QBasic 1.1: OPEN COM Statement

Syntax

OPEN "COMn: optlist1 optlist2" [FOR mode] AS [#]filenum% [LEN=reclen%]

Description / Parameter(s)

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:
 
OptionDescription
ASCOpens the device in ASCII mode.
BINOpens 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.
LFSends 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.
RSSuppresses 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