readString
readBytes
readString reads a character string from the receive buffer.
readBytes reads an array of bytes.
Not available at design time.
Only available with Comm64. Not available with MSComm32 (See remarks below)
 |
| |
Syntax |
result = object.readString(value) |
| |
|
result = object.readBytes(value)
|
| |
object |
Name of the communications control. |
| |
value |
A numerical expression indicating the number of characters or bytes to read from the receive buffer
|
| |
|
|
| |
|
|
| |
Example. |
|
| |
|
Dim s as String
s =
object.readString(10)
|
'// Read a string of 10 chars |
| |
|
Dim b( ) as Byte
b = object.readBytes(10) |
'// Read an array of bytes.
|
|
 |
Remarks:
If you've used MSComm32 before then you will have used the .Input property. It is the only way that MSComm can receive data.
The Input property used by MSComm works in conjunction with the InputMode property which defines whether data is received as a string or as an array of bytes. The MSComm Input property returns a variant which we've decided not to adopt in our .Net Component. Instead we've added two new functions readString and readBytes.
These are Functions so the syntax can therefore not be the same as that of a property.
The standard Input property is used like this:-
.InputLen = 10
someString = .Input
The readString function is used like this:-
someString = .readString ( 10 )
If RxTimeout is zero then the Input/read functions return immediately with the required number of chars/bytes or less if there were less than the required number waiting in the receive buffer.
If TxTimeout is greater than zero then the Input/Read functions will return immediately if the required number of bytes are already in the receive buffer otherwise it will wait for the required number of bytes until RxTimeout occurs.
Instead of using lareg timeouts, we recomend that you use very small timeouts and repeat the read a number of times until you get the number of bytes you require. |