Asigning Values

You use value assignment to change the content of a variable by assigning the content of another data object to it. This section deals with the statements designed exclusively for value assignments to variables. However, value assignments also appear in other statements, in which the content of a variable is changed.

When assigning the value of a source object (source) to a destination object (destination), you must distinguish between three cases concerning the data type:

  1. source and destination are compatible, i.e. all attributes (data type, length and number of decimal places, composition of the components in structures) match. The content is copied unchanged byte by byte from source to destination.

  2. source and destination are not compatible, but convertible. The content of source is converted according to the

conversion rules and then copied to destination. Two data types are convertible if a conversion rule exists for them. An exception occurs if the content of source cannot be treated according to the conversion rule. An assignment that requires a conversion is always slower than an assignment without conversion.

  1. If the data objects are neither compatible nor convertible, no assignment can take place. If this state is discovered already in the syntax check, a syntax error is displayed; otherwise an exception occurs when the program is executed.

The following statements are designed for value assignments: