ASSIGN command

Used to create variables and assign values to variables.

Syntax

<ASSIGN> variable_name = value <IF test>

Parameters

ASSIGN variable_name

Specifies the name of the variable to assign the value to. If the variable does not exist, it is created. If the variable already exists, it is updated with the new value. You can omit the word ASSIGN, because ACL automatically interprets the syntax, variable_name = value as an assignment operation.

value

Specifies the value to assign to the variable. If a new variable is created, the variable type is based on the data type in value. If the variable already exists, the data type of the new value must match the variable type.

IF test

Optional. Specifies a condition that must be met. The value is only assigned to the variable if the condition evaluates to true.

Remarks

Variables are retained for the duration of the current ACL session only.

If you assign a value to a variable that already exists, and the variable is used within a computed field or the assignment is made inside a group, then the value assigned is adjusted to the specifications previously defined for that variable. The length is padded or truncated and the decimals are adjusted if required.

If you assign a value to a variable that already exists, and the variable is not used in a computed field, or is assigned outside a group, then the previous value and its specifications are overwritten.

There are several ACL system variables, such as HEADER and FOOTER. If new values are assigned to either of these variables, they are automatically used as page headers or footers if a header or footer is not otherwise specified, and the new values remain in effect until the variables are deleted or until the end of the current session.

Examples

a. Assigning a value to a variable

The following example assigns the value of the Amount field in the current record to a variable named v_current_amount. Because v_current_amount is a variable, its value will not change unless explicitly changed by another ASSIGN command.

ASSIGN v_current_amount = Amount

b. Conditionally assigning a value to a variable

The optional ASSIGN keyword is omitted.

If the variable v_counter is less than 10, the following example assigns a value of 1 to the variable v_quantity.

If v_counter is greater than or equal to 10, no assignment is made and the value of v_quantity remains unchanged. If v_quantity did not previously exist, it will not be created.

v_quantity = 1 IF v_counter < 10



(C) 2013 ACL Services Ltd. All Rights Reserved. | Send feedback