About Variables
TestComposer enables you to define variables that you can then use as step parameters, step return values, procedure arguments, or for creating Tcl expressions.
The For step, for example, uses a loop variable initialized to a start value and loops over a values domain for executing the nested steps a predefined or variable number of times. Considering another example, some steps of the Execute type which return a result can be assigned a return variable that is then used for retrieving the step output.
Variable Scope
Variables can be created and used both in the main script body and in within the procedures that are defined in a TestComposer script.
Depending on their scope, variables fall into the two categories below:
- Local: These variables, which are defined in the main body of a script or in the body of procedures, have a limited scope and cannot be accessed outside that scope. For example, a variable that was defined in the main script body cannot be used inside a procedure.
Variables defined in the Files Catalog are considered to have a local scope that is attached to the main script body and, as such, cannot be accessed from the body of procedures.
- Global: These variables are defined at any location of the script using a ReadWriteGlobal statement and are used only for facilitating the transfer of variable values between the main body and the procedure bodies.
When defined within a procedure resource, a global variable is visible in all TestComposer scripts that reference the shared procedure. Similarly, when defined in the main body of a script, global variables can still be accessed from within any inline procedure that is contained in that script.
Opposed to local variables, global variables cannot be used as parameters or building blocks for Tcl expressions.
Variable Types
With regard to their type, TestComposer supports the following variable types:
- Simple variables: These are simple variables, such as scalars (boolean, integer), strings, and lists, that have a Tcl representation and are directly accessed in Tcl expressions using a $ reference.
Simple variables are used in Tcl expressions, such as those encountered in Assign and TclEval steps, or in conditional expressions associated to flow control steps.
- Composite variables: This structured variable type does not have a Tcl representation and represents, for example, the result of some predefined Execute-type steps or Response Templates targets.
Composite variables may contain multiple elements of different types, such as statistics groups, scalars, and statistics lists. Fields within a composite variable are referenced using the $-prefixed variable name and the . (dot) operator.
Given the sample composite variable that is shown in Figure:Sample Composite Variable, specific fields are referenced for example using the x.Measured_interval_ms or x.Data_rate_limit expressions.
Figure:Sample Composite Variable
Both simple and composite variables can be passed as arguments to procedures. When used as procedure arguments, simple variables can be initialized to default values, whereas composite variables cannot.
Composite variables are shown highlighted in blue in the Test Steps table.
Variables Creation Statements
Local variables can be created using Assign statements both in the main body of a script and in the body of procedures.
Global variables can be created anywhere in the script using ReadWriteGlobal statements and serve the purpose of transferring the values of local variables between the main body of a script and the procedure bodies. See ReadWriteGlobal Statement Step.
IxLoad TestComposer │ User Guide |