integer-cast-function = ( BYTE | CHAR | SHORTINT | WORD | INTEGER | LONGWORD | LONGINT ) "(" expression ")" .
If <expression> returns an integer type value, cast (truncate or expand) the expression result to the specified format.
If <expression> returns a floating point value, convert (and truncate) the expression result to the specified format. A truncation warning may occur.
float-cast-function = ( SINGLE | REAL ) "(" expression ")" .
Convert the expression result to the specified float format.
integer-cast-as-array = BYTES "(" variable ")" "[" index-expression "]" .
integer-assign-with-cast = BYTES "(" variable ")" "[" index-expression "]" ":=" expression .
NEW! (V2.1): The BYTES keyword may be used to access any <variable> as an ARRAY[0..SIZEOF(<variable>)-1] OF BYTE. It may be used to cast an assigned variable and to read any variable as an ARRAY as well. For an ARRAY [...] OF BOOLEAN, the number of elements must be a multiple of 8.
VAR
LW: LONGWORD;
W0: WORD;
F0: REAL;
…
W0 := WORD(LW); // avoids truncation warning
F0 := REAL(W0) * 100000; // computes in float format
…
BYTES(LW)[1] := $55; // assigns $55 to bits 8..15 of LW
W0 := BYTES(LW)[2]; // assigns W0 with bits 16..23 of LW