EPOC   SDK Home Glossary   Previous Next Up

OFFOPENR


Contents


OFF — Switches the EPOC machine off

Usage:      OFF
or      OFF x%

Switches the machine off.

When you switch back on, the statement following the OFF command is executed, for example:

    OFF :PRINT "Hello again"

If you specify an integer, x%, greater than 5, the machine switches off for that number of seconds and then automatically turns back on and continues with the next line of the program. However, during this time the machine may be switched on by an alarm, and of course you can turn it on as usual.

The minimum time to switch off is 5 seconds. EPOC also prevents switch off if there is an absolute timer outstanding and due to go off in less than 5 seconds.

Warning: Be careful how you use this command. If, due to a programming mistake, a program uses OFF in a loop, you may find it impossible to switch the machine back on, and have to reset it.


ONERR — Establishes an error handler

Usage:

    ONERR label::
    ...
    ONERR OFF

or just:

    ONERR label
    ...
    ONERR OFF

ONERR label:: establishes an error handler in a procedure. When an error is raised, the program jumps to the label:: instead of the program stopping and an error message being displayed.

The label may be up to 32 characters long starting with a letter or an underscore. It ends with a double colon (::), although you don’t need to use this in the ONERR statement.

ONERR OFF disables the ONERR command, so that any errors occurring after the ONERR OFF statement no longer jump to the label.

It is advisable to use the command ONERR OFF immediately after the label:: which starts the error handling code.

See Runtime errors — Handling errors reported while running programs for full details.


OPEN — Opens an existing table in a database

Usage: OPEN query$,log,f1,f2,...

Opens an existing table (or a ‘view’ of a table) from an existing database, giving it the logical view name log and handles for the fields f1, f2. log can be any letter in the range A to Z.

query$ specifies the database file, the required table and fields to be selected.

For example:

    OPEN "clients SELECT name, tel FROM phone",D,n$,t$

The database name here is clients and the table name is phone. The field names are enclosed by the keywords SELECT and FROM and their types should correspond with the list of handles (i.e. n$ indicates that the name field is a string).

Replacing the list of field names with * selects all the fields from the table.

query$ is also used to specify an ordered view and if a suitable index has been created, then it will be used. See dBase.opx — Database handling. For example,

    OPEN "people SELECT name,number FROM phoneBook ORDER BY name
             ASC, number DESC",G,n$,num%

would open a view with name fields in ascending alphabetical order and if any names were the same then the number field would be used to order these records in descending numerical order.

If the specification of the database includes embedded spaces, for example in the name of the folder, the name must be enclosed in quotes, so for example the following correctly fails:

    OPEN "c:\folder with spaces\file with spaces",a,name$

whereas the following works:

    OPEN """c:\folder with spaces\file with spaces""",a,name$

See also Database File Handling.

See also CREATE, USE and OPENR.


OPENR — Opens a table as read only in an existing database

Usage: OPEN query$,log,f1,f2,...

This command works exactly like OPEN except that the opened file is read-only. In other words, you cannot APPEND, UPDATE or PUT the records it contains.

This means that you can run two separate programs at the same time, both sharing the same file.

EPOC       SDK Home Glossary   Previous Next Up