95
Makes the script jump to the specified label if an error occurs. The line
ON ERROR OFF
returns Comms to normal error handling.
O
PEN OPEN <filename> FOR [INPUT/OUTPUT/APPEND] AS <handle>
READ <length>,<variable>,<handle>
WRITE <handle>,<string>
EOF <handle>
CLOSE <handle>
Opens files and enables reading from (“input”) and writing to (“output”)
them. When you open a file, you assign it a “handle” (a number from 1 to
9), which you then use to refer to that file. You can have up to 9 files open
at a time. E.g., to write a text string to a file:
OPEN “C:\Files\Connectlog” FOR OUTPUT AS 1
WRITE 1,“Connect failed”
CLOSE 1
opens the file “Connectlog” to write to it, then writes “Connect failed” and
closes it again. You can use OPEN to read information from one file and
write it to another. When reading from a file, use EOF to look for the end
of the file, so that Comms knows when to stop. E.g.
OPEN “C:\sourcefile” FOR INPUT AS 1
OPEN “C:\destination” FOR OUTPUT AS 2
WHILE NOT EOF(1) DO
READ 16,a$,1
WRITE 2,a$
ENDWHILE
CLOSE 1
CLOSE 2
This script opens the two files, then instructs Comms to read 16 characters
into a$ from the first file and write the contents of a$ to the second file.
These instructions are held within a WHILE…DO…ENDWHILE loop,
so they are repeated until the end of the first file is reached.
O
R see AND
OUTPUT see OPEN
QUERY QUERY <string exp>
<string exp>,<variable>
<string exp>,<variable>
ENDQUERY
Prompts the user for information which is then stored as a name. E.g.
QUERY “Enter details”
“Username:” , myname$
“City” , city$
ENDQUERY
creates a dialog where the user can enter information such as “Username”
etc. This information is then stored with the name that follows, e.g.