Checking the status of a data file record buffer

check

Check the status of a data file record buffer


SYNTAX

check record_id [nrs = label] [traps = label]


Selection and de-selection of records

Checks that the file to which the record buffer record_id is attached is open and that the buffer contains a record.

If the file is open for update, then check ascertains that the record in the buffer is locked. For this to occur, a record must have been read from the file, and must still remain there, available for update. A record that has been read into the buffer and locked is said to be selected.

If the file is open in read only mode, the command merely checks that a record has been read into the buffer and that the buffer has not been cleared.

If a record is available, control passes to the next statement.

If no record is available, the No record selected condition is generated. See [nrs = label] below,

record_id

The record buffer to be checked.

At present, the selected record may be in any buffer attached to the file, not necessarily the one specified. This may change in the future. The programmer should therefore always check the correct buffer - the one that should contain the record.

[nrs = label]

Traps the condition where check finds no record available.

If this condition is not trapped, the error No record selected is displayed and control passes to the active menu, if any. If no menu is active the program exits.

In a !report section, an untrapped nrs condition is ignored.

[traps = label]

General purpose trap clause that traps any condition not explicitly trapped, passing control to the line indicated by label. It has the lowest priority, and is only invoked if a trappable condition has not been more explicitly trapped.


Selection and de-selection of records

A record is selected by successfully performing a read, find, next, prev or match on the file, which must be open in update mode. It will subsequently be deselected if any of the following events occurs:

1

A clear command with no arguments, or clear record_id that explicitly clears the record buffer.

2

A write command on the file. Writing a record back deselects it.

3

A delete command on the file.

4

A successful writelock or readlock on the file by the current program.

5

An unlock command on the file. The record remains in the buffer but cannot be written back.

6

A read, find, next, prev or match which attempts to read another record into the same buffer, whether successful or not.

7

The file is closed. If it is subsequently opened the buffer contents remain the same, but the record is deselected.


EXAMPLE

!function DeleteRec() {
     tmp.InfoText = "No record currently selected"
     check Invoices nrs = DR_INFO
     tmp.InfoText = "Deletion failed"
     delete Invoices traps = DR_INFO
     tmp.InfoText = "Record deleted"

DR_INFO:
     info tmp.InfoText
     return
}

RELATED TOPICS

clear

delete

readlock

unlock

write

writelock

Traps