FORTRAN 77 Language Reference

ENCODE/DECODE

The ENCODE @ statement writes data from a list to memory.

ENCODE(size, f, buf [, IOSTAT=ios] [, ERR=s]) [iolist]

Parameter 

Description 

size

 Number of characters to be translated

f

 Format identifier

buf

 Variable, array, or array element

ios

 I/O status specifier

s

 Error specifier (statement label)

iolist

 List of I/O items, each a character variable, array, or array element

Description

ENCODE is provided for compatibility with older versions of FORTRAN. Similar functionality can be accomplished using internal files with a formatted sequential WRITE statement. ENCODE is not in the FORTRAN 77 Standard.

Data are edited according to the format identifier.

Example


       CHARACTER S*6, T*6 
       INTEGER V(3)*4 
       DATA S / '987654' / 
       DECODE( 6, 1, S ) V 
1      FORMAT( 3 I2 ) 
       ENCODE( 6, 1, T ) V(3), V(2), V(1) 

The DECODE reads the characters of S as 3 integers, and stores them into V(1), V(2), and V(3). The ENCODE statement writes the values V(3), V(2), and V(1), into T as characters; T then contains '547698'.

See "DECODE/ENCODE" for more information and a full example.