Handlers don't execute from Run Script ?

I’m going through some of the examples in the sensetalk manual and I put this line in:

to greetTheUser 
	put "Welcome to SenseTalk. Happy scripting!"
end greetTheUser

greetTheUser

I also tried:


to greetTheUser 
	ask "Welcome to SenseTalk. Happy scripting!"
end greetTheUser

greetTheUser

When I run the script, it does not greet me, or log it.
I did figure out that i can do it in the run window, or from another script called as : Handlers.GreetTheUser , but i expected it to execute directly from the Run Script button. Am I missing something?

Handler definitions within a script have to appear after the code in the script. The code that is not in a handler definition is referred to as the “initial handler”. Code that is not in a handler and does not appear at the beginning of the script is just never called. In the example here, your call to the greetTheUser handler is the initial handler for the script, so the code needs to be written like this:

greetTheUser

to greetTheUser
   put "Welcome to SenseTalk. Happy scripting!"
end greetTheUser

The order of other handler declarations is not important – a handler can call any other handler defined either above or below it in the script.

Hello Matt,

One quick clarification required wrt to the Generic Handlers.

I have written a piece of code like this:

put 30 into c1
put 40 into d1

greetTheUser c1,d1

to handle greetTheUser a,b
log a
log b
put
end greetTheUser

But I am not seeing anything in the log.Also I am getting an STUnknown message error. I am sending the error message that I am getting for easy reference purpose as well.

The code that you show works fine on my systems (both Mac and Windows). The screenshot indicates that you were running a selection. What does the whole script look like and what did you have selected? Selections have to be syntactically correct code in order to execute properly.