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

READ

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Glossary

 » Index

Transfers a record of data from the file $STDIN to the data area.

Syntax

     I16             CA        I16V
transfercount:=READ(message,expectedlength);

Use

The READ intrinsic reads an ASCII string from $STDIN into an array.

This is similar to calling the FREAD intrinsic against the file $STDIN. READ is intended as a quick method of obtaining input from the terminal for temporary programming. Read timers or timeouts must be set prior to calling READ by first calling FCONTROL using the appropriate controlcode values.

When you use the READ intrinsic, the full capabilities of the file system are not available to you. For example, since no file number can be specified in the call it is not possible to use the :FILE command to redirect input for programs using READ. (The only way that input can be redirected is to use the $STDIN=filename option of the :RUN command.) Input always comes from the $STDIN file opened by the session at logon time.

READ differs from READX in how it interprets an end-of-file. READ reads a record and, if there is a colon in the first column, end-of-file is set.

Functional Return

transfercount

16-bit signed integer (assigned functional return)

The length of the ASCII string that was read. If expectedlength is positive, the count represents halfwords. If expectedlength is negative, the count represents bytes.

Parameters

message

character array (required)

Returns the ASCII characters that were read. Note that all character arrays must start on a halfword boundary.

expectedlength

16-bit signed integer by value (required)

The maximum length of the message array. If expectedlength is positive, it specifies the length in halfwords. If expectedlength is negative, it specifies the length in bytes. When the record is read, the first expectedlength characters are input. If the number of bytes input exceeds this value, the read terminates on byte count.

Condition Codes

CCE

Request granted.

CCG

A record with a colon in the first column, signaling the end-of-data or a hardware end-of-file, was encountered.

CCL

Request denied. A physical input/output error occurred. Further analysis through the FCHECK intrinsic is not possible.

Additional Discussion

See the discussion of reading ASCII strings from $STDIN into an array in Accessing Files Programmer's Guide.

Feedback to webmaster