Universal Variables
Hi,
I'm unable to access the universal variables that i have decalred in mhy scripts.
Scenario is:
In my Testsuite I have 3 scripts (script1, script2, script3). Script3 uses script1 and Script 2 (with help of Start Using ).
Script 2 has function setUniversalVariables where i set my universal variables(univar1,univar2) with initial values. and in the course of script 2 these values get modified.
Now, when I access these Universal variables for ex: TypeText UniVar1
instead of displaying values of UniVar1 it just displays text Univar1.
Please advise on how do I access the Universal variables declared.
Thx in advance.
-Veena
I'm unable to access the universal variables that i have decalred in mhy scripts.
Scenario is:
In my Testsuite I have 3 scripts (script1, script2, script3). Script3 uses script1 and Script 2 (with help of Start Using ).
Script 2 has function setUniversalVariables where i set my universal variables(univar1,univar2) with initial values. and in the course of script 2 these values get modified.
Now, when I access these Universal variables for ex: TypeText UniVar1
instead of displaying values of UniVar1 it just displays text Univar1.
Please advise on how do I access the Universal variables declared.
Thx in advance.
-Veena
Comments
~Charles
There are two different ways you can declare a variable as global. Either use the word "global" before the variable name everywhere you use it, like this: Or, declare it at the beginning of your script: If you declare the variable at the beginning, then every use of that variable name will refer to the global variable, but only within the script or handler where the declaration appears. To use it in another script or handler, you'll have to declare it again there.
Keep in mind that SenseTalk offers both global and universal variables, which are distinct from each other. Universal variables are declared and used in exactly the same way as global variables. You can use either or both in your scripts. The difference between them in Eggplant is that universal variables retain their values between script runs (until you quit Egglant), while global variables are cleared at the end of every script run.
I'm unable to access the universal variables that i have decalred in mhy scripts.
Scenario is:
In my Testsuite I have 3 scripts (script1, script2, script3). Script3 uses script1 and Script 2 (with help of Start Using ).
Script 2 has function setUniversalVariables where i set my universal variables(univar1,univar2) with initial values. and in the course of script 2 these values get modified.
Now, when I access these Universal variables for ex: TypeText UniVar1
instead of displaying values of UniVar1 it just displays text Univar1.
Please advise on how do I access the Universal variables declared.
Thx in advance.
-Veena
Hi Veena instead of "Typetext UniVar1" try "Typetext Universal UniVar1"
this should work.
and another thing (that burned me initially) is if you have a handler declared later in the script file, you need to declare your globals and universals inside them as well.
Try something like this..
Universal abc (**Declare the variable abc as Universal**)
put "veena" into abc (**Putting a value into the Universal Variable abc**)
now if you type
put abc //this will type "abc".
so if you type
put universal abc //this will type "Veena"
One more thing is that you need to run the Script where you have declared the Universal Variables the first time you start Eggplant else the Value will not be set.
Hope this helps.. I may be wrong but this is how i am using the universal variables in my scripts.
Local and universal (and global) variables are distinct from each other, so if you don't explicitly declare variable 'abc' as global or universal you can actually have three different 'abc' variables in a handler: 'abc' (the local variable), 'global abc', and 'universal abc', each with their own values.
As harshakm said,I access universal variables sucessfully.Just add a statement before I refer to the universal variables :
run "universal_variables_script"
"universal_variables_script" is the script in which I declared the variables.