omron — READ program instruction

READ program instruction 526). Then, additional READ instructions must be executed, until one is complete, in order to obtain the data in the variable list. The IOSTAT function can be used to determine when such a READ is complete. Once a record has been read, it is processed in one of the following two ways: 1. If the var_list parameter is a list of real-valued variables, the record is assumed to contain a list of numbers separated by space characters and/or commas. Each number is converted from text to its internal representation, and its value is stored in the next variable contained in the variable list.

If more values are read than the number of variables specified, the extra values are ignored. If fewer values are read, the remaining variables are set to zero. If data is read that is not a number, an error occurs and program execution stops (or an error reaction occurs). 2. If the var_list parameter is a list of string variables, the entire record is stored in the string variables as follows. The first 128 bytes in the record are copied to the first string variable. If there are more than 128 bytes in the record, the second string variable is filled with the next 128 bytes. This continues until the entire record has been processed or all the string variables have been filled.

If there is not enough data to fill all the string variables, the unused string variables are set to the empty string (""). If there is too much data for the number of string variables specified, an error is reported by the IOSTAT real- valued function. When a READ is performed in variable-length record mode, the strings contain all the characters up to, but not including, the terminating CR and LF, which are discarded. Any error in the specification of this instruction (such as attempting to read from an invalid unit) causes a program error and halts program execution.

However, errors associated with performing the actual read operation (such as end of file or device not ready) do not halt program execution since these errors may occur in the normal operation of a program. These normal errors can be detected by using the IOSTAT function after performing the read. In general, it is good practice always to test whether each read operation completed successfully by testing the value from IOSTAT. When accessing a network device, the record_num parameter allows a server to communicate with multiple clients on a single logical unit.

In this context, the parameter provides a handle number that you can use to identify the client from which the READ data was received. Handles are allocated when a client connects to the server and are deallocated when the client disconnects. In order to determine when the client connection or disconnection is done, you must use the IOSTAT real-valued function after the READ. Refer to the documentation for IOSTAT. The READ instruction with TCP/IP reads data until either the input string is full or the buffer is empty, at which point the instruction returns. READ with TCP/IP does not allow fixed- length records and does not terminate when encountering a delimiter.

eV+Language Reference Guide, v2.x, 18319-000 Rev A Page 426