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

Parameter Description Examples In the following example, the program segment reads 10 IDs from select list 1, and then reads the records associated with those IDs. If a record ID is not found in the default system file, the program displays the message NOT FOUND. 1-630 UniBasic Commands Reference ON ERROR statements Specifies statements to execute if the READNEXT 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 user enters the debugger. 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 does not exist. END is required to terminate multiline ELSE statements. READNEXT Parameters (continued) FOR I = 1 TO 10 READNEXT ID FROM 1 ELSE SHORT.LIST = 1 THEN READU REC FROM CUST,ID ELSE PRINT "NOT FOUND" END NEXT I

In the next example, the program selects all Canadian clients, and then executes READNEXT to read and display the records for the first 22: EXECUTE 'SELECT CLIENTS WITH COUNTRY = "Canada"' EXECUTE "SAVE.LIST 'canadians'" OPEN 'CLIENTS' TO CLIENT.FILE ELSE ABORT GETLIST 'canadians' SETTING LIST.CNT ELSE PRINT CLIENT:" SAVELISTS ID ‘canadians’ CANNOT BE FOUND";STOP PRINT @(-1) FOR I = 1 TO 22 READNEXT ID ELSE EXIT READ REC FROM CLIENT.FILE, ID THEN PRINT @(5,I):REC:@(20,I):REC END ELSE PRINT "CANNOT FIND RECORD":ID END NEXT I CLEARSELECT END Related Commands UniBasic DELETELIST, FORMLIST, GETLIST, READLIST, SELECT, SELECTINDEX, SELECTINFO, WRITELIST UniQuery DELETE.LIST, GET.LIST, SAVE.LIST, SELECT, SSELECT – For information, see the UniQuery Commands Reference. UniData SQL SELECT – For information, see the UniData SQL Commands Reference. READNEXT 1-631

Parameter Description<br />

Examples<br />

In the following example, the program segment reads 10 IDs from select list 1, and<br />

then reads the records associated with those IDs. If a record ID is not found in the<br />

default system file, the program displays the message NOT FOUND.<br />

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

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

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

occurs, or UniData cannot find the file.<br />

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

occurs, the user enters the debugger.<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 does<br />

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

statements.<br />

READNEXT Parameters (continued)<br />

FOR I = 1 TO 10<br />

READNEXT ID FROM 1 ELSE SHORT.LIST = 1 THEN<br />

READU REC FROM CUST,ID ELSE PRINT "NOT FOUND"<br />

END<br />

NEXT I

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

Saved successfully!

Ooh no, something went wrong!