Using handler local variables of caller

Dar Scott dsc at swcp.com
Tue May 1 19:23:10 EDT 2012


Thanks, Bob and Peter!

I didn't think there was a way, but I thought I'd ask.

I have two goals.

1
I sometimes create commands that are like built-in commands that modify 'it'.  It would be nice if mine can modify 'it' to simplify the code and make it easier for users to learn and for me to specify.  Instead, I have the user pass a variable by reference (@).  That creates one tick down for readability.  It also seems goofy when there are cases when the referenced variable is not set and it is just unneeded appendage.  

2
The other goal is to denote some expression in a standard domain language and have it evaluated but referring to variables in the caller's view.  The two methods I use now are to use a lot of nested functions (not in domain language) or to compile to a string that is evaluated, like this:

put value(  darzXenologic( "blah-blah-blah mentioning variables a, b and c" ) ) into b

The function darzXenologic() compiles the domain language into LiveCode that is evaluated by LiveCode value().

What I'd like to do is this:

put darzXeno( "blah-blah-blah mentioning variables a, b and c" ) into b

I don't see a way to do it.

I could do this:

put darzXeno( "blah-blah-blah mentioning variables a, b and c", "a", a, "b", b, "c", c) into b

Now, I'm losing readability again.  Well, it seems to to me.


I think I'm stuck with what I have.

Dar Scott


On May 1, 2012, at 4:58 PM, Bob Sneidar wrote:

> If the handlers are in the same script, can't you use script local variables? If they are in different scripts, then Peter's suggestion of using properties may be the way to go. Seems like a lot to avoid passing parameters though. 
> 
> Bob
> 
> 
> On May 1, 2012, at 3:11 PM, Dar Scott wrote:
> 
>> I'd like a function to use some variables of the caller without them being passed or being declared as globals.  Is there a way to do that?
>> 
>> Desktop externals can do that, but I don't see a way for a library in a function to do that.
>> 
>> Dar
>> 
>> 
>> _______________________________________________
>> 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