IB Statements/chr

From CometWiki

Jump to: navigation, search

CHR function

Syntax: CHR(numeric-argument)

Discussion: The CHR function returns a single-byte ASCII character corresponding to the 8-bit binary number equivalent of the numeric-argument.

The numeric-argument is a decimal value between 0 and 255, inclusive. Only the absolute integer portion of the numeric argument is used for the conversion; the sign and fractional digits (if any) of the numeric argument are ignored.

The numeric-argument may be a numeric constant, a single-element numeric variable, a numeric array element, a numeric expression, or a numeric function.

If the numeric argument is greater than 255, it is reduced by integer multiples of 256 until the remaining value is less than 256 (i.e., the numeric argument is evaluated modulo 256). This is accomplished by dividing the value by 256 and retaining the integer remainder. For example, 600 is evaluated as 88 (600/256 equals 2 with a remainder of 88). The decimal number is then converted to ASCII and stored as the value of a single-byte string.

Example: VALUE$ = CHR(CODE)

In the above example, the numeric variable CODE is converted to its ASCII equivalent; the resulting string byte is stored in VALUE$.

For example, if CODE equals 65, the CHR function converts it to the letter "A" (the ASCII value for decimal 65); this character is then stored in VALUE$.

Personal tools