LINEINPUT (Statement)


Reads data received at an RS232C or Ethernet port preceding a delimiter, and stores (assigns) it to a character string variable.


LINEINPUT [#<line number>,]<string variablename> [,WTIME=<timeout>[,RVAL=<restore variable>]]


Stores all the characters preceding a delimiter (CR or CR + LF) in the data which has been received at the RS232C or Ethernet port into the variable specified by <string variablename>. The delimiter itself will not be stored into the specified variable.
In <line number>, specify the line number of the RS232C or Ethernet port being used. If you omit the <line number> assignment, the default value of "ch2" will be assumed. You cannot specify "ch1" since it is reserved for a teach pendant. (See Section 2.4.1 "Circuit Number.")
In <string variablename>, specify the name of a character string variable.
<timeout> Version 2.2 or later
If no delimiter is received within the specified period of time, the processing of the LINEINPUT statement will terminate and control will be transferred to the next command. The timeout period should be specified in ms (milliseconds). In practice, however, the actual wait time is incremented every 1/60 of a second.
<restore variable> Version 2.2 or later
This parameter is used in conjunction with <timeout>. If the processing of a variable is normally completed by data received, then TRUE (1) will be stored into the specified restore variable; if it terminates as a result of a timeout, FALSE (0) will be stored.


DEFSTR 1s1,1s2,1s3,1s4
DEFINT 1i
LINEINPUT #0, 1s1
'Receive character string from port 1 and assign it to 1s1.
LINEINPUT #1, 1s2
'Receive character string from port 2 and assign it to 1S2.
LINEINPUT 1s3
'Receive character string from port 2 and assign it to 1S3.
LINEINPUT#1, 1s4,WTIME=100,RVAL=1i
'If no data exists preceding a delimiter, transfer control
'to the next command after the timeout of 100 ms.
'Set "0" into 1i, indicating that the processing
'has terminated because of timeout.


Top