The ENCODE and DECODE statements transfer data between variables or
arrays in internal storage. The ENCODE statement translates data
from internal (binary) form to character form. Inversely, the
DECODE statement translates data from character to internal form.
These statements are comparable to using internal files in
formatted sequential WRITE and READ statements, respectively.
Statement format:
ENCODE (c,f,b [,IOSTAT=ios] [,ERR=s]) [list]
DECODE (c,f,b [,IOSTAT=ios] [,ERR=s]) [list]
c Is an integer expression. In the ENCODE statement,
"c" is the number of characters (in bytes) to be
translated to character form. In the DECODE statement,
"c" is the number of characters to be translated to
internal form.
f Is a format identifier. An error occurs if more than
one record is specified.
b Is a scalar or array reference. If b is an array
reference, its elements are processed in the
order of subscript progression. The data type of "b"
determines the number of characters that ENCODE or
DECODE can process.
In the ENCODE statement, "b" receives the characters
after translation to external form. If less than "c"
characters are received, the remaining character
positions are filled with blank characters.
In the DECODE statement, "b" contains the characters
to be translated to internal form.
ios Is a scalar integer variable that is defined
as a positive integer if an error occurs, and zero
if no error occurs.
s Is the label of an executable statement.
list Is an I/O list.
In the ENCODE statement, the "list" contains the data
to be translated to character form. In the DECODE
statement, the "list" receives the data after
translation to internal form.
The interaction between the format specifier and the
I/O list is the same as for a formatted I/O statement.