ID : 373
Comm.Input
Function
To receive data by the data communication function.
Syntax
Comm.Input(line number[, timeout[, number of input bytes]])
Guaranteed entry
- Line number
- Designate a line number by integer type.
- Timeout
- Designate a timeout period by integer type data. This is an optional value. This should be waiting according to the default value (parameter designated value) if this is omitted.
- Number of input bytes
- Specify the number of data bytes to receive when the line data type is "Binary" by integer type data. This should be 1 if this is omitted.
Return value
Return the received data.
Description
- Data are received from the designated line.
- In the text mode, text parts where neither headers nor delimiters (signs to delimit texts) are included will be returned.
- Designated values and meanings for timeout are described below. When time-out occurs, an error of Error Level1 occurs. For detailed information, please refer to "Error Processing Routine".
Designated value | Meaning |
---|---|
>= 0 | Waiting for designated time. (Unit ms) |
= -1 | Infinite waiting. |
< -1 , when omitted | Waiting according to the default value (parameter designated value) |
Related Terms
Comm.Open, Comm.Close, Comm.Output, Comm.Clear, Comm.Count, Comm.State, Data Communication, Data Communication in Binary Mode
Attention
A number designated in the number of input bytes will be ignored if data type of line is "text".
Example
'!TITLE "Data Reception by Data Communication Function"
' Receive data by the line number 1
Sub Sample_CommInput
Dim aaa As Variant
Dim bbb As Integer
Dim ccc As Integer
' Open line number 1
Comm.Open 1
' Receive 10 byte data with timeout time 10 seconds by line number 1 and assign it to aaa
aaa = Comm.Input( 1, 10000, 10 )
'Assign the maximum index number of element aaa to bbb
bbb = UBound( aaa )
' To process repeat until ccc reaches bbb
For ccc = 0 To bbb
' Assign received data to I variable
I[ccc] = aaa( ccc )
Next
' Close line number 1
Comm.Close 1
End Sub
ID : 373