Variable assignments in scripts

You can assign values to a variable that is to be used by another statement or used as a counter. A variable might need a specific value before a statement can be successfully executed, or you might need to assign the value of one variable to another variable. A variable can be no longer than 256 bytes.

In the case of arithmetic operations, an EX_MATH_ERROR exception definition script may be generated upon occurrence of the following error conditions:

By default, the script is abnormally terminated. To handle a failed assignment involving an arithmetic operation in a different way, you need to write an exception handler, as described in EXCEPTION.

The permissible range of any result is:
-le15 < result < -le15
Any result outside of this range will stop the script and generate error number 24507. For more information on errors, see the Blueworx Voice Response for AIX: Problem Determination.

Syntax


This picture shows the syntax for assigning a value to a variable that is to be used by another statement or used as a counter.
Note: Complex arithmetic operations are not supported. Only simple operations (add (+), subtract (-), multiply (*), and divide (/)) are permitted. The operands can be variables, constants, or a combination of the two.

For example, the following statement is not valid:

variable = 5 * ( 10 + 40 );

The following statements are valid and produce the same results:

temp_variable = 10 + 40 variable = 5 * temp_variable;

Examples

a = b;
password = "Hello";
result = 10 + 40;
answer = 5 * temp_x;
screen_name = QUERY_SCREEN; 
Note: You can concatenate strings and variables using the following format:
result = “some” ‸ “thing”; 

Procedure

To use the 3270 Script window’s Statements menu to assign a value to a variable, follow this procedure:

  1. From the Welcome window, click on Applications —> 3270 Servers
  2. Selecting the Assignment : Click Statements —> Assignment.

    The system displays the Assignment Definition window.

  3. Specifying the result : Type the name of the result variable next to Result, or click Result to select the variable.
  4. Specifying an Assign assignment : To specify a direct assignment of a variable or a concatenation operation to the Result variable:
    • Make sure that the pushbutton next to Assignment Type displays Assign.
    • Type either the name of the variable or the concatenation operation (for example, B>C) in the Value field, or click Value to display the Term Definition window to select the variable.
  5. Specifying an Arithmetic assignment : To specify an assignment from a specified arithmetic operation to the Result variable:
    • Click the pushbutton next to Assignment Type and select Arithmetic.
    • Type the name of the left operand variable in the Left Operand field, or click Left Operand to display the Term Definition window to select the operand.
    • Click the pushbutton next to Operator to select the required operator (Add, Subtract, Multiply, Divide).
    • Type the name of the right operand variable in the Right Operand field, or click Right Operand to display the Term Definition window to select the operand.
  6. Specifying a QUERY_ SCREEN assignment : To assign the name of the current 3270 screen to the Result variable:
    • Click the pushbutton next to Assignment Type and then Query Screen.
    • Refer to QUERY_SCREEN.
  7. Adding the statement : Click OK.

    The assignment statement is added to the script.