Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
OPEN COM Statement
◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Opens and initializes a communications channel for input or output (I/O).
The OPEN COM statement must be executed before a device can be used for
communication using an RS232 interface.
OPEN "COMn: optlist1 optlist2" [FOR mode] AS [#]filenum% [LEN=reclen%]
■ n The communications port to open (1 = COM1, 2 = COM2).
■ optlist1 The most-often-used communications parameters:
[baud] [,[parity] [,[data] [,[stop]]]]
baud is the baud rate of the device to be opened:
75, 110, 150, 300, 600, 1200, 2400, 4800, 9600
parity is the method of parity checking:
N (none) E (even) O (odd)
S (space) M (mark) PE (enable error checking)
data is the number of data bits per byte:
5, 6, 7, 8
stop is the number of stop bits:
1, 1.5, 2
Defaults: 300 baud, even parity, 7 data bits, 1 stop bit.
■ optlist2 A list of less-often-used parameters, separated by commas:
Option Description
══════ ══════════════════════════════════════════════════
ASC Opens the device in ASCII mode.
BIN Opens the device in binary mode.
CD[m] Sets the timeout period (in milliseconds) on the
Data Carrier Detect (DCD) line.
CS[m] Sets the timeout period (in milliseconds) on the
Clear to Send (CTS) line.
DS[m] Sets the timeout period (in milliseconds) on the
Data Set Ready (DS) line.
LF Sends a line-feed character after a carriage
return.
OP[m] Specifies how long (in milliseconds) OPEN COM
waits for all communications lines to become open.
RB[n] Sets the size (in bytes) of the receive buffer.
RS Suppresses detection of Request to Send (RTS).
TB[n] Sets the size (in bytes) of the transmit buffer.
■ mode INPUT, OUTPUT, or RANDOM (the default).
See ◄OPEN Statement File Modes►.
■ filenum% A number in the range 1 through 255 that identifies the
communications channel as long as it is open.
■ reclen% Random-access-mode buffer size (default is 128 bytes).
Example:
'Use this example for trouble shooting serial communications problems.
'Slow baud, hardware handshaking is ignored and buffers are enlarged.
OPEN "COM1:300,N,8,1,CD0,CS0,DS0,OP0,RS,TB2048,RB2048" FOR RANDOM AS #1
See Also ◄OPEN►