ASSIGN command

Used to create variables and assign values to variables.


<ASSIGN> variable_name = value <IF test>


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.


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 test

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


If you want a variable to be permanently saved with an ACL project, preface the variable name with an underscore – for example, _variable_name. Variables with names that are not prefaced with an underscore are retained for the duration of the current ACL session only. Do not use non-English characters, such as é, in the names of variables. Variable names that contain non-English characters will cause scripts to fail.

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.


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) 2015 ACL Services Ltd. All Rights Reserved.