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 Comm32. 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.
NOTE. Always use a dynamic array. No
need to size/initialize or ReDim the array |
|
 |
Remarks:
Using these functions you do not need to pre set the InputMode property.
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:-
.InputMode = InputModeText
.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 RxTimeout 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 large 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. |