11.04.2013 Views

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

In the next example, the program segment replaces “Blue” with the null value in STG,<br />

prints STG, then replaces the null value with “Blue” in STG, and prints STG again.<br />

The subroutine PRINT.SETUP converts attribute marks, value marks, and the null<br />

value to characters that can be displayed and printed.<br />

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

STG = "Movies":@AM:"The Sacrifice":@VM:"Blue":@AM:"Rocky IV"<br />

STG = REPLACE(STG,2,2,0,@NULL)<br />

GOSUB PRINT.SETUP<br />

PRINT "STG = ":PRT.STG<br />

STG = REPLACE(STG,2,2,0,"Blue")<br />

GOSUB PRINT.SETUP<br />

PRINT "STG = ":PRT.STG<br />

PRINT.SETUP:<br />

PRT.STG = CHANGE(STG, @NULL, "@NULL")<br />

PRT.STG = CHANGE(PRT.STG, @AM, "@AM")<br />

PRT.STG = CHANGE(PRT.STG, @VM, "@VM")<br />

RETURN<br />

This program prints the following:<br />

STG = Movies@AMThe Sacrifice@VM@NULL@AMRocky IV<br />

STG = Movies@AMThe Sacrifice@VMBlue@AMRocky IV<br />

In the next example, the first REPLACE places Harry Smith in the first attribute<br />

position. The second REPLACE places an array with two values in the fifth attribute.<br />

CUST.REC =''<br />

CUST.REC = REPLACE(CUST.REC,1,0,01'Harry Smith')<br />

CUST.REC = REPLACE(CUST.REC,5,0,0,"V220":@VM:"v230")<br />

This results in:<br />

CUST.REC = "Harry<br />

Smith":@AM::@AM::@AM::@AM:"V220":@VM:"V230"<br />

In the following example, the program uses the short form of the REPLACE<br />

command to append CLIENT.NAME to NAME.ARRAY1:<br />

NAME.ARRAY1 = "Smith Jones Brown"<br />

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

READV CLIENT.NAME FROM CLIENT.FILE,"10034",2 THEN<br />

NAME.ARRAY1 = CLIENT.NAME<br />

PRINT NAME.ARRAY1<br />

END ELSE<br />

PRINT 'NO RECORD FOR CLIENT ':CLIENT.ID<br />

END

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

Saved successfully!

Ooh no, something went wrong!