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

STATUS Function Return Values After you execute READBCKL, the STATUS function returns one of the values described in the following table. Value Description 0 Successful read. Example This example uses the following program to lock the CLIENT file for two minutes: 1-604 UniBasic Commands Reference 10 UniBasic found and read a duplicate alternate index key value, and ECL DUP.STATUS is on. STATUS Function Return Values OPEN "CLIENTS" TO CLIENT.FILE ELSE STOP FILELOCK CLIENT.FILE LOCKED PRINT "CLIENTS FILE already locked." SLEEP 120 FILEUNLOCK CLIENT.FILE If you execute the following program: OPEN 'CLIENTS' TO tmp ELSE STOP SETINDEX 'LNAME', 'Smith' ON tmp FOR X = 1 TO 5 READBCKL rec FROM tmp THEN PRINT rec:", ":rec:" ":rec ELSE STOP NEXT X END Notice that execution halts on the second program until the first program unlocks the CLIENTS file. This is because commands that set shared locks cannot access files locked with exclusive locks (FILELOCK sets an exclusive lock). Note: If the first program had set a shared lock, the second program would have been able to read the records.

Related Commands UniBasic READBCK, READBCKU, READFWD, READFWDL, READFWDU, READXBCK, READXFWD, SELECTINDEX, SETINDEX UniData BUILD.INDEX, CREATE.INDEX, DEFAULT.LOCKED.ACTION, DUP.STATUS – For information, see the UniData Commands Reference. READBCKL 1-605

STATUS Function Return Values<br />

After you execute READBCKL, the STATUS function returns one of the values<br />

described in the following table.<br />

Value Description<br />

0 Successful read.<br />

Example<br />

This example uses the following program to lock the CLIENT file for two minutes:<br />

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

10 <strong>UniBasic</strong> found and read a duplicate alternate index key value, and ECL<br />

DUP.STATUS is on.<br />

STATUS Function Return Values<br />

OPEN "CLIENTS" TO CLIENT.FILE ELSE STOP<br />

FILELOCK CLIENT.FILE LOCKED PRINT "CLIENTS FILE already locked."<br />

SLEEP 120<br />

FILEUNLOCK CLIENT.FILE<br />

If you execute the following program:<br />

OPEN 'CLIENTS' TO tmp ELSE STOP<br />

SETINDEX 'LNAME', 'Smith' ON tmp<br />

FOR X = 1 TO 5<br />

READBCKL rec FROM tmp THEN PRINT rec:", ":rec:" ":rec<br />

ELSE STOP<br />

NEXT X<br />

END<br />

Notice that execution halts on the second program until the first program unlocks the<br />

CLIENTS file. This is because commands that set shared locks cannot access files<br />

locked with exclusive locks (FILELOCK sets an exclusive lock).<br />

Note: If the first program had set a shared lock, the second program would have been<br />

able to read the records.

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

Saved successfully!

Ooh no, something went wrong!