READVU Statement

Locks a file item, then reads an attribute value from the item and assigns its string value to a specified variable.

Syntax

READVU variable FROM {file-var,}item-id, attr# {SETTING setting-var} {LOCKED statement(s)} [THEN statement(s) | ELSE statement(s)]

Syntax Elements

variable The name of a variable to which the value of the attribute is assigned.

file-var The name of a variable containing a file reference (assigned via an OPEN statement). If file-var is not specified, the internal default file variable is used; that is, the file used is that most recently opened without a file variable.

item-id The name of the item from which the data is to be read.

attr# The number of the attribute to be read.

If attr# is 0, READVU checks that the specified item exists and executes the THEN or ELSE clause as appropriate. variable is returned unchanged.

setting-var The name of a variable that is set to a return value. If the data is read successfully, setting-var is set to 0 and the THEN clause is executed. If an error occurs, setting-var is set to the appropriate error code and the ELSE clause is executed. The error codes and corresponding messages are given in File I/O and IPC Error Codes).

If the item is locked, setting-var is returned unchanged.

statement(s) A sequence of one or more valid DataBasic statements, either separated by semicolons or contained on separate lines and followed by an END statement.

A THEN or an ELSE clause, or both, must be included.

Operation

READVU works the same way as the READV statement, except that it locks the item to be read. This prevents an item from being simultaneously updated by two or more processes.

MultiValue Compatibility

If you call the STATUS function immediately after a READVU statement, if a LOCKED clause was specified and has been executed STATUS returns the port number of the process that has locked the item; otherwise STATUS returns zero.

Example

READVU ATTR FROM B, "RECORD", 6 LOCKED PRINT "UNABLE TO ACCESS"
ELSE STOP

Locks item RECORD in file B. Reads attribute 6 of RECORD to variable ATTR or, if RECORD does not exist, an error message is displayed and the program terminates.

Go to top button