calling a handler as a variable
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
calling a handler as a variable
Hi: referencing the name of a handler as a variable won't work. Any idea how to accomplish this?
ie the following won't work, but gives you an example of what I'm trying to do:
-------
put "runThisSystem" into myHandlerName
if this then myHandlerName (var1,var2)
-------
When I run "myHandlerName", I actually want to run "runThisSystem"
ie the following won't work, but gives you an example of what I'm trying to do:
-------
put "runThisSystem" into myHandlerName
if this then myHandlerName (var1,var2)
-------
When I run "myHandlerName", I actually want to run "runThisSystem"
Re: calling a handler as a variable
Code: Select all
on mouseUp
put "runThisSystem" into myHandlerName
if myHandlerName = "runThisSystem" then
runThisSystem
end if
end mouseUp
on runThisSystem
beep
end runThisSystem
Re: calling a handler as a variable
Hi Greg,
just DO it
...
put "runThisSystem" into myHandlerName
do myHandlerName
...
Best
Klaus
just DO it

...
put "runThisSystem" into myHandlerName
do myHandlerName
...
Best
Klaus
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: calling a handler as a variable
Klaus - oops, it's a FUNCTION, not a handler. Sorry. It's like this:
...
put "runThisSystem" into myFUNCTIONname
put myFUNCTIONname (var1,var2,var3) into whatever
...
...
put "runThisSystem" into myFUNCTIONname
put myFUNCTIONname (var1,var2,var3) into whatever
...
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: calling a handler as a variable
Hi Dixie: Sorry, it was a FUNCTION, not a handler. Yes your solution would work, but for other reasons, I can't run a bunch of if scenarios. The user would type the name of the system to run in a field, and the script should just find the function in the stack scripts and run it. Every time I add a new function, I don't want to add a corresponding "if then". you know?
Dixie wrote:strange...Code: Select all
on mouseUp put "runThisSystem" into myHandlerName if myHandlerName = "runThisSystem" then runThisSystem end if end mouseUp on runThisSystem beep end runThisSystem
Re: calling a handler as a variable
Hi.
Like this?
Craig
Like this?
Code: Select all
on mouseUp
put any item of "A,B,C" into var
put "runThisSystem" && var into myHandlerName
answer runThisSystem(var)
end mouseUp
function runThisSystem var
return "You chose" && var
end runThisSystem
Re: calling a handler as a variable
dunbarx wrote:Hi.
Like this?CraigCode: Select all
on mouseUp put any item of "A,B,C" into var put "runThisSystem" && var into myHandlerName answer runThisSystem(var) end mouseUp function runThisSystem var return "You chose" && var end runThisSystem




Value can help here:
...
put "runThisSystem" into myFUNCTIONname
put VALUE("myFUNCTIONname (var1,var2,var3)") into whatever
...
tested and works!
Best
Klaus
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: calling a handler as a variable
That's it Klaus. I've never used VALUE before. Thanks!