New QL ‘Open’

See all articles from SMUG Bytes v7 n7
Author(s): Bill Heberlein
Publication: SMUG Bytes
Pub Details: SMUG Bytes v7 n7 (Volume 7, Issue 7)
Date: July 1990
Pages: 6-7

In writting a program for the QL I found a new, at least to me, open. The command will allow you to open for the creation of a new file without name error checking. In other words if the name is there it will overwrite the current name file’s data with the new data. This can be important in the case of a backup where the new file and the old are the same name but you don’t want the program to stop on a duplicate file name.

This instruction is from toolkit II and to use it you must have it.

This instruction joins the other opens and they are OPEN #x, OPEN_IN #x, and OPEN_NEW #x. There is one other and it is OPEN_DIR. It is used to find an unused channel.

Try’m you’ll like them.

OPEN COMMANDS

The following are some examples of the open commands. I hope they help. I have’t included the OPEN_DIR as I have never used it but I will try it for next month.

The OPEN #x command.

   OPEN #12,con_236x22a20x15

This command will open a section of the screen so when channel 12 is written to that area will display it.

The OPEN_OVER #x command.

   OPEN_OVER #7,flp1_reservations_bac

This command will open the file for update. One difference is this command will not stop if the file name already exists so beware if you use if.

The OPEN_NEW #x command.

   OPEN_OVER #7,flp1_reservation

This command will open a new file with an error check to see if the file does exsist. If it does then halt.

The OPEN_IN #x command.

   OPEN_IN #7,'reservation'

This command will open an existing file for update only. You can read each record but can’t write.

A couple of other things with the open is the different things you can do with the command. The OPEN command can open a file, a channel or a device. The prior illustration opens a window on the screen. If you wish to open a file use OPEN #7,flp1’reservation’. If a device, such as the printer is wanted use OPEN #3,ser. This will open channel 3 as a serial port.

If you use the OPEN to the con or scr remember you still must define a the window also. To read a file use the INPUT command. INPUT #7,aaaa$ where aaa$ is a storage area. To write use the PRINT command. PRINT #7,aaaa$ again aaaa$ is a storage area.