3.4.1 Assignment

The assignment operation in the AIT language assigns the value of the right operand to the left operand. In assignment, you cannot use any constant as the left operand.

Organization of this subsection
(1) Format
(2) Description
(3) Example of coding

(1) Format

Assignment statement

assignment_expression END_STMT

Assignment expression

identifier assign_operand expression

(2) Description

In assignment, the value of the right operand is stored in the left operand. The left operand must neither be a function nor be a constant.

If the data type of the right operand differs from that of the left operand, type conversion is performed when possible. This type conversion depends on the specified operator, and the type of operator or operand.

The following table lists the results of type conversion in the AIT language. Warning messages and errors for data conversion are displayed upon syntax checks.

Left operandRight operandResultDescription
integerintegerintegerThe value of one integer-type variable is assigned to the other integer-type variable.
integerfloatintegerThe truncated value is assigned to the integer-type variable. A warning message is displayed because the data may become inaccurate.
integerboolintegerThe value true is assigned to the integer-type variable as 1. The value false is assigned to the integer-type variable as 0.
integerstringErrorSince the string type cannot be converted to the integer type, an error message is displayed.
floatintegerfloatThe value of the integer-type variable is assigned to the float-type variable.
floatfloatfloatThe value of one float-type variable is assigned to the other float-type variable.
floatboolfloatThe value true is assigned to the float-type variable as 1. The value false is assigned to the float-type variable as 0.
floatstringErrorSince the string type cannot be converted to the float type, an error message is displayed.
boolintegerboolA non-0 value is assigned to the bool-type variable as true. 0 is assigned to the bool-type variable as false. Since the original data is lost, a warning message is displayed.
boolfloatbool
boolboolboolThe value of one bool-type variable is assigned to the other bool-type variable.
boolstringErrorSince the string type cannot be converted to the bool type, an error message is displayed.
stringintegerErrorSince the integer type cannot be converted to the string type, an error message is displayed.
stringfloatErrorSince the float type cannot be converted to the string type, an error message is displayed.
stringboolErrorSince the bool type cannot be converted to the string type, an error message is displayed.
stringstringstringThe value of one string-type variable is assigned to the other string-type variable

The AIT language supports multi-assignment. The multi-assignment here means assignment of a value to two variables.

(3) Example of coding

MAIN
   {
       a = 10;         // Value 10 is assigned to a.
       a = b = 20;     // Multi-assignment is coded.
                       // Value 20 is assigned to variable b,
                       // then to variable a.
   }