I have been trying to use a universal variable across scripts and suites, but don’t get any value in the variable when I reference it even in another script in the same suite.
Do universal variables require the use of the keyword “universal” when they are used, or can I set the execution context to universal in my primary (main) script and then just use the universal variables I have declared there whenever/wherever I like?
A code snippet of this would be great. Currently, I’m doing this
repeat blah blah
end main loop
But when I use the universal variable like that, nothing happens.
I think I figured it out… error on my part. But please answer, the use of “universal” is not well documented.
The use of the Sensetalk ‘universal’ directive is designed to allow a container to be used over and over again during the entire host application’s runtime. That is to say, Sensetalk is embedded within Eggplant. So between script invocations, you can use the universal directive to keep a container from being sent to the Sensetalk garbage collection system as unused.
I hope that helps.
Coincidentally, I just (belatedly) replied to your original question about this on another thread (sorry to take so long).
Just to be sure it’s clear:
[list]? Global and universal variables must be declared in each handler that uses them, or else preceded by the word global or universal each time they are used.
? Undeclared variables that are not preceded by the word global or universal within a handler are local to that handler.
? Local variables have a value within a single execution of a single handler, and are discarded when the handler finishes executing.
? Global variables have a value that persists across handlers. They are discarded at the end of a run.
? Universal variables have a value that persists across handlers and across runs. They are discarded when Eggplant quits.
? The three types of variables are all distinct (that is, you may have local, global, and universal variables all in existence at the same time with the same name but different values).
I hope that helps clarify. Todd’s answer above is in reference to the difference between global and universal variables.
When in doubt, I suggest that you experiment with small test scripts to see how things work. Single stepping through some scripts in debug mode may be helpful.
Those four bullets should be in the SenseTalk maual. You cleared everything up in a second. Now I just have to strip out all those extra parameters I was passing around… sigh :oops:
Good idea, thanks! Expect to see that clarification in the next version of the documentation.