Session and webpage issues

I’ve got two webpages, cc and ccipad. In session, I’ve got a property called c as webpage.

in session.open I’ve got c = cc.

The problem is that any method, whether in session or cc, returns a item does not exist error. (c.lstRoutine.Cell(row,3) for example).

any suggestions? please … please realize I’m not a professional programmer like you guys.

You need to cast c. Assuming property c as WebPage:

if c isa cc then cc(c).lstRoutine.Cell(row, 3) = ... elseif c isa ccipad ccipad(c).lstRoutine.Cell(row, 3) = ... end if

That sounds backward. Using the below example, page0 is supposed to represent either webPage1 or webPage2, depending on the platform. If webPage1 is chosen, webPage1 is shown and “hi” is written in label1.

However I get a “this item doesn’t exist” error.

(can’t seem to insert an image here)

Session
Open:

page0 = webPage1
page0.show

page0.label1.text = “hi”

Properties:
page0 as webpage

webpage1 as webpage
controls
Label1 as txtLabel

webpage2 as webpage
controls
Label1 as txtLabel

OK, well, I was working with what you gave us. YMMV.

[quote=40875:@John Scanlan]That sounds backward. Using the below example, page0 is supposed to represent either webPage1 or webPage2, depending on the platform. If webPage1 is chosen, webPage1 is shown and “hi” is written in label1.

However I get a “this item doesn’t exist” error.

(can’t seem to insert an image here)

Session
Open:

page0 = webPage1
page0.show

page0.label1.text = “hi”

Properties:
page0 as webpage

webpage1 as webpage
controls
Label1 as txtLabel

webpage2 as webpage
controls
Label1 as txtLabel[/quote]

webPage1 and WebPage are distinct classes. WebPage does not have a reference to Label1 but webPage1 does. So if you are going to store a reference to the base class (WebPage) then Brad is correct you will need to cast. The reason is that whatever code accessing the page0 property does not know whether its a webPage1/webPage2/WebPage and will assume the latter (what you defined it as).

So you’re saying that I can’t use single code to do things in different window layouts depending on the platform … I think.

Something like if page0 = webpage1 then else end if will end up repeating all the code. That’s what I’m trying to avoid. Brad’s suggestion makes sense but repeats code in the same way. I’m afraid this is going to become a huge app.

My app is code heavy out of necessity (http://sfo1.sc1473a.1701hosting.com/cgi-bin/rio/rio.cgi).

or am I missing something? probably something basic?

Well one thing you can do is move all the duplicate code to a method so the if statement just calls the appropriate setup routines.

You could create a class interface and implement it in both classes. Your general approach though strikes me as too cute by half. I’d have to get my head around what you’re trying to accomplish to recommend a better route, but I have a feeling there is one.

is there a way to say do stuff in whichever page happens to be active?

any ideas yet Brad ? :slight_smile:

You’re looking for some syntactic sugar here to deal with the reality that cc and ccipad are two different subclasses of WebPage. What exactly are the differences between cc and ccipad? And from where are you calling cc.lstRoutine(…)? The way I design stuff, I would never end up doing something like that except to implement a data push from one session to another. Maybe we can help you keep things isolated to a page and avoid the issue.

Use a class interface like Brad suggested.

ipad needs much bigger buttons for fat coaches’ fingers. cc.lstRoutine is a listbox in a container control.

also trying the class interface, but when I create a class instance (c = new circleCalcRoutines) in cc, I get a c does not exist error when trying to call c.dosomething.