Weirdness with global variable declaration
Ray G. Miller
rgmiller at pacbell.net
Tue Jan 20 14:01:11 EST 2004
>
>
>Robert Brenstein said,
>
>I haven't tested this with the newest engine but earlier it was like
>Richard mentioned: globals had to be declared within a handler. There
>was some technical reason for that if I recall.
>
>
>
Yes, the globala are *declared* within a handler, but setting the
globals for all can set, usually at the top of the script editor, for
each "section" (card script, background script, button script).
For example:
In the card script, at the top you could set:
global gCatNames, gDogNames, gGreatToys
on preOpenStack
doTheNeatFldLocs
doEmptyLitterBox
--
setTheGlobals
end preOpenStack
on setTheGlobals
put fld "catNames" into gCatNames
put fld "dogNames" into gCatNames
put fld "greatToys" into gGreatToys
end setTheGlobals
... then, in the stack script (or any control script), simply start each
script page with:
global gCatNames, gDogNames, gGreatToys
and those globals are available to all handlers on that page.
This of course, works across all subStacks as well.
Ray G. Miller
__________________
Turtlelips Productions
4009 Everett Ave.
Oakland, CA 94602
MailTo:rgmiller at pacbell.net
(V) 510.530.1971
(F) 510.482.3491
More information about the use-livecode
mailing list