Using handler local variables of caller

Dar Scott dsc at swcp.com
Tue May 1 22:03:41 EDT 2012


Hi, Mark!

You hit the nail on the head.

You work with desktop externals, right?  They don't have this limitation.  Since iOS externals do have the limitation, I'm not going to go that way.

Here is a goofy solution:

function darzCommand
	get 123
	return "put " & it & " into it"
end darzCommand

on mouseUp
	do darzCommand()
end if

So, far the best solution for the 'ask' extensions is to add to the documentation:

	For all uses of the darzAskXxxx commands, pass a variable as the first parameter to receive the requested value.
	When replace existing 'ask' commands, simply use the variable named 'it'.  

Something like that.  

Dar


On May 1, 2012, at 7:49 PM, Mark Wieder wrote:

> Dar-
> 
> Tuesday, May 1, 2012, 5:14:42 PM, you wrote:
> 
>> I want to make a few commands and functions that work like some built-in functions.
> 
>> For example, the built-in commands 'read' and 'ask...' both set
>> 'it'.  If I make my own version of 'ask', I'd like for the command
>> to set 'it'.
> 
> Setting "it" is the easy part. Convincing the compiler to accept "it"
> after a command is hard.
> 
> on DarzCommand
>  do "put 123 into it"
>  -- now 123 is in both it and the result
>  return it
> end DarzCommand
> 
> on mouseUp
>  DarzCommand
>  put it -- this will give a compiler error
> end mouseUp
> 
> ...while...
> 
> function DarzCommand
>  do "put 123 into it"
>  -- now 123 is in both it and the result
>  return it
> end DarzCommand
> 
> on mouseUp pMouseBtnNo
>    get DarzOwnVersionOfAsk(13)
>    if it is 123 then
>        put "yep"
>    else
>        put "nope"
>    end if
> end mouseUp
> 
> works as designed.
> 
> -- 
> -Mark Wieder
> mwieder at ahsoftware.net
> 
> 
> _______________________________________________
> 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