11.04.2013 Views

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example<br />

In the following example, the program segment opens the ORDERS file to the<br />

variable ORDER.FILE and the dictionary of the ORDERS file to the special @DICT<br />

variable. After selecting the ORDERS file, the program reads the value of each<br />

record ID into @ID, reads the value of the order record into @RECORD, then uses<br />

the {} (braces) function to evaluate the order balance (storing the total in<br />

TOTAL.DUE). The braces function updates the @CONV and @FORMAT variables,<br />

which are used to print the total with the correct format.<br />

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

OPEN 'ORDERS' TO ORDER.FILE ELSE<br />

STOP 'NO ORDER FILE'<br />

END<br />

OPEN 'DICT','ORDERS' TO @DICT ELSE<br />

STOP 'NO DICTIONARY FOR ORDERS FILE'<br />

END<br />

TOTAL.DUE = 0<br />

SELECT ORDER.FILE<br />

MORE = 1<br />

LOOP<br />

READNEXT @ID ELSE MORE = 0<br />

UNTIL NOT(MORE) DO<br />

READ @RECORD FROM ORDER.FILE,@ID ELSE<br />

@RECORD = ''<br />

END<br />

TOTAL.DUE += {GRAND_TOTAL}<br />

REPEAT<br />

TOTAL.DUE = OCONV(TOTAL.DUE,@CONV)<br />

PRINT "Total Accounts Receivable":FMT(TOTAL.DUE,@FORMAT)<br />

CLEARSELECT<br />

END<br />

Related Command<br />

<strong>UniBasic</strong><br />

ITYPE

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

Saved successfully!

Ooh no, something went wrong!