11.04.2013 Views

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAR<br />

Syntax<br />

CHAR(expr)<br />

Description<br />

The <strong>UniBasic</strong> CHAR function changes a numeric expression to its ASCII (American<br />

Standard Code for Information Interchange) character string equivalent. expr can be<br />

a constant, variable, numeric function, or any combination of these. expr must<br />

evaluate to a positive number from 0 to 255 (the range of ASCII character codes).<br />

CHAR supports multibyte languages.<br />

Not all ASCII codes are printable. Some represent terminal controls, and others are<br />

reserved for special uses. For more information about ASCII character codes, see<br />

Appendix A, “ASCII Character Codes.”<br />

Tip: Use @variables to represent UniData delimiters and the null value. IBM<br />

recommends that you not use the <strong>UniBasic</strong> functions CHAR or CHARS to insert these<br />

variables because the ASCII code that represents it varies with language group.<br />

Examples<br />

In the following example, the program segment assigns the ASCII string equivalent<br />

of the numeric expression VAL to the variable VSTRING. The final numeric value of<br />

the argument is 90, so VSTRING becomes Z, the character equivalent of 90 in ASCII<br />

code.<br />

VAL=90<br />

VSTRING=CHAR(VAL)<br />

In the next example, the program statement sends the ASCII code 12 to the current<br />

print device. In ASCII, this is a form feed.<br />

PRINT CHAR(12)<br />

1-135 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>

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

Saved successfully!

Ooh no, something went wrong!