Subject: Re: variable list? Global var confusion

John Tenny jtenny at willamette.edu
Tue Sep 2 00:50:01 EDT 2003


Sarah and Dar

Thanks for the clues. What I have is from 2 to 10 buttons on a card, 
each adding/calculating percent of totals for all the corresponding 
fields. Right now, I have the scripts in each button, but they all 
access common variables. Is there a way to put all that scripting into 
the card script? Or do you mean that I can declare the variables as 
local in the card script, and then have the handlers in each button as 
needed? There's no conflict within the individual card, only between 
different cards.

and unrelated -- what's the best way to reply to an individual post 
within the digest?

John
==============
Date: Tue, 02 Sep 2003 11:13:42 +1000
From: Sarah <sarahr at genesearch.com.au>
Subject: Re: variable list? Global var confusion
To: use-revolution at lists.runrev.com
Reply-To: use-revolution at lists.runrev.com

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