Chr$: Difference between revisions
No edit summary |
|
(No difference)
|
Revision as of 16:18, 26 February 2014
The Chr$(X) internal function returns the ASCII character represented by X, 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
Output:
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.
Related Functions
Inverse function is Ord(A$). Hex$ function can send several special codes in one function call.
Technical Considerations
- 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.