Reusable Code (again)
Sarah Reichelt
sarahr at genesearch.com.au
Tue Nov 30 00:14:35 EST 2004
No, it doesn't really work with either globals or constants, although
again, you can fake it with handlers.
Suppose you have a global in the Math stack called "gVar".
You can set it from anywhere using a special handler in the Math stack
script:
on setGlobal newSetting
global gVar
put newSetting into gVar
end setGlobal
And then retrive the value at any time:
function readGlobal
global gVar
return gVar
end readGlobal
Using the "do" command, you could make these general global setting &
reading handlers but for starters, it's easier to follow this way.
This is a way to get around having to declare the global in every
script where you need it.
Sarah
On 30 Nov 2004, at 2:41 pm, Gordon wrote:
> Sorry, I meant to ask for a variable example, not a
> constant. My question is this then ...
>
> How do I have my reusable stack introduce a global
> variable that can be passed around in an application
> that uses the stack? Can I declare a global variable
> in the stack script of the reusable stack and then use
> the 'start using' construct that was described
> earlier?
>
> Does this avoid having to declare the same global
> variable in the rest of my app?
>
> Best
>
> Gordon
>
>> e.g. my library stack contains ...
>>
>> a constant called 'HalfCircle' with a value of 180.0
>>
>> a function called 'degreestoradians' defined as
>>
>> function degreestoradians degrees
>> return (degrees/180.0) * 3.1415926
>> end function
>>
>> How do I store these in my library stack?
>> How do make them available to the rest of my app
> when
>> the library stack is loaded?
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
>
More information about the use-livecode
mailing list