Reusable Code (again)

Richard Gaskin ambassador at fourthworld.com
Tue Nov 30 06:26:03 EST 2004


Ken Norris wrote:
> Hi Gordon,
> 
> On Nov 30, 2004, at 2:25 AM, use-revolution-request at lists.runrev.com wrote:
> 
>> Date: Mon, 29 Nov 2004 20:39:49 -0800 (PST)
>> From: Gordon <gwalias-rev at yahoo.com>
>> Subject: Reusable Code (again)
>>
>> 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?
> 
> 
> I think you're making it too hard. Store it in custom props instead, 
> call it via path from wherever you are.

Or use a function, which adds only two characters:

  function:   get myValue()

  global var: global gMyValue
              get gMyValue

  property    get the uMyValue of stack "Props"


Function calls carry a bit of overhead relative to the others, but its 
just a few nanoseconds and if you need to use the value often in your 
script yoiu can just copy it to a local var:

   put myValue() into tMyValue
   repeat with i = 1 to 100000
      add tMyValue to tTotal
   end repeat


-- 
  Richard Gaskin
  Fourth World Media Corporation
  ___________________________________________________________
  Ambassador at FourthWorld.com       http://www.FourthWorld.com


More information about the use-livecode mailing list