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, SWAP does not replace a character with a character, but it<br />

replaces a string with a string. The program segment prints HARRY BELAFONTE.<br />

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

STRING = 'MARION BELAFONTE'<br />

SWAP 'MARION' WITH 'HARRY' IN STRING<br />

PRINT STRING<br />

The following program first creates a string that contains the null value, then calls a<br />

subroutine that converts UniData delimiters and the null value to characters that can<br />

be displayed or printed. Next, the program swaps the null value for another string<br />

(“def”), calls the conversion subroutine again, and prints the string again.<br />

A = @AM:"abc":@VM:@NULL:@VM:"ghi":@AM:"jkl"<br />

B = A<br />

CALL null.swap(B)<br />

PRINT B<br />

SWAP @NULL WITH "def" IN A<br />

B = A<br />

CALL null.swap(B)<br />

PRINT B<br />

The called subroutine is:<br />

SUBROUTINE null.swap(B)<br />

SWAP @NULL WITH "null" IN B<br />

SWAP @AM WITH " " IN B<br />

SWAP @VM WITH " " IN B<br />

SWAP @SM WITH " " IN B<br />

RETURN<br />

This program prints:<br />

:RUN BP null.swap.test<br />

abc null ghi jkl<br />

abc def ghi jkl<br />

Related Command<br />

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

CONVERT

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

Saved successfully!

Ooh no, something went wrong!