I would like to know how to declare constants and globals so that they can be used in every single card and every single object in a stack (maybe the sub stacks as well).
Thanks!
Proza
P.S. I tried to put the declaration on the top of the stack script, but only the handlers on the stack script can see them. The handlers on the card scripts and object scripts cannot see them.
Constants and Globals
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Hi proza,
constants are local!
So you can put them on the top of a script and use it in any handler in that script, as you already found out
Globals are erm global...
You can declare them anywhere and anytime you want and they are valid and accessible in THAT very moment.
But you have to tell the engine in every handler THAT you're gonna use it.
e.G.
then you can use and alter this variable in every handler in your stack like:
Some button:
Well, that's it, basically 
Have a nice weekend.
Best from germany
Klaus
constants are local!
So you can put them on the top of a script and use it in any handler in that script, as you already found out

Globals are erm global...
You can declare them anywhere and anytime you want and they are valid and accessible in THAT very moment.
But you have to tell the engine in every handler THAT you're gonna use it.
e.G.
Code: Select all
on preopenstack
global your_global
put "my global" into your_global
...
end preopenstack
then you can use and alter this variable in every handler in your stack like:
Some button:
Code: Select all
on mouseup
global your_global
answer "This is" && your_global &&" and not yours!"
put "your global" into your_global
answer "This is" && your_global &&" and not mine!"
...
end mouseup

Have a nice weekend.
Best from germany
Klaus