Note: You must add uk to the end of the address, it's to help prevent spam. |
OPEN TYPE: I/O Statement Action: This statement OPENs a channel for input and/or output to a peripheral device. However, you may NOT need all those parts for every OPEN statement. Some OPEN statements require only 2 codes:
The <file-num> is the logical file number, which relates the OPEN, CLOSE, CMD, GET#, INPUT#, and PRINT# statements to each other and associates them with the file-name and the piece of equipment being used. The logical file number can range from 1 to 255 and you can assign it any number you want in that range. NOTE: File numbers over 128 were really designed for other uses so it's good practice to use only numbers below 127 for file numbers. Each peripheral device (printer, disk drive, cassette) in the system has its own number which it answers to. The <device> number is used with OPEN to specify on which device the data file exists. Peripherals like cassette decks, disk drives or printers also answer to several secondary addresses. Think of these as codes which tell each device what operation to perform. The device logical file number is used with every GET#, INPUT#, and PRINT#. If the <device> number is left out the computer will automatically assume that you want your information to be sent to and received from the Datassette(TM), which is device number 1. The file-name can also be left out, but later on in your program, you can NOT call the file by name if you have not already given it one. When you are storing files on cassette tape, the computer will assume that the secondary <address> is zero (0) if you omit the secondary address (a READ operation). A secondary address value of one (1) OPENs cassette tape files for writing. A secondary address value of two (2) causes an end-of-tape marker to be written when the file is later closed. The end-of-tape marker prevents accidentally reading past the end of data which results in the BASIC error message ?DEVICE NOT PRESENT. For disk files, the secondary addresses 2 thru 14 are available
for data-files, but other numbers have special meanings in DOS
commands. You must use a secondary address when using your disk
drive(s). (See your disk drive manual for DOS command details.) Sequential files are OPENed for reading <mode>=R unless you specify that files should be OPENed for writing <mode> =W is specified. A file <type> can be used to OPEN an existing Relative file. Use REL for <type> with Relative files. Relative and Sequential files are for disk only. If you try to access a file before it is OPENed the BASIC error message ?FILE NOT OPEN will occur. If you try to OPEN a file for reading which does not exist the BASIC error message ?FILE NOT FOUND will occur. If a file is OPENed to disk for writing and the file-name already exists, the DOS error message FILE EXISTS occurs. There is no check of this type available for tape files, so be sure that the tape is properly positioned or you might accidentally write over some data that had previously been SAVED. If a file is OPENed that is already OPEN, the BASIC error message FILE OPEN occurs. (See Printer Manual for further details.) EXAMPLES of OPEN Statements:
|