Using handler local variables of caller

Mark Wieder mwieder at ahsoftware.net
Tue May 1 21:49:36 EDT 2012


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





More information about the use-livecode mailing list