modula-2 home

  Win32 API  



The assignment serves to replace the current value of a variable by a new value indicated by an expression. The assignment operator is written as ": =" and pronounced as "becomes".

   assignment = designator": =" expression.

The designator to the left of the assignment operator denotes a variable. After an assignment is executed, the variable has the value obtained by evaluating the expression.

The old value is lost (overwritten). The type of the variable must be assignment compatible with the type of the expression. Operand types are said to be assigrunent compatible, if either they are compatible or both are INTEGER or CARDINAL or subranges with base types INTEGER or CARDINAL.

A string of length n1 can be assigned to a string variable of length n2 > n1. In this case, the string value is extended with a null character (OC). A string of length 1 is compatible with the type CHAR.

Examples of assignments:

   i := k
   p := i=j
   j := log2(i + j)
   F := log2
   s := {2,3,5,7,1l,13}
   a[i] : = (i + j) * (i-j)
   t1^.key:= i
   w[i+l].ch:= "A"


  • Wirth N: Programming in Modula-2, 3rd ed. Springer Verlag, Berlin, 1985.