Compatible with:
DOS Maximite CMM MM150 MM170 MM+ MMX Picromite ArmiteL4 Armite F4 ArmiteH7 CMM2

OPEN fname$ FOR mode AS [#]fnbr
OPEN comspec$ AS [#]fnbr
OPEN comspec$ AS GPS [,tz_offset] [,monitor]


OPEN fname$ FOR mode AS [#]fnbr
Opens a file for reading or writing. ‘fname’ is the filename with an optional extension separated by a dot (.). Long file names with upper and lower case characters are supported. A directory path can be specified with the forward or backwards slash as a directory separator. The parent of the current directory can be specified by using a directory name of .. (two dots) and the current directory with . (a single dot). For example OPEN "../dir1/dir2/filename.txt" FOR INPUT AS #1 ‘mode’ is INPUT, OUTPUT, APPEND or RANDOM. INPUT will open the file for reading and throw an error if the file does not Colour Maximite 2 User Manual Page 76 exist. OUTPUT will open the file for writing and will automatically overwrite any existing file with the same name. APPEND will also open the file for writing but it will not overwrite an existing file; instead any writes will be appended to the end of the file. If there is no existing file the APPEND mode will act the same as the OUTPUT mode (i.e. the file is created then opened for writing). RANDOM will open the file for both read and write and will allow random access using the SEEK command. When opened the read/write pointer is positioned at the end of the file. ‘fnbr’ is the file number (1 to 10). The # is optional. Up to 10 files can be open simultaneously. The INPUT, LINE INPUT, PRINT, WRITE and CLOSE commands as well as the EOF() and INPUT$() functions all use ‘fnbr’ to identify the file being operated on. See also ON ERROR and MM.ERRNO for error handling.

OPEN comspec$ AS [#]fnbr
Will open a serial communications port for reading and writing. Two ports are available (COM1: and COM2:) and both can be open simultaneously. 
If OPTION CONSOLE SCREEN is used then the console serial port is available as COM3:
Using 'fnbr' the port can be written to and read from using any command or function that uses a file number. 
'comspec$' is the communication specification and is a string (it can be a string variable) specifying the serial port to be opened and optional parameters. 
The default is 9600 baud, 8 data bits, no parity and one stop bit.
It has the form "COMn: baud, buf, int, int-trigger, (DEN or DEP), 7BIT, (ODD or EVEN), INV, OC, S2"
'n' is the serial port number for either COM1:, COM2 or COM3 ...
'baud' is the baud rate. This can be any value between 1200 (the minimum) and 1000000 (1MHz). Default is 9600.
'buf' is the receive buffer size in bytes (default size is 256). The transmit buffer is fixed at 256 bytes.
'int' is a user defined subroutine which will be called when the serial port has received some data. The default is no interrupt.
'int-trigger' sets the trigger condition for calling the interrupt subroutine.
 If it is a normal number the interrupt subroutine will be called when this number of characters has arrived in the receive queue.
All parameters except the serial port name (COMn:) are optional. If any one parameter is left out then all the following parameters must also be left out and the defaults will be used.
These options can be added to the end of 'comspec$'
'INV' specifies that the transmit and receive polarity is inverted.
'OC' will force the transmit pin (and DE on COM1:) to be open collector. The default is normal (0 to 3.3V) output.
 'S2' specifies that two stop bits will be sent following each character transmitted.
'7BIT' will specify that 7 bit transmit and receive is to be used.
'ODD' will specify that an odd parity bit will be appended (8 bits will be transmitted if 7BIT is specified, otherwise 9)
'EVEN' will specify that an even parity bit will be appended (8 bits will be transmitted if 7BIT is specified, otherwise 9)
'DEP' will enable RS485 mode with a positive output on the COM1-DE pin
'DEN' will enable RS485 mode with a negative output on the COM1-DE pin

OPEN comspec$ AS GPS [,tz_offset] [,monitor] (CMM2 and ArmiteH7 only)
Will open a serial communications port for reading from a GPS receiver. See the GPS function for details. 
The sentences interpreted are GPRMC, GNRMC, GPCGA and GNCGA. 
The timezone_offset parameter is used to convert UTC as received from the GPS to the local timezone. 
If omitted the timezone will default to UTC. The timezone_offset can be a any number between -12 and 14 allowing the time to be set correctly even for the Chatham Islands in New Zealand (UTC +12:45). 
If the monitor parameter is set to 1 then all GPS input is directed to the console. 
This can be stopped by closing the GPS channel.



Last edited: 15 December, 2020