Can a constant be global?

David Burgun dburgun at dsl.pipex.com
Mon Mar 27 07:12:19 EST 2006


On 27 Mar 2006, at 13:04, Robert Brenstein wrote:

>> This is another of those things that I've lived without for years  
>> - I normally use globals to contain text strings which may change  
>> if the human language of the app changes (what is the Welsh for  
>> "Cancel"? - don't know, but I know someone who can tell me!), so  
>> that all the values can be initialised in one handler when the app  
>> starts up: but after all this time I thought I'd try using  
>> constants instead.
>>
>> However neither the RR documentation nor my experiments seem to  
>> suggest that there is a way of making constants global (i.e  
>> constant). Can this really be true? If so, they have a crushing  
>> disadvantage with respect to globals. After all, RR's own  
>> constants are global. I guess I've missed something.
>>
>> Thanks to anyone who can dispel another of my clouds of ignorance.
>>
>> Graham
>>
>
> RR's own constants are global because they are part of the language  
> so do speak. As such, they are defined in the engine. That makes  
> them a different beast than constant defined in your scripts.
>
> Replicating constant behavior at global level has been discussed  
> quite a lot in the past, and not only on this list, but... it is a  
> lot more complicated than it seems at first glance. So, for now at  
> least, there is no way to make a global behave like a constant  
> through declaration. It is up to you to designate some globals as  
> global constants, like using a different prefix than for global  
> variables.

But the problem there is where do you actually set them? Obviously  
you have to make sure they are set before another stack/card/control  
uses them.

That's why I decided that a Constant Library was a better way to go.

All the Best
Dave





More information about the Use-livecode mailing list