UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software

rocketsoftware.com
from rocketsoftware.com More from this publisher
11.04.2013 Views

Parameters The following table describes each parameter of the syntax. Parameter Description 1-644 UniBasic Commands Reference dyn.array.var Specifies a dynamic array to contain the record. FROM file.var, Specifies the file variable from which to read the record. If you do not specify a file.var, UniData reads from the default file. If no default file is open, a fatal error occurs. The default file is one for which no file variable is assigned in the OPEN statement. record.ID.expr Specifies the record ID to use to retrieve the record. ON ERROR statements Specifies statements to execute if the READU statement fails with a fatal error because the file is not open, an I/O error occurs, or UniData cannot find the file. If you do not specify the ON ERROR clause and a fatal error occurs, the program terminates. LOCKED statements Specifies statements to execute if the record is locked by another user. If you do not specify a LOCKED clause, the program waits until the lock on the record is released. Use the ECL command DEFAULT.LOCKED.ACTION BELL to make the terminal beep while you wait for UniData to unlock the record. THEN statements END THEN executes if the read is successful. END is required to terminate multiline THEN statements. ELSE statements END ELSE executes if the read is not successful or the record (or ID) does not exist. END is required to terminate multiline ELSE statements. READU Parameters

STATUS Function Return Values After you execute READU, the STATUS function returns one of the values described in the following table. Examples Value Description 0 Successful read. 1 UniData was unable to read the record. n The record is locked. The user number of the user who locked the file is returned in n. STATUS Function Return Values The following program segment is taken from the sample program in Appendix A, “Sample Programs,” in Developing UniBasic Applications. READU checks for locks. If the record is available, it sets an exclusive lock and reads the record into ORDER.REC. DISPLAY_DATA: * Display the current information in the desired record. This is * determined by the number the user entered (ORDER_NUMBER). READU ORDER.REC FROM ORDERS_FILE,ORDER_NUMBER THEN * Read with a lock so that no one else can modify it at the same time. RECORD_FOUND = 1 The record remains locked until the following program executes, which releases locks: WRITE ORDER.REC ON ORDERS_FILE,ORDER_NUMBER In the following example, the program segment assigns the record, read from the default file, to the variable INFO, and sets an exclusive lock on that record. UniData prints “Record locked” if the record is locked by another program, or prints “File not found” if the record does not exist. If the default file is not found, the program ends. READU INFO FROM "IDENT" LOCKED PRINT "Record locked" ELSE PRINT "Record not found" READU 1-645

Parameters<br />

The following table describes each parameter of the syntax.<br />

Parameter Description<br />

1-644 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />

dyn.array.var Specifies a dynamic array to contain the record.<br />

FROM file.var, Specifies the file variable from which to read the record.<br />

If you do not specify a file.var, UniData reads from the default<br />

file. If no default file is open, a fatal error occurs.<br />

The default file is one for which no file variable is assigned in<br />

the OPEN statement.<br />

record.ID.expr Specifies the record ID to use to retrieve the record.<br />

ON ERROR statements Specifies statements to execute if the READU statement fails<br />

with a fatal error because the file is not open, an I/O error occurs,<br />

or UniData cannot find the file.<br />

If you do not specify the ON ERROR clause and a fatal error<br />

occurs, the program terminates.<br />

LOCKED statements Specifies statements to execute if the record is locked by another<br />

user. If you do not specify a LOCKED clause, the program waits<br />

until the lock on the record is released.<br />

Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />

to make the terminal beep while you wait for UniData to unlock<br />

the record.<br />

THEN statements END THEN executes if the read is successful. END is required to<br />

terminate multiline THEN statements.<br />

ELSE statements END ELSE executes if the read is not successful or the record (or ID)<br />

does not exist. END is required to terminate multiline ELSE<br />

statements.<br />

READU Parameters

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!