LC equivalent of the JS eval() function

Dar Scott dsc at
Sun Jul 24 14:26:17 EDT 2011

People have already mentioned 'do', 'merge()' and using arrays.  

I'll add these:
Set the script of an object.  
Use a switch statement.
Set a chunk of the value of a variable, perhaps a global.  
In limited situations, 'value()' might be useful.  
Pass the variable to the function rather than its value using @.

Both 'do' and set scripts are limited to 10 lines in standalone applications.  Perhaps 'do' is the most direct solution to what you want to do.

(I have found 'merge' to be powerful in some cases.)

I suspect what you want to do might be done well with a (perhaps global) variable containing an array.  Like this:

	put "202 Main Street" into stuff[ tAddress ]

However, maybe the @ fits into your scenario.  Put an @ in front of a parameter in a hander (command or function) and when it is called with a variable the variable is passed not the value; use of the parameter is the same as the use of the original variable.  This is much like pass-by-reference in Java.  Like this:

on configureLocation @pAddress, @pCity, @pState, pLongitude, pLatitude
	put "202 Main Street" into pAddress
end configureLocation

(Having--tongue-in-cheek--thrown candy at speakers at a RunRev conference who promoted their "morals" in using variable prefixes, I have to say that the use of such prefixes above does not constitute a promotion of such use, but only exists as an aid in communicating the example.)

I wish you well in this.

Dar Scott

More information about the Use-livecode mailing list