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.

Note: IBM recommends that you do not use the TRIM function on dynamic arrays.<br />

For BASICTYPEs M and P, some leading and trailing spaces or occurrences of a<br />

specified character are not removed from elements in a dynamic array. For example,<br />

for BASICTYPE M or P, the following program segment:<br />

P = “**Fred**Smith**”:@VM:”**Jim**Olsen**”<br />

Q = TRIM(P,”*”)<br />

produces the following result (notice the asterisks surrounding the delimiter<br />

character):<br />

Q = Fred*Smith*}*Jim*Olsen<br />

For BASICTYPE R or U, the program segment produces the following result:<br />

Q = Fred*Smith}Jim Olsen<br />

To get this latter result regardless of BASICTYPE, use the TRIMS function.<br />

Examples<br />

In the following example, the program segment removes the leading, trailing, and<br />

extraneous blanks from the variable NAME:<br />

NAME = " Zenith, R. "<br />

NAME = TRIM(NAME)<br />

This results in the following:<br />

NAME = "Zenith, R."<br />

In the next example, the program segment removes the asterisks from the variables<br />

X and Y:<br />

X = TRIM("***NOT***ICE***","*")<br />

Y = TRIM("***NOT***ICE***","*","A")<br />

This results in the following:<br />

X = "NOT*ICE"<br />

Y = "NOTICE"<br />

TRIM 1-882

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

Saved successfully!

Ooh no, something went wrong!