CONTROLCHR: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
(Created page with "{{DISPLAYTITLE:_CONTROLCHR}} The _CONTROLCHR statement can be used to turn OFF control character attributes and allow them to be printed. {{PageSyntax}} : _CONTROLCHR {OFF|ON} {{PageDescription}} * The OFF clause allows control characters 0 to 31 to be printed and not format printing as normal text characters. ::For example: '''{{text|PRINT CHR$(13)|green}}''' 'will not move the cursor to the next line and '''{{text|PRINT CHR$(9)|green}}''' 'will not tab...") |
No edit summary |
||
(8 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
{{PageDescription}} | {{PageDescription}} | ||
* The [[OFF]] clause allows control characters 0 to 31 to be printed and not format printing as normal text characters. | * The [[OFF]] clause allows control characters 0 to 31 to be printed and not format printing as normal text characters. | ||
::For example: '''{{ | ::For example: '''{{Text|PRINT CHR$(13)|green}}''' 'will not move the cursor to the next line and '''{{Text|PRINT CHR$(9)|green}}''' 'will not tab. | ||
* The default [[ON]] statement allows [[ASCII#Control_Characters|Control Characters]] to be used as control commands where some will not print or will format prints. | * The default [[ON]] statement allows [[ASCII#Control_Characters|Control Characters]] to be used as control commands where some will not print or will format prints. | ||
* '''Note:''' File prints may be affected also when using Carriage Return or Line Feed/Form Feed formatting. | * '''Note:''' File prints may be affected also when using Carriage Return or Line Feed/Form Feed formatting. | ||
Line 17: | Line 17: | ||
{{PageExamples}} | {{PageExamples}} | ||
''Example:'' Printing the 255 [[ASCII]] characters in [[SCREEN]] 0 with 32 colors. | ''Example:'' Printing the 255 [[ASCII]] characters in [[SCREEN]] 0 with 32 colors. | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|DIM}} i {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} | {{Cl|DIM}} i {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} | ||
{{Cl|WIDTH}} 40, 25 | {{Cl|WIDTH}} {{Text|40|#F580B1}}, {{Text|25|#F580B1}} | ||
{{Cl|CLS}} | {{Cl|CLS}} | ||
{{Cl|_CONTROLCHR}} OFF | {{Cl|_CONTROLCHR}} {{Cl|OFF}} | ||
i = 0 | i = {{Text|0|#F580B1}} | ||
DO | {{Cl|DO}} | ||
{{Cl|PRINT}} {{Cl|CHR$}}(i); | |||
i = i + {{Text|1|#F580B1}} | |||
{{Cl|IF}} (i {{Cl|AND (boolean)|AND}} {{Text|&HF|#F580B1}}) = {{Text|0|#F580B1}} {{Cl|THEN}} {{Cl|PRINT}} | |||
{{Cl|LOOP | {{Cl|DO...LOOP|LOOP WHILE}} i | ||
{{Cl|LOCATE}} 1, 20 | {{Cl|LOCATE}} {{Text|1|#F580B1}}, {{Text|20|#F580B1}} | ||
DO | {{Cl|DO}} | ||
{{Cl|COLOR}} i {{Cl|AND}} {{Text|&HF|#F580B1}} {{Cl|OR}} (i {{Cl|AND}} {{Text|&H80|#F580B1}}) \ {{Text|&H8|#F580B1}}, (i {{Cl|AND}} {{Text|&H70|#F580B1}}) \ {{Text|&H10|#F580B1}} | |||
{{Cl|PRINT}} {{Cl|CHR$}}(i); | |||
i = i + {{Text|1|#F580B1}} | |||
{{Cl|IF}} (i {{Cl|AND (boolean)|AND}} {{Text|&HF|#F580B1}}) = {{Text|0|#F580B1}} {{Cl|THEN}} {{Cl|LOCATE}} {{Text|1|#F580B1}} + i \ {{Text|&H10|#F580B1}}, {{Text|20|#F580B1}} | |||
{{ | {{Cl|DO...LOOP|LOOP WHILE}} i | ||
{{Cl|END}} | {{Cl|END}} | ||
{{CodeEnd}} | {{CodeEnd}} | ||
{{PageSeeAlso}} | {{PageSeeAlso}} | ||
* [https://qb64phoenix.com/forum/showthread.php?tid=1260 Featured in our "Keyword of the Day" series] | |||
* [[_CONTROLCHR (function)]] | * [[_CONTROLCHR (function)]] | ||
* [[CHR$]], [[ASC]] | * [[CHR$]], [[ASC (function)]] | ||
* [[INKEY$]], [[_KEYHIT]] | * [[INKEY$]], [[_KEYHIT]] | ||
* [[ASCII]] | * [[ASCII]] | ||
* [[ASCII#Control_Characters|Control Characters]] | * [[ASCII#Control_Characters|Control Characters]] | ||
{{PageNavigation}} | {{PageNavigation}} |
Latest revision as of 17:50, 25 May 2024
The _CONTROLCHR statement can be used to turn OFF control character attributes and allow them to be printed.
Syntax
- _CONTROLCHR {OFF|ON}
Description
- The OFF clause allows control characters 0 to 31 to be printed and not format printing as normal text characters.
- For example: PRINT CHR$(13) 'will not move the cursor to the next line and PRINT CHR$(9) 'will not tab.
- The default ON statement allows Control Characters to be used as control commands where some will not print or will format prints.
- Note: File prints may be affected also when using Carriage Return or Line Feed/Form Feed formatting.
- The QB64 IDE may allow Alt + number pad character entries, but they must be inside of STRING values. Otherwise the IDE may not recognize them.
Examples
Example: Printing the 255 ASCII characters in SCREEN 0 with 32 colors.
DIM i AS _UNSIGNED _BYTE WIDTH 40, 25 CLS _CONTROLCHR OFF i = 0 DO PRINT CHR$(i); i = i + 1 IF (i AND &HF) = 0 THEN PRINT LOOP WHILE i LOCATE 1, 20 DO COLOR i AND &HF OR (i AND &H80) \ &H8, (i AND &H70) \ &H10 PRINT CHR$(i); i = i + 1 IF (i AND &HF) = 0 THEN LOCATE 1 + i \ &H10, 20 LOOP WHILE i END |
See also
- Featured in our "Keyword of the Day" series
- _CONTROLCHR (function)
- CHR$, ASC (function)
- INKEY$, _KEYHIT
- ASCII
- Control Characters