From Br Wiki
Jump to: navigation, search
CHR$(<numeric expression>)

The Chr$ internal function returns the ASCII character represented by the numeric expression, which may have an integer value from 0 to 255.

Comments and Examples

Chr$ is often used to send special characters to control a printer or screen. Chr$(27) generates the same ASCII character as the Esc key.

In order to see the different characters which the CHR$ function can produce, run the following example:

00010 for i = 1 to 255
00020    print CHR$(i);
00030 next i


CHR example.png

Note that the semicolon after the print statement forces the carriage return not to be printed after each character. As a result, we are able to see all of our output on just a few lines which fit nicely on one screen. Without this semicolon we would only be able to see 24 rows of output at a time.

NWP Printing

CHR$(6) implies right justify the previous field for printed output. This works just like \Eright_justify except \Eright_justify applies to the following text whereas CHR$(6) pertains to the preceding text.

Related Functions

Inverse function is Ord(A$). Hex$ function can send several special codes in one function call.

Technical Considerations

  1. If the parameter value is greater than 255, only the low order byte will be used. Thus, CHR$(65) and CHR$(65+256) both will print the letter A.