Code: Select all
on mouseUp
global gDoThis
put figureThis(gDoThis) into newTask
newTask --(the name of a handler. like "doLink")
end mouseUp
on doLink
beep
end doLink
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Code: Select all
on mouseUp
global gDoThis
put figureThis(gDoThis) into newTask
newTask --(the name of a handler. like "doLink")
end mouseUp
on doLink
beep
end doLink
Hi,melristau wrote:what is returned by function is the name of a handler?
Code: Select all
on mouseUp global gDoThis put figureThis(gDoThis) into newTask newTask --(the name of a handler. like "doLink") end mouseUp on doLink beep end doLink
Code: Select all
on mouseUp
dispatch figureThis( "whatever")
end mouseUp
Code: Select all
on mouseUp
send figureThis( "whatever") to me in 1 millisecond
end mouseUp
Code: Select all
on doLink
beep
end doLink
function figureThis state
return "doLink"
end figureThis
Code: Select all
on mouseUp
dispatch function "figureThis" with "whatever"
end mouseUp
Code: Select all
on mouseUp
global gDoThis
put figureThis(gDoThis) into newTask
send newTask to me in 0 milliseconds
end mouseUp
function figureThis
-- return the name of the handler to call
-- i.e., return "doLink"
end figureThis
on doLink
beep
end doLink
Hi Mark,mwieder wrote:Thierry-
I think the proper dispatch syntax for functions isCode: Select all
on mouseUp dispatch function "figureThis" with "whatever" end mouseUp
Code: Select all
on mouseUp
dispatch figureThis( "whatever")
end mouseUp
on doLink
answer "cool!"
end doLink
function figureThis state
return "doLink"
end figureThis
Code: Select all
call handler [of object]
What should "dispatch function" do?mwieder wrote:Should be noted that the call command only works for other commands, not functions.
Interestingly, I don't see the "dispatch function" form documented in the dictionary.
Code: Select all
dispatch function "grunt" with "1234"
function grunt pValue
return pValue * 2
end grunt
Hi Mark,mwieder wrote:Thierry-
Yes, it does/should work.
I also used the "send" form rather than "dispatch" because I can't remember how asynchronous the dispatch command is, and it might be important to end the mouseUp handler before processing the result of figureThis. For a single-line call like this it shouldn't matter, but if the executing command is blocking or otherwise takes a long time, the end result could be ambiguous.