ReadBin Statement

Reads binary data from a file or communications port.

Syntax
ReadBin #portNumber, var

ReadBin #portNumber, array(), count

Parameters

portNumber
ID number that specifies the file or communications port. File number can be specified in BOpen statement. Communication port number can be specified in OpenCom (RS-232C) or OpenNet (TCP/IP) statements.
varName
Specify the name of a byte-type, integer-type, or long-type variable that will receive the data byte.
array()
Specify the name of a byte-type, integer-type, or long-type variable that will receive the data byte. Specify a one dimension array variable.
count
Specify the number of bytes to read. The specified count has to be less than or equal to the number of array elements and also smaller than 256 bytes. If the communication port (TCP/IP) is the subject, the count has to be less than or equal to the number of array and also smaller than 1024 bytes.

Notes


  • About the Controllers to use

    For T/VT series, an error will occur at operation when RS-232C port of the Controller is specified.


See Also
Write, WriteBin, Read

ReadBin Statement Example

Integer data
Integer dataArray(10)

numOfChars = ChkCom(1)

If numOfChars > 0 Then
    ReadBin #1, data
EndIf

NumOfChars = ChkCom(1)

If numOfChars > 10 Then
    ReadBin #1, dataArray(), 10
EndIf