Skip to content

Commit 1f5e0e9

Browse files
authored
Update 776-string-chr.markdown
1 parent 619be8f commit 1f5e0e9

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

_build/reference/776-string-chr.markdown

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
# CHR
22

3-
> CHR (x)
3+
> s = CHR (x)
44
5-
Returns one-char string of character with ASCII code x.
5+
Returns an one-char string of character with ASCII code `x`.
66

77
See ASC to convert a character to ASCII code.
88

9-
Example 1:
9+
### Example 1
1010

1111
```
12-
print "ASCII code 65 is '" + chr(65) + "'"
13-
14-
' Output ASCII code 65 is 'A'
12+
print "ASCII code 65 is '" + chr(65) + "'" ' Output ASCII code 65 is 'A'
1513
```
1614

17-
Example 2: The CHR command is useful for obtaining and printing the escape character (ASCII 27). For more information about escape codes see article "Escape Codes"
15+
### Example 2: Get escape character
16+
17+
The CHR command is useful for obtaining and printing the escape character (ASCII 27). For more information about escape codes see article "Escape Codes"
1818

1919
```
2020
PRINT CHR(27) + "[1mTHIS IS BOLD" + CHR(27) + "[0m"
2121
PRINT CHR(27) + "[3mThis is italic" + CHR(27) + "[0m"
2222
PRINT CHR(27) + "[4mThis is underline"
2323
```
2424

25-
Example 3: Print ASCII table
25+
### Example 3: Print ASCII table
2626

2727
```
28-
rem display the ASCII and the extended tables
28+
REM display the ASCII and the extended tables
29+
2930
For n = 0 To 255
31+
3032
If n = 0 Then
3133
Color 15, 0: Locate 1, 1
3234
Print "Standard 7-bit ASCII table (character codes 0 - 127):";
@@ -37,6 +39,7 @@ For n = 0 To 255
3739
Color 15, 0: Cls: Locate 1, 1
3840
Print "Nonstandard 8-bit Extended table (character codes 128 - 255):";
3941
Endif
42+
4043
If n <= 31 Then ' control characters (e.g. new-line, tab, etc).
4144
Read c
4245
Elseif n = 32 Then ' regular space (invisible...)
@@ -46,15 +49,18 @@ For n = 0 To 255
4649
Else
4750
c = Chr(n) ' ASCII code --> character
4851
Endif
52+
4953
Locate (n Mod 16) + 3, (((n \ 16) Mod 8) * 9) + 1
5054
5155
Color 7: Print Using "000 "; n; ' ASCII code
5256
Color 14: Print c; ' ASCII (or ANSI) character
5357
Next
58+
5459
Color 7, 0: Print: Print
5560
Print " * Nonstandard characters might look different on another system."
5661
5762
End
63+
5864
' nonprintable control characters (ASCII codes 0..31):
5965
Data "nul", "soh", "stx", "etx", "eot" ' 0..4
6066
Data "enq", "ack", "bel", "bs" , "tab" ' 5..9
@@ -64,5 +70,3 @@ Data "dc4", "nak", "syn", "etb", "can" ' 20..24
6470
Data "em" , "eof", "esc", "fs" , "gs" ' 25..29
6571
Data "rs" , "us" ' 30..31
6672
```
67-
68-

0 commit comments

Comments
 (0)