variable list? Global var confusion
Sarah
sarahr at genesearch.com.au
Mon Sep 1 16:25:01 EDT 2003
Hi John,
If you need a variable that can be accessed by all handlers in a single
script e.g. your card script, but NOT by handlers outside that script,
then you can declare them as local at the start of your script. For
example:
local myLocalVar
on openCard
put 1 into myLocalVar
end openCard
on clickHere
add 1 to myLocalVar
end clickHere
on displayVar
put myLocalVar
end displayVar
You may have to move some scripts from buttons to the card script for
this to work, but I think it will be the easiest way around your
problem. BTW, you can list all global variables using either the
message box (4th button from the left) or the Variable Watcher.
Cheers,
Sarah
On Tuesday, September 2, 2003, at 11:03 am, John Tenny wrote:
> Is there a way to see a list of all variables and current contents in
> a stack? Some window/chart?
>
> I think I'm misusing global variables.
> I doing a set of timers, each on a different card. Being lazy,I copied
> the first card and adjusted things, using the same global variables. I
> used global as there are several buttons on each card that add to the
> same set of variables/fields (on the same card)
>
> Now I discover that I'm changing the variable contents in the other
> cards as well.
> My thoughts:
> 1. go through a hundred or so buttons and change the variable names (a
> terrible thought) where ever they appear in the scripts
> 2. ?? move the declarations from outside the handlers to inside the
> handlers?? This would be quicker as I wouldn't have to edit all the
> scripts, just cut and paste.
>
> What I think I want (but not sure) is a set of variables that work
> 'globally' on one card, for all the handlers on that card, but no
> other card.
>
> Oh, and I don't want to empty the variables till the program closes as
> the user will want to print the cards (marked through a button on each
> card) at the end of the session, just before quitting.
More information about the use-livecode
mailing list