Using handlers from another script.

Just wanted to say that I’m still pretty new to using Eggplant…

I wrote a bunch of handlers to do different things. I had every bit of code all in the same script and I was just using the Run Selection tool to test their functionality. Now that I’ve verified everything works I’m having trouble calling those handlers now whenever I put them in a different script. It is as if they don’t exist. Maybe I have a backwards approach to this, but the script is setup to run all of these handlers in series. Essentially I had all of the handlers at the top of the script, and was calling them at the bottom. I wanted to put all of those handlers into some sort of a separate include script if you will so I could just use Run Script on the main one but like I said, it wouldn’t work.

I’ve been looking at documentation all day and just keep going in circles. Can someone break down how I would kind of “include” a set of handlers and how I’d get them to run if they were called? Some of them have parameters.

Any help would be awesome. Thanks so much.

Handlers within a SenseTalk script are only accessible from within that script, unless the script is added as part of the message passing path. The most common way to add scripts to the message path is with the start using command. They can be removed with the stop using command. These commands actually add and remove scripts from a global list called the backScripts, which can be accessed and manipulated directly but rarely is.

So, to make the handlers in a script called CommonHandlers available, you would say

start using "CommonHandlers"

to stop using the handlers in that script:

stop using "CommonHandlers"

and to see what scripts are currently in the message path (after the current script):

put the backScripts

Eggplant also provides mechanisms for adding all of the scripts in a suite to the message path (but not the handlers in those scripts) with the InitialSuites and the FinalSuites global properties, which have recently been discussed here.

First, within a single script, you can’t call handlers after you define them, unless you’re doing it from within another handler. So your single script probably would not have done anything.

Next, to call handlers within another script, there are a couple of notation options:

run secondscript.somehandler
run secondscript's somehandler
run somehandler of secondscript

See Chapter 4 of Using Eggplant for more examples.

Thanks for the info!

Will definitely try those things.