Liberty BASIC Help Online

OPEN device FOR purpose AS #handle {LEN = n}
The OPEN command opens communication with a device, which can be a disk file, a window, a dynamic link library or a serial communications port. The command must be told what to open, for what purpose, and a descriptive, unique name or "handle" must be assigned to it so that other functions can access the open device. Handles must always begin with "#" to identify them as such and to distinguish them from other variables. The details for using the OPEN statement are shown below. It will be necessary to refer to the individual topics for complete explanations for using OPEN with the various devices.
Note:  Any device that is opened during the normal operation of the program must be closed before program execution is finished.  See CLOSE  Changing the handle of a device dynamically at runtime can be accomplished with the MAPHANDLE command.
The device to be opened may be one of the following:
If the device to be opened is a file, the device parameter must be a valid disk filename.  This may be expressed as a string variable, or as a literal text expression enclosed in quotes. For more on coding file specifications, see Path and Filename.
Files may be opened for the purpose of INPUT, OUTPUT, APPEND, RANDOM or BINARY access. The final {LEN=n} parameter applies to files opened for RANDOM access. For more on opening files, please see File Operations.
open "c:\readme.txt" for input as #f
If the device to be opened is a window, the device parameter will become the caption of the window.  The caption is the text contained on the titlebar of the window.
When the device is a window, the purpose parameter is the window type.  There are many possibilities for window types and these are explained in: Window TypesWindow and Dialog Commands, Graphical User Interface.
open "My Cool Program" for window_nf as #main
dynamic link library
A DLL (dynamic link library) must be opened before any calls can be made to the functions. If the device is a DLL the device parameter will be the disk filename of the DLL, enclosed in quotes.  See CALLDLL.
The purpose is always "for DLL" when using OPEN with a dynamic link library. 
open "c:\myprog\sample.dll" for DLL as #sample
or for Windows API calls:
open "user32" for DLL as #user32
serial communications port
The OPEN  statement opens a serial communications port for reading and writing.  The device parameter is the name of the port enclosed in quotes.  The syntax looks like this:
OPEN "COMn:baud,parity,data stop{,options}" for random as #handle
The purpose is always "for random" when using OPEN to open a communications port.  See " Open "Comn..."
To open com port 2 at 9600 baud, 8 data bits, 1 stop bit, and no parity, use this line of code:
open "com2:9600,n,8,1" for random as #commHandle
The #handle is a unique name given to the