Checking if bytes are available on a sequential file, socket or pipe

check #

Check if bytes are available on a sequential file, socket or pipe


SYNTAX

check #channel [ni = label] [err = label] [traps = label]

Check if bytes are available on the sequential file, socket or pipe open on the channel number specified.

channel

An integer in the range 1-64 specifying the number of the channel on which the sequential file, socket or pipe (opened by the open # command) is open. It may be a constant, field name or expression.

[ni = label]

This clause traps the condition where no bytes are available, passing control to the line indicated by label.

[err = label]

If an error occurs, the error number is stored in the system variable sys.Error, and control passes to the line indicated by the label specified in the err clause. The error numbers are defined by manifest constants in the file $SCULPTOR/include/errors.h.

[traps = label]

General purpose trap clause that traps any condition not explicitly trapped, passing control to the line indicated by label. It has the lowest priority, and is only invoked if a trappable condition has not been more explicitly trapped.

The number of available bytes is stored in the Sculptor system variable sys.AvailableBytes. If none are available then this variable is set to zero. If the socket has been closed at the other end it is set to -1. In all cases, execution then continues with the next statement.


EXAMPLE

open #2, seqfile read traps = OPENTRAP
check #2 traps = CHECKTRAP

RELATED TOPICS

Sequential files

open #

get[field] #

sys.AvailableBytes