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 INMAT Function Return Values After you execute MATREAD, the INMAT function returns one of the values described in the following table. Note: BASICTYPEs P and R do not support the 0,0 element. If more attributes are read from the file than can be placed in the dimensioned array, a runtime error results and data is lost. Examples In the following example, the program segment reads the record with ID NAMES from the CUSTFILE, and assigns the elements to the dimensioned array TEST. If the program does not find the record, it assigns the value 0 to the variable FOUND. 1-450 UniBasic Commands Reference ON ERROR statements Specifies statements to execute if the MATREAD 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. 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. Value Meaning MATREAD Parameters (continued) n The number of attributes loaded into the array. 0 The array was too small to contain all attributes in the record. The excess data (including delimiters) is placed in the 0,0 element. INMAT Function Return Values DIM TEST(10,10) MATREAD TEST FROM CUSTFILE,"NAMES" ELSE FOUND = 0

In the next example, the program segment reads the record with ID NAMES and assigns the data from the record to the dimensioned array TEST: OPEN "CUSTFILE" TO CF ELSE STOP "NO CUSTFILE" MATREAD TEST FROM CF,"NAMES" ELSE FOUND = 0 In the next example, the MATREAD statement includes multiline THEN and ELSE clauses: FILE.ERR = 0 DIM CUST.ITEM(22) MATREAD CUST.ITEM FROM CUST.FILE,CUST.ID THEN GOSUB PROCESS.CUSTOMER: END ELSE MAT CUST.ITEM = " FILE.ERR = 1 END Related Commands UniBasic DIM, INMAT, MAT, MATBUILD, MATPARSE, MATREADL, MATREADU, MATWRITE, MATWRITEU MATREAD 1-451

Parameter Description<br />

INMAT Function Return Values<br />

After you execute MATREAD, the INMAT function returns one of the values<br />

described in the following table.<br />

Note: BASICTYPEs P and R do not support the 0,0 element. If more attributes are<br />

read from the file than can be placed in the dimensioned array, a runtime error results<br />

and data is lost.<br />

Examples<br />

In the following example, the program segment reads the record with ID NAMES<br />

from the CUSTFILE, and assigns the elements to the dimensioned array TEST. If the<br />

program does not find the record, it assigns the value 0 to the variable FOUND.<br />

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

ON ERROR statements Specifies statements to execute if the MATREAD 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 />

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 />

Value Meaning<br />

MATREAD Parameters (continued)<br />

n The number of attributes loaded into the array.<br />

0 The array was too small to contain all attributes in the record. The excess data<br />

(including delimiters) is placed in the 0,0 element.<br />

INMAT Function Return Values<br />

DIM TEST(10,10)<br />

MATREAD TEST FROM CUSTFILE,"NAMES" ELSE FOUND = 0

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

Saved successfully!

Ooh no, something went wrong!