INPUT
(Statement)
Gets data from an RS-232C or Ethernet port.
INPUT [#<line number>,]<variablename>[,WTIME=<timeout>
[,RVAL=<restore variable>]][<variablename>[,WTIME=<timeout> [,RVAL=<restore variable>]]...]
This statement stores the data that has been received at the RS232C or Ethernet port into the variable specified by <variablename>.
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.")
To store more than one piece of data into the same number of variables, insert a comma (,) between each adjacent pair of the data.
All the information preceding a delimiter (CR or CR + LF) will be stored into the specified variable. The delimiter itself will not be stored into the specified variable.
The baud rate needs to be specified using a system parameter.
<timeout> Version 2.2 or later
You can specify a timeout period for each variable. If no input data is found for any variable, the system will wait for the timeout period specified for this variable, and after that, it will pass control 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.
-
Be sure to issue a FLUSH command before receiving data in order to clear the input buffer for incoming data.
-
If the received data exceeds the maximum value that can be expressed by the variable type of the target variable, then this maximum value will be stored into the variable.
Example 1
DIM 1i1 As Integer
|
|
defint 1i
|
|
DEFSTR 1s1, 1s2, 1s3, 1s4
|
|
INPUT #1, 1s1
|
'Write data from ch2 into 1s1.
|
INPUT #1, 1i1, 1s2, 1s3
|
'Write data from ch2 into '1i1, 1s2, and 1s3.
|
INPUT 1s4
|
'Write data from ch2 into 1s4.
|
INPUT 1s4, WTIME=100, RVAL=1i
|
|
|
'If there is no input data, transfer control
'to the next command after the timeout of
'100 ms. Store "0" into 1i, indicating that
'the processing has terminated because of
'timeout.
|
In examples 2 and 3 below, character strings are delimited by commas (,) and the number of those comma-delimited strings is the same as that of variables (elements), so no extra string calculation is required.
Example 2
Input "505.425, -125.325, 400.238" from external equipment (6-axis robot)
|
|
|
|
DIM lv1 AS VECTOR
|
|
INPUT #1, lv1
|
|
LETP P11=lv1
|
'Assign received x, y and z to P11.
|
LETR P11=RVEC(P10)
|
'Assign P10 value to posture data.
|
LETF P11=FIG(P10)
|
'Assign P10 value to figure data.
|
MOVE P, @E P11, S=100
|
|
Example 3
Input "505.425, -125.325, 400.238, 180, 0, 180, 5" from external equipment (6-axis robot)
|
|
|
|
INPUT #1, P11
|
|
MOVE P, @E P11, S=100
|
|