Ignoring a piece of code...

Hello Auberlords, Earls, and Knights–

Is there a way to tell eggplant not to execute a piece of code if that script is called by another script via the run command?

What I’m trying to do is use a script I’ve already written that has some verification logging in it. In this special case, I’d like the calling script to handle verification, because I want to keep track of which iteration through a repeat loop “fails” ie: the file is corrupted after pass number 1,045 again after 2007, etc.



Probably the simplest aproach is just to pass a parameter (or an additional parameter) to the called script, and have it check the value of that parameter to decide whether it should perform validation or not.

So, if you usually call your script with:

ExerciseTheSUT someParameters

you would change that to:

ExerciseTheSUT someParameters, true

Then, in your ExerciseTheSUT script, you would check for the extra parameter something like this:

params incomingParameters, suppressValidation
if suppressValidation is not true then
    -- your validation code goes here
end if

SenseTalk is flexible about the number of parameters passed to a called script – you can always call a script with more (or fewer) parameters than it declares. So calling ExerciseTheSUT with only the usual parameter(s) will just leave suppressValidation empty.

If the approach of using an extra parameter to tell the called script whether or not it should perform validation doesn’t seem workable for some reason, you could take a look at the callStack() function, which can allow a script to find out which script called it, but that’s much more involved than what you most likely really need.