02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

IOSTAT=integer-variable<br />

out-list<br />

Description<br />

<strong>HP</strong> <strong>Fortran</strong> statements<br />

ENCODE (extension)<br />

specifies the label of the executable statement to which control passes if an<br />

error occurs during statement execution.<br />

returns the I/O status after the statement executes. If the statement<br />

successfully executes, integer-variable is set to zero. If an end-of-file<br />

record is encountered without an error condition, it is set to a negative<br />

integer. If an error occurs, integer-variable is set to a positive integer<br />

that indicates which error occurred.<br />

is a comma-separated list of data items for output. The data items can<br />

include expressions and implied-DO lists (see “Implied-DO loop” on<br />

page 191).<br />

The ENCODE statement is a nonstandard feature of <strong>HP</strong> <strong>Fortran</strong> and is provided for<br />

compatibility with other versions of <strong>Fortran</strong>. The<br />

internal-I/O capabilities of the standard WRITE statement provide similar functionality and<br />

should be used to ensure portability.<br />

The ENCODE statement translates data from its internal (binary) representation into<br />

formatted character data.<br />

Examples<br />

The following example program uses the ENCODE statement to write to an internal file:<br />

PROGRAM encode_example<br />

CHARACTER(LEN=20) :: buf<br />

ENCODE (LEN(buf), '(2X, 3I4, 1X)', buf) 1234, 45, -12<br />

PRINT *, buf<br />

END PROGRAM encode_example<br />

When compiled and executed, this program outputs the following (where b represents a blank<br />

character):<br />

bb1234bb45b-12bbbbb<br />

Related statements<br />

DECODE and WRITE<br />

Related concepts<br />

For related information, see the following:<br />

Chapter 10 305

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!