Chr$: Difference between revisions
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
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. | 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: | |||
[[File: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. | |||
===Related Functions=== | ===Related Functions=== |
Revision as of 20:24, 18 January 2012
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.