any use of pass by reference breaks any omitted variable?

Peter M. Brigham pmbrig at gmail.com
Mon Nov 24 14:05:23 EST 2014


On Nov 22, 2014, at 10:38 PM, Dr. Hawkins wrote:

> Pass by reference *should* be something useful, but it seems half done.
> 
> I have various handlers with optional parameters.
> 
> It seems that if *any* parameter is passed by reference, omitting any
> variable causes a runtime error

Hmm. I tested this:

on testReference
   put 8 into someVariable
   put 5 into someOtherVariable
   setVariable someVariable -- second param omitted
   answer "someVariable was 8, and is is now:" && someVariable
end testReference

on setVariable @incomingVar, at someOtherVariable 
   add 1 to incomingVar
end setVariable

…and got an error message. But if I make the second parameter in the setVariable function *not* by reference

on setVariable @incomingVar,someOtherVariable

then the same test works. It appears that if you are passing variables by reference you must supply all the referenced variables, but you can leave out non-referenced variables.

I'm using an older version of LC: 2008 MacBook, OSX 10.7.4 (Lion), Rev Studio 5.5.1, build 1487. Don't know about lC 6.x or 7.x.

-- Peter

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





More information about the use-livecode mailing list