set default parameter value for a handler

I write a handler

to handler1 param1,param2

end handler1

I want to set default value for param1, param2, thus the handler still can run with default value though caller gives no param value.
how can I do that?

hey df4747–

You can definitely make parameters optional:

to handler1_deluxe param1, param2
     if param1 is empty then put default_value into param1
     if param2 is empty then put another_default into param2
     #do stuff
end handler1_deluxe

Hope this helps!

thanks a lot,
yes, it is good way.

I want to do like this:

to handlerA param1, param2, param3

end handlerA

when I call handlerA, I can call like this

handlerA a, b

even if no param is set to param3, I can have a default value used for param3

just like in C++:

int myfunction(int param1, int param2, int param3=0)

param3 has a default value, when call this function,
I do as this myfunction(1,2)

SenseTalk allows you to call a handler with fewer parameters than you have declared. In this case, the parameters that weren’t given values will be empty in the called handler. So you can supply default values for those parameters as described earlier, by testing whether they are empty.

SenseTalk doesn’t currently provide a syntax for supplying default values directly (like the example you gave), but we will consider that as a possible enhancement in the future.