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 The SETTING clause assigns the variable delim.var a value based on the type of delimiter encountered. The following table describes the values of the delimiter codes. *ASCII value is language-dependent and can be reassigned. 1-676 UniBasic Commands Reference FROM dyn.var Specifies a dynamic array from which to remove elements. AT col.pos Specifies the position in the array at which to start removing elements. This position is the number of characters, including system delimiters, from the beginning of the array. To process the entire array, set col.pos to 1 (0 defaults to 1). The value of col.pos changes as the array is processed, indicating the current position of the pointer. SETTING delim.var Specifies the delimiter code. When the end of the array is encountered, delim.var is set to 0. REMOVE Parameters (continued) Delimiete r Code Description ASCII Value* 0 array end 1 record mark 255 2 attribute mark 254 3 value mark 253 4 subvalue mark 252 5 text mark 251 6 not used; nonprinting 250 7 not used; nonprinting 249 REMOVE Delimiter Codes

Examples In the following example, the program segment processes the dynamic array CLIENT: DIM VAR(5,2) CLIENT = "G.Flaubert":@VM:"Guy":@SM:"12":@VM:"Yvette":@SM:"7" FOR I = 1 TO 5 REMOVE VAR(I,1) FROM CLIENT SETTING VAR(I,2) NEXT I CLIENT = CLIENT;*reset REMOVE pointer After the loop terminates, VAR contains the following: VAR(1,1) = "G.Flaubert" VAR(1,2) = 3 VAR(2,1) = "Guy" VAR(2,2) = 4 VAR(3,1) = "12" VAR(3,2) = 3 VAR(4,1) = "Yvette" VAR(4,2) = 4 VAR(5,1) = "7" VAR(5,2) = 0 Notice that each element in the array VAR contains the extracted array element and the associated delimiter. In the next example, the program segment starts at the beginning of the array AMOUNTS, successively removes each element from the array, calculates a 3.5 percent tax amount, and adds it into the variable TAX.AMT. When MARK = 0 (delim.var is 0), processing terminates. COL = 1 LOOP REMOVE INV.AMT FROM AMOUNTS AT COL SETTING MARK TAX.AMT += INV.AMT*.035 WHILE MARK DO REPEAT In the next example, the program segment demonstrates the difference between UniBasic and other implementations of BASIC: ARRAY = "AB":@AM:"CD":@AM:"EF" COL = 1 LOOP REMOVE LINE FROM ARRAY AT COL SETTING MARK PRINT LINE, COL, MARK WHILE MARK REPEAT In UniBasic, the result is the following: AB 4 2 CD 7 2 EF 9 0 REMOVE 1-677

Examples<br />

In the following example, the program segment processes the dynamic array<br />

CLIENT:<br />

DIM VAR(5,2)<br />

CLIENT = "G.Flaubert":@VM:"Guy":@SM:"12":@VM:"Yvette":@SM:"7"<br />

FOR I = 1 TO 5<br />

REMOVE VAR(I,1) FROM CLIENT SETTING VAR(I,2)<br />

NEXT I<br />

CLIENT = CLIENT;*reset REMOVE pointer<br />

After the loop terminates, VAR contains the following:<br />

VAR(1,1) = "G.Flaubert" VAR(1,2) = 3<br />

VAR(2,1) = "Guy" VAR(2,2) = 4<br />

VAR(3,1) = "12" VAR(3,2) = 3<br />

VAR(4,1) = "Yvette" VAR(4,2) = 4<br />

VAR(5,1) = "7" VAR(5,2) = 0<br />

Notice that each element in the array VAR contains the extracted array element and<br />

the associated delimiter.<br />

In the next example, the program segment starts at the beginning of the array<br />

AMOUNTS, successively removes each element from the array, calculates a 3.5<br />

percent tax amount, and adds it into the variable TAX.AMT. When MARK = 0<br />

(delim.var is 0), processing terminates.<br />

COL = 1<br />

LOOP<br />

REMOVE INV.AMT FROM AMOUNTS AT COL SETTING MARK<br />

TAX.AMT += INV.AMT*.035<br />

WHILE MARK DO REPEAT<br />

In the next example, the program segment demonstrates the difference between<br />

<strong>UniBasic</strong> and other implementations of BASIC:<br />

ARRAY = "AB":@AM:"CD":@AM:"EF"<br />

COL = 1<br />

LOOP<br />

REMOVE LINE FROM ARRAY AT COL SETTING MARK<br />

PRINT LINE, COL, MARK<br />

WHILE MARK REPEAT<br />

In <strong>UniBasic</strong>, the result is the following:<br />

AB 4 2<br />

CD 7 2<br />

EF 9 0<br />

REMOVE 1-677

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

Saved successfully!

Ooh no, something went wrong!