To establish input/output (I/O) to a file or device.
OPEN filename [ FOR access_mode ] [ ACCESS network_access ] [ lock_type ] AS [#] file_number [ LEN = record_length ]
OPEN mode, [#] file_number, filename [ , record_length ]
OPEN "COMn: basic_com com_specifics” [ FOR access_mode ] AS [#] file_number [ LEN = record_length ]
filename is a string expression containing the name of the file or device to open.
access_mode specifies how the file is to be used: INPUT, OUTPUT, APPEND, RANDOM or BINARY. The default is RANDOM.
network_access provides more detail on how the file is to be used in shared-file network environments: READ, WRITE or READ WRITE.
lock_type is the type of file locking used in shared-file environments: SHARED, LOCK READ, LOCK WRITE or LOCK READ WRITE.
file_number is the integer number to associate with the file for read, write and close operations.
record_length is the number of bytes in each record. For sequential files, the default is 512; for random-access files, the default is 128; for communications, the default is 128. The value cannot exceed 32,767.
mode is used for older BASIC programs. It is a single-letter string that specifies the access mode:
A AppendB BinaryI InputO OutputR Randomn is the number of the communications port to open, either 1 or 2.
basic_com represents the basic data-communications parameters, separated by commas, in the following form:
[ baud ] [ ,[ parity] [, [ databits ] [ , [ stopbits ]]]]
N (none), E (even), O (odd), S (space), M (mark) or PE (enable error checking).O (odd) or E (even), one bit is used for parity. If parity is set to N (none), no bits are used for parity.com_specifics is a list of data-communications specifics, separated by commas:
ASC opens device in ASCII modeBIN opens device in binary modeCD[ milliseconds ] specifies carrier-detect timeoutCS[ milliseconds ] specifies clear-to-send timeoutDS[ milliseconds ] specifies data-set-ready timeoutLF sends linefeed after each carriage returnOP[ milliseconds ] specifies the OPEN statement timeout periodRB[ bytes ] specifies the size of the receive bufferRS suppresses detection of Request To Send (RTS)TB[ bytes ] specifies the size of the transmit bufferOPEN "TEST.DAT" FOR INPUT AS #1
f% = FREEFILE
OPEN "NEW.DAT" FOR RANDOM AS f% LEN = 80
OPEN "C0M1:4800, E, 7, 1, BIN" AS #2