FYI, initializing variables by reference

Peter M. Brigham pmbrig at gmail.com
Tue Jun 19 08:13:17 EDT 2012


Yup, try it and see. The variables are loaded and their values are available in subsequent script lines. 

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig

On Jun 18, 2012, at 4:53 PM, Bob Sneidar wrote:

> You are saying these variables survive the command call because they are called by reference? Interesting! I would have thought that this would throw a compile error because the variables do not exist in the calling handler. 
> 
> Bob
> 
> 
> On Jun 18, 2012, at 7:24 AM, Peter M. Brigham wrote:
> 
>> For some reason I never realized that you can use referenced variables in a command handler -- I was thinking of them only when using functions. In case others haven't discovered it, you can, for instance, do something like this:
>> 
>> on prepareInvoice tID
>> initializeVars tID, tName, tDOB, tAddr, tPhone
>> -- now you can go on and do something
>> --     with the initialized variables
>> -- ...
>> end prepareInvoice
>> 
>> on initializeVars tID, @tName, @tDOB, @tAddr, @tPhone
>> put fetchData(tID) into tArray
>> put tArray["name"] into tName 
>> put tArray["DOB"] into tDOB
>> put tArray["ID"] into tID
>> put tArray["address"] into tAddr 
>> put tArray["phone"] into tPhone
>> end initializeVars
>> 
>> This may not be new to some, but it was new to me.
>> 
>> -- Peter
>> 
>> Peter M. Brigham
>> pmbrig at gmail.com
>> http://home.comcast.net/~pmbrig
>> 
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list