Example: My Interactive debug mode code block

When writing scripts that are normally driven by a calling script with parameters, I needed a way to set those variables during development. When I first started writing Eggplant code, I was adding and commenting these items out. Of course, there’s always the chance that I forget to comment a parameter out, and it can take a while to find a problem like that. Additionally, since it is interactive, I can set variables each time without changing the script.
In my situation, I have a global variable that always needs to be set. My debug block executes if it is not set, but you may have better ways of triggering it.
My debug block is simple and varies from script to script, but the format is generally the same. It interactively asks for the values of each of the parameters that would normally be set by another calling script. It also logs a warning that the variables were set for debug purposes.

I hope this brings joy to someone else :slight_smile: :

if global requiredVariable is "" 
	ask "You must be in Debug Mode : please enter your global requiredVariable: "  with  "Default Variable" Title "¿Debug Mode?" 
	runScriptToSetVariable it
	ask "What is parameter2 ? " with 3
	set parameter2 to it
	ask "What is parameter3 ? " with 1
	set parameter3 to it 
	logwarning " Variables set for Development only!!"
end if

That’s a great tip, Brett. Thanks for posting it. A feature that might augment this was introduced in eggPlant v12. As of that release, you can specify a script template file in the Suite Settings that provides a default template for any new scripts created in that suite. So if you want to add code like this to every script, put the skeleton of it in a template. The template is also a great place for a standard header with things like placeholder comments for the script author, a description of the scripts purpose, etc.

I haven’t gotten around to using new templates yet… that’s a perfect place to store this as you suggest. Thanks Matt.