HPlogo Asynchronous Serial Communications Programmer's Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 8 Intrinsics Reference

FREAD

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Glossary

 » Index

Transfers a record of data from an input device to the user's data area.

Syntax

     I16              16V    UDS   I16V
transfercount:=FREAD(filenum,buffer,length);

Use

Use the FREAD intrinsic to read a logical record from a file to the user's data area. For asynchronous devices, this implies the transfer of data (one record at a time) from an input device, usually a terminal, to the data area. Condition codes are used to indicate completion status and should be checked after each read, whether you are using NOWAIT I/O or normal I/O processing. Read timeouts or timers must be set prior to an FREAD by calls to the appropriate FCONTROL functions.

When the logical end-of-data is encountered during a read, CCG is returned to your process. The end-of-data is indicated by a hardware end-of-file; on $STDIN, by any record beginning with a colon (:); or on $STDINX by :EOD.

Functional Return

transfercount

16-bit signed integer (assigned functional return)

Assumes a value corresponding to the length of the information transferred. If the value specified in the length parameter of the call was a positive number, the value returned in transfercount is positive, and represents a halfword count. If the value specified in the length parameter was negative, the value returned in transfercount represents a byte count.

FREAD always returns a zero if you specified NOWAIT I/O in FOPEN or HPFOPEN. In this case, the actual record length is returned in the length parameter of the IOWAIT or IODONTWAIT intrinsic.

Parameters

filenum

16-bit signed integer by value (required)

The file number of the file to be read.

buffer

user-defined structure (required)

Returns the record that was read. This structure should be large enough to hold all of the information to be transferred.

length

16-bit signed integer by value (required)

The number of halfwords or bytes to be transferred. If this value is positive, it signifies the length in halfwords; if negative, in bytes. A zero indicates that no transfer is to take place.

NOTE: Whether you specify the value of length as halfwords or bytes, the actual physical transfer is done on a byte-by-byte basis for an asynchronous device. If the number of bytes input exceeds the value specified, the read will terminate on byte count.

Condition Codes

CCE

The information was read.

CCG

The logical end-of-data was encountered during reading.

CCL

The information was not read because an error occurred: a terminal read was terminated by a special character or timeout interval, as specified in the FCONTROL intrinsic.

Additional Discussion

See Accessing Files Programmer's Guide. See also discussion of IOWAIT and IODONTWAIT in this manual.

Feedback to webmaster