QA Wizard Pro includes script and repository variables, which are both used to store information.
Variables can be declared explicitly or implicitly. The variable value can be a text string, expression, or value from an associated datasheet.
Variables can be explicitly declared using the Dim statement. Variables can also be implicitly declared by assigning a value.
Dim sampleA
sampleA = 10
sampleB = 20
PrintLn sampleA
PrintLn sampleB
sampleA = "Hi"
sampleB = "there"
PrintLn sampleA
PrintLn sampleB
The variable type is not explicitly declared. Notice that the variables are initially assigned an integer and later assigned a text string.
Note: Variables do not have a specific type (e.g., integer or string). It is much easier to declare variables implicitly by using the variable name in a script. If you use arrays, you must use the Dim statement to declare variables explicitly.
If you create a variable called by other scripts, the variable name must conform to the following rules:
Variable values are persistent in called scripts. Keep the following in mind:
You generally declare variables and assign values at the same time.
Use the following format to declare a variable and assign a value to it:
VariableName = value
VariableName is the variable name and value is the value to assign to the variable. For example:
x = 5
myUser = "WebUser"
Tip: As you work with a script, you can view a list of variables, functions, and subroutines defined in the script in the Definition field at the top of the Script pane. To go directly to the script line where a variable is defined, select it in the Definition field or right-click a script line that references it and choose Go To Definition. See Finding variable, function, and subroutine definitions in scripts.
Calling script variables from another script
Script variables are defined at the script level. To use a script variable with another script in the same workspace, you must first call that script using the Script.CallScript statement. You do not have to immediately use the variable.
For example, you create a variable named User in the Login script. You want to use the User variable in a new script named TestLogin. First, you call the Login script:
Script.CallScript("Login")
To use the variable, enter the called script name, a period, then the variable name. For example:
PrintLn Login.User
Note: You can also use the GetScriptVariable and SetScriptVariable statements to access another script and work with variables.