Assignment Expressions

LANSA Composer

Assignment Expressions

The assignment expression used in the ASSIGN directive consists of the following parts:

Left Operand

The name of a variable or built-in variable that receives the value specified by the right operand.

To specify a variable, precede the variable name with an ampersand (&) – for example &VARIABLE1.  To specify an indexed variable, specify a variable or numeric literal that specifies the index value in parentheses immediately following the variable name – for example &VARIABLE1(&INDEX1).

Note: The variable specified by the left operand does not have to have been previously defined in the variable pool. If it does not exist, the Assign Processing Directive implicitly defines it.

To specify a built-in variable, enter the name, including the asterisk, as shown on the Built-ins tab – do not precede a built-in variable name with ampersand. Note only certain built-in variables are valid as the target of an assignment expression. Refer to 3.1.3 Built-in Variables for information.

Operator

An assignment operator used to assign a value to the variable specified by the left operand. It may be one of the following:

=  assigns the value of the right operand to the variable specified by the left operand

+= adds the numeric value of the right operand to the numeric value of the variable specified by the left operand

-= subtracts the numeric value of the right operand from the numeric value of the variable specified by the left operand

When += or -= assignment operators are used the values of the left and right operands are evaluated as numeric if possible.  If either operand does not contain a numeric value, then zero is used as the value for that operand.

Right Operand

The value that is assigned to the variable specified by the left operand. The value can be specified in one of two ways:

1. A numeric or alphanumeric literal value. If you enter an alphanumeric literal value you must surround it with quote marks. The quote marks do not become part of the value that is assigned. If you need to embed quote marks in the value, you double-up the embedded quote marks.

2. The name of a variable or built-in variable that supplies the value for the assignment. To specify a variable, precede the variable name with an ampersand (&) – for example &VARIABLE1. To specify a built-in variable, enter the name, including the asterisk, as shown on the Built-ins tab – do not precede a built-in variable name with ampersand. To specify an indexed variable, specify a variable or numeric literal that specifies the index value in parentheses immediately following the variable name – for example &VARIABLE1(&INDEX1).

 

Examples

This expression assigns the numeric value 3 to the variable named MYNUMBER:

&MYNUMBER = 3

This expression adds 1 to the numeric value of the variable named MYNUMBER:

&MYNUMBER += 1

This expression adds the numeric value of the variable named OTHERNUMBER to the numeric value of the variable named MYNUMBER:

&MYNUMBER += &OTHERNUMBER

This expression assigns the alphanumeric value ABC to the variable named MYSTRING:

&MYSTRING = 'ABC'

These three assignment expressions populate the first three instances of the MYLIST variable list with the first three letters of the alphabet:

&MYLIST(1) = 'A'

&MYLIST(2) = 'B'

&MYLIST(3) = 'C'

This expression assigns the value of the third instance of the MYLIST variable list to the MYLETTER variable:

&MYLETTER = &MYLIST(3)

This expression is similar but the MYINDEX variable specifies which instance of the MYLIST variable list to use:

&MYLETTER = &MYLIST(&MYINDEX)

This expression assigns trading partner identifier ATLAS to the *TRADINGPARTNER built-in variable:

*TRADINGPARTNER = 'ATLAS'

This expression assigns the identifier of the FTP Inbound Configuration linked to the current trading partner to the variable MYFTPCONFIG:

&MYFTPCONFIG = *TRADINGPARTNER.FTPIN