bobs at twft.com
Thu Oct 14 14:09:09 CDT 2010
I think script local variables have to be declared, but constants don't. Once you create the constant it is accessible in all scripts. With a script local variable, you have to declare it, and the same variable name in two different places, say the card script and the stack script, would be two different variables with potentially two different values.
A global variable would be one variable one value, but you have to make sure you declare it before you use it, and it it's scope is any running stack. A constant (or so it is my understanding) is created once, then available to all scripts in the stack (I think the scope is just the stack that created it, but it may be for the entire environment) and you wouldn't have to declare it in each script.
If I am in error here feel free to call me on it.
On Oct 14, 2010, at 10:50 AM, DunbarX at aol.com wrote:
> But script local variables do all that as well, no? It isn't a big deal,
> but except for the fact that these can replace predefined constants (a feature
> less available in LiveCode than in HC, especially as regards build-in
> functions) I still don't see the point.
> Couldn't hurt to have them, though. And you would get an error if you ever
> tried to change one in the same handler, so that might be a check of some
> kind. Did I mention it was no big deal?
> In a message dated 10/14/10 12:34:55 PM, m.schonewille at economy-x-talk.com
>> Hi Craig,
>> I don't know if it is compelling, but a constant is readily available to
>> all handlers in a script. If you have a library with functions and you don't
>> know which function will be called first, it is useful to not be required
>> to define a local variable in every function. Usually, I keep constants at
>> the top of a script, which makes it easy to adjust a script for different
>> customers or servers. Sometimes, I use a constant only because it is easier
>> to write, e.g. I consistently use dot instead of ".".
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the use-livecode