Statement: Translates data from character to internal form. It is comparable to using internal files in formatted sequential READ statements.
Syntax
The interaction between the format specifier and the I/O list is the same as for a formatted I/O statement.
Rules and Behavior
The number of characters that the DECODE statement can translate depends on the data type of b. For example, an INTEGER(2) array can contain two characters per element, so that the maximum number of characters is twice the number of elements in that array.
The maximum number of characters a character variable or character array element can contain is the length of the character variable or character array element.
The maximum number of characters a character array can contain is the length of each element multiplied by the number of elements.
Examples
In the following example, the DECODE statement translates the 12 characters in A to integer form (as specified by the FORMAT statement):
DIMENSION K(3)
CHARACTER*12 A,B
DATA A/'123456789012'/
DECODE(12,100,A) K
100 FORMAT(3I4)
ENCODE(12,100,B) K(3), K(2), K(1)
The 12 characters are stored in array K:
K(1) = 1234
K(2) = 5678
K(3) = 9012