doubts about globals, seeking advise...
Ken Ray
kray at sonsothunder.com
Sat Jan 3 16:39:40 EST 2004
Andre,
Globals are just that... "global". This means that as long as Rev is
running (i.e. the engine is in operation and you haven't quit), the
values you put in a global will remain and be accessible from all stacks
that are open.
> Can two stacks share globals? Like that, I've got a
> splashscreen stack
> and a app stack, can I open a database connection in the
> splash screen
> stack, put the ID in a global and then call DB Methods in the app
> stack?
Yes.
> It's like that, i've got a running app, it works, but
> I decided
> to add a standard splash screen (thats reused many times, so it's got
> it's own stack), I decided that the splash screen should be the
> mainstack (thats its setting in the distribution builder)
> since I want
> it to appear first. I used to open and close the DB
> Connections in the
> openStack and closeStack handlers of the app stack, but when I build
> the distribution (including all libs and stuff), the DB funcs start
> shouting about invalid id, I think that's happening because my global
> vars are missing... I tried another approach opening and closing
> connections in splashscreen, writing IDs to custom props and reading
> them from the other stack, but that's just ugly. Anyone here got two
> cents to spare on advise? How should I proceed? Should my
> splashscreen
> stack just call the other stack openStack handler and pray?
Well, I'd make your DB Connections open/close with the
openStack/closeStack handlers of the app stack, but don't open that
stack until the splash has fully displayed. After the splash goes away,
open the app stack and have it run the connections to the database. If
you need to pass information between the splash stack and the app stack,
you can use globals, but my question would be: where do the IDs come
from? Does the splash stack even need to *know* the IDs? Or can the IDs
just get initiated when the app stack opens? As in:
-> Launch executable
-> Splash stack displays
-> Splash stack closes
-> App stack displays, makes initial DB connection, stores IDs
???
Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
More information about the use-livecode
mailing list