Home icon
Home

CHR$ Function

Purpose:

To convert an ASCII code to its equivalent character.

Syntax:

CHR$(n)

Comments:

n is a value from 0 to 255.

CHR$ is commonly used to send a special character to the terminal or printer. For example, you could send CHR$(7) to sound a beep through the speaker as a preface to an error message, or you could send a form feed, CHR$(12), to the printer.

See the ASC function for ASCII-to-numeric conversion.

ASCII Codes are listed in Appendix C of the GW-BASIC User's Guide.

Examples:

PRINT CHR$(66);
 B

This prints the ASCII character code 66, which is the uppercase letter B.

PRINT CHR$(13);

This command prints a carriage return.