Show ASCII table: Difference between revisions

(→‎{{header|ALGOL 68}}: Show the table vertically as with most of the other samples)
 
(16 intermediate revisions by 9 users not shown)
Line 438:
=={{header|ALGOL 68}}==
<syntaxhighlight lang="algol68">
# generate an ascii table for characters 32 - 127 #
BEGIN
FOR c FROM 32 TO 32 + 15 DO
# generate an ascii table for characters 32 - 127 #
FOR cach FROM 32c BY 16 TO 32c + 15( 16 * 5 ) DO
FORprint( ach FROM c BY 16 TO c +( whole( 16ach, * 5-4 ) DO
print( ( whole( ach, -4": )"
, IF ,ach ":= 32 THEN "SPC"
, IF ELIF ach = 32127 THEN "SPCDEL"
ELSE " " + ELIFREPR ach = 127 THEN+ "DEL "
ELSE " " + REPR ach + " "FI
FI
)
)
OD;
print( ( newline ) )
OD
END
</syntaxhighlight>
{{out}}
Line 475 ⟶ 473:
 
=={{header|ALGOL W}}==
This assumes the ASCII character set is used by the Algol W compiler/runtime - the original Algol W implementation used EBCDIC.
<syntaxhighlight lang="algolw">begin
<syntaxhighlight lang="algolw">% generate an ascii table for chars 32 - 127 %
for i := 32 until 32 + 15 do begin
integer cPos;
cPos := 0write();
for ic := 32i step 16 until 127i + ( 16 * 5 ) do begin
ifwriteon( cPosi_w := 3, s_w := 0, thenc, ": " write();
cPosif := ( cPos + 1 )c rem= 6; 32 then writeon( "Spc ")
writeon(else i_wif c := 3,127 s_wthen := 0, i,writeon( ":Del " );
ifelse i = 32 then writeon( code( c ), "Spc " )
end for_ach
else if i = 127 then writeon( "Del " )
end for_i.
else writeon( code( i ), " " )
</syntaxhighlight>
end for_i
end.</syntaxhighlight>
{{out}}
<pre>
<pre> 32: Spc 33: ! 34: " 35: # 36: $ 37: %
3832: &Spc 3948: '0 4064: (@ 4180: )P 4296: * ` 43112: +p
4433: ,! 4549: -1 4665: .A 4781: /Q 4897: 0a 49113: 1q
5034: 2" 5150: 32 5266: 4B 5382: 5R 5498: 6 b 55114: 7r
5635: 8# 5751: 93 5867: :C 5983: ;S 6099: < c 61115: =s
6236: >$ 6352: ?4 6468: @D 6584: AT 66100: B d 67116: Ct
6837: D% 6953: E5 7069: FE 7185: GU 72101: H e 73117: Iu
7438: J& 7554: K6 7670: LF 7786: MV 78102: N f 79118: Ov
8039: P' 8155: Q7 8271: RG 8387: SW 84103: T g 85119: Uw
8640: V( 8756: W8 8872: XH 8988: YX 90104: Z h 91120: [x
9241: \) 9357: ]9 9473: ^I 9589: _Y 96105: ` i 97121: ay
9842: b* 9958: c: 100 74: dJ 10190: eZ 102106: fj 103122: gz
104 43: h+ 105 59: i; 106 75: jK 107 91: k[ 108107: lk 109123: m{
110 44: n, 111 60: o< 112 76: pL 11392: q\ 114108: rl 115124: s|
116 45: t- 117 61: u= 118 77: vM 11993: w] 120109: xm 121125: y}
122 46: z. 123 62: {> 124 78: |N 125 94: }^ 126110: ~n 127126: Del</pre>~
47: / 63: ? 79: O 95: _ 111: o 127: Del
</pre>
 
=={{header|APL}}==
Line 2,187 ⟶ 2,186:
46 : . 62 : > 78 : N 94 : ^ 110 : n 126 : ~
47 : / 63 : ? 79 : O 95 : _ 111 : o 127 : Del</pre>
 
=={{header|EasyLang}}==
{{trans|AWK}}
 
<syntaxhighlight lang="easylang">
numfmt 0 3
for i range0 16
for j = 32 + i step 16 to 127
if j = 32
x$ = "Spc"
elif j = 127
x$ = "Del"
else
x$ = strchar j & " "
.
write j & ": " & x$
.
print ""
.
</syntaxhighlight>
 
=={{header|Ecstasy}}==
<syntaxhighlight lang="java">
module testShowAsciiTable {
{
@Inject Console console;
void run() {
for (Int offset : 0..<16) {
for (Int ascii = 32+offset; :ascii 0..< 128; ascii += 16) {
{
for (Int ascii = 32+offset; ascii < 128; ascii += 16)
{
console.print($|{ascii.toString().rightJustify(3)}/\
|{ascii.toByte().toByteArray()}: \
|{new Char(ascii).quoted().leftJustify(5)}
, suppressNewline=True);
}
console.print();
}
console.print();
}
}
}
</syntaxhighlight>
 
Line 3,062 ⟶ 3,077:
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Show_ASCII_table}}
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for storage and transfer purposes more than visualization and edition.
 
'''Solution'''
Programs in Fōrmulæ are created/edited online in its [https://formulae.org website], However they run on execution servers. By default remote servers are used, but they are limited in memory and processing power, since they are intended for demonstration and casual use. A local server can be downloaded and installed, it has no limitations (it runs in your own computer). Because of that, example programs can be fully visualized and edited, but some of them will not run if they require a moderate or heavy computation/memory resources, and no local server is being used.
 
[[File:Fōrmulæ - Show ASCII table 01.png]]
In '''[https://formulae.org/?example=Show_ASCII_table this]''' page you can see the program(s) related to this task and their results.
 
[[File:Fōrmulæ - Show ASCII table 02.png]]
 
=={{header|FutureBasic}}==
Line 3,074 ⟶ 3,090:
 
local fn ASCIITable as CFStringRef
NSinteger i
'~'1
CFStringRef temp
NSinteger i
CFStringRef temp
CFMutableStringRef mutStr = fn MutableStringWithCapacity( 0 )
 
for i = 32 to 127
CFMutableStringRef mutStr = fn MutableStringWithCapacity( 0 )
temp = fn StringWithFormat( @"%c", i )
for i = 32 to 127
if i == 32 then temp = @"Spc"
temp = fn StringWithFormat( @"%c", i )
if i == 32127 then temp = @"SpcDel"
MutableStringAppendString( mutStr, fn StringWithFormat( @"%-1d : %@\n", i, temp ) )
if i == 127 then temp = @"Del"
next
MutableStringAppendString( mutStr, fn StringWithFormat( @"%-1d : %@\n", i, temp ) )
next
CFArrayRef colArr = fn StringComponentsSeparatedByString( mutStr, @"\n" )
 
CFArrayRef colArr = fn StringComponentsSeparatedByStringMutableStringSetString( mutStr, @"\n" )
for i = 0 to 15
MutableStringSetString( mutStr, @"" )
ObjectRef col0 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i ) )
for i = 0 to 15
ObjectRef col0col1 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 16 ) )
ObjectRef col1col2 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 1632 ) )
ObjectRef col2col3 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 3248 ) )
ObjectRef col3col4 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 4864 ) )
ObjectRef col4col5 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 6480 ) )
MutableStringAppendString( mutStr, fn StringWithFormat( @"%-10s %-10s %-10s %-10s %-10s %-10s\n", col0, col1, col2, col3, col4, col5 ) )
ObjectRef col5 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i + 80 ) )
next
MutableStringAppendString( mutStr, fn StringWithFormat( @"%-10s %-10s %-10s %-10s %-10s %-10s\n", col0, col1, col2, col3, col4, col5 ) )
next
end fn = fn StringWithString( mutStr )
 
Line 3,122 ⟶ 3,137:
47 : / 63 : ? 79 : O 95 : _ 111 : o 127 : Del
</pre>
 
 
=={{header|Go}}==
Line 3,250 ⟶ 3,264:
46 : . 62 : > 78 : N 94 : ^ 110 : n 126 : ~
47 : / 63 : ? 79 : O 95 : _ 111 : o 127 : Del </pre>
 
=={{Header|Insitux}}==
<syntaxhighlight lang="insitux">
(-> (for i (range 16)
j (range (+ i 32) 128 16)
(let k (match j 32 "Spc" 127 "Del" (str (char-code j) " ")))
(strn ((< j 100) " ") j " : " k))
(partition 6)
(map (join " "))
(join "\n"))
</syntaxhighlight>
{{out}}
<pre>
32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
33 : ! 49 : 1 65 : A 81 : Q 97 : a 113 : q
34 : " 50 : 2 66 : B 82 : R 98 : b 114 : r
35 : # 51 : 3 67 : C 83 : S 99 : c 115 : s
36 : $ 52 : 4 68 : D 84 : T 100 : d 116 : t
37 : % 53 : 5 69 : E 85 : U 101 : e 117 : u
38 : & 54 : 6 70 : F 86 : V 102 : f 118 : v
39 : ' 55 : 7 71 : G 87 : W 103 : g 119 : w
40 : ( 56 : 8 72 : H 88 : X 104 : h 120 : x
41 : ) 57 : 9 73 : I 89 : Y 105 : i 121 : y
42 : * 58 : : 74 : J 90 : Z 106 : j 122 : z
43 : + 59 : ; 75 : K 91 : [ 107 : k 123 : {
44 : , 60 : < 76 : L 92 : \ 108 : l 124 : |
45 : - 61 : = 77 : M 93 : ] 109 : m 125 : }
46 : . 62 : > 78 : N 94 : ^ 110 : n 126 : ~
47 : / 63 : ? 79 : O 95 : _ 111 : o 127 : Del
</pre>
 
=={{header|J}}==
Line 3,945 ⟶ 3,989:
end
prt(Tbl) # format and print table on console</syntaxhighlight>
 
=={{header|K}}==
{{works with|ngn/k}}
<syntaxhighlight lang=K>`0:"\n"/" "/'+6 16#{-6$($x),-2$`c$x}'32+!96
32 48 0 64 @ 80 P 96 ` 112 p
33 ! 49 1 65 A 81 Q 97 a 113 q
34 " 50 2 66 B 82 R 98 b 114 r
35 # 51 3 67 C 83 S 99 c 115 s
36 $ 52 4 68 D 84 T 100 d 116 t
37 % 53 5 69 E 85 U 101 e 117 u
38 & 54 6 70 F 86 V 102 f 118 v
39 ' 55 7 71 G 87 W 103 g 119 w
40 ( 56 8 72 H 88 X 104 h 120 x
41 ) 57 9 73 I 89 Y 105 i 121 y
42 * 58 : 74 J 90 Z 106 j 122 z
43 + 59 ; 75 K 91 [ 107 k 123 {
44 , 60 < 76 L 92 \ 108 l 124 |
45 - 61 = 77 M 93 ] 109 m 125 }
46 . 62 > 78 N 94 ^ 110 n 126 ~
47 / 63 ? 79 O 95 _ 111 o 127</syntaxhighlight>
 
=={{header|Kotlin}}==
Line 4,069 ⟶ 4,133:
=={{header|langur}}==
{{trans|Go}}
{{works with|langur|0.6.8}}
<syntaxhighlight lang="langur">for .i of 16 {
for .j = 31 + .i ; .j < 128 ; .j += 16 {
val .L = givenswitch(.j; 32: "spc"; 127: "del"; cp2s .j)
write $"\{{.j:3;}} : \{{.L:-4;}}"
}
writeln()
}
}</syntaxhighlight>
</syntaxhighlight>
 
{{out}}
Line 4,678 ⟶ 4,742:
 
=={{header|PL/M}}==
<syntaxhighlight lang="pli">100H: /* SHOW AN ASCII TABLE FROM 32 TO 127 */
100H: /* SHOW AN ASCII TABLE FROM 32 TO 127 */
/* CP/M BDOS SYSTEM CALL */
BDOS: PROCEDURE( FN, ARG ); DECLARE FN BYTE, ARG ADDRESS; GOTO 5; END;
Line 4,694 ⟶ 4,759:
END PR$BYTE;
/* ASCII TABLE */
DECLARE ( A, C ) BYTE;
DO C = 32 TO 12732 + 15;
CALLDO PR$BYTE(A = C TO C + ( 16 * 5 ) BY 16;
CALL PR$STRINGBYTE( .': $'A );
IF C = 32 THEN CALL PR$STRING( .'SPC: $' );
ELSE IF C A = 127 32 THEN CALL PR$STRING( .'DELSPC$' );
ELSE DOIF A = 127 THEN CALL PR$STRING( .'DEL$' );
CALLELSE PR$CHAR( ' ' )DO;
CALL PR$CHAR( ' C ' );
CALL PR$CHAR( ' 'A );
CALL PR$CHAR( ' ' );
END;
END;
IF ( ( C - 31 ) MOD 6 ) = 0 THEN CALL PR$STRING( .( 0DH, 0AH, '$' ) );
END;
EOF
EOF</syntaxhighlight>
</syntaxhighlight>
{{out}}
<pre>
032: SPC 033048: !0 034064: "@ 035080: #P 036096: $` 037112: %p
038033: &! 039049: '1 040065: (A 041081: )Q 042097: *a 043113: +q
044034: ," 045050: -2 046066: .B 047082: /R 048098: 0b 049114: 1r
050035: 2# 051: 3 052067: 4C 053083: 5S 054099: 6c 055115: 7s
056036: 8$ 057052: 94 058068: :D 059084: ;T 060100: <d 061116: =t
062037: >% 063053: ?5 064069: @E 065085: AU 066101: Be 067117: Cu
068038: D& 069054: E6 070: F 071086: GV 072102: Hf 073118: Iv
074039: J' 075055: K7 076071: LG 077087: MW 078103: Ng 079119: Ow
080040: P( 081056: Q8 082072: RH 083088: SX 084104: Th 085120: Ux
086041: V) 087057: W9 088073: XI 089: Y 090105: Zi 091121: [y
092042: \* 093058: ]: 094074: ^J 095090: _Z 096106: `j 097122: az
098043: b+ 099059: c; 100075: dK 101091: e[ 102107: fk 103123: g{
104044: h, 105060: i< 106076: jL 107092: k\ 108: l 109124: m|
110045: n- 111061: o= 112077: pM 113093: q] 114109: rm 115125: s}
116046: t. 117062: u> 118078: vN 119094: w^ 120110: xn 121126: y~
122047: z/ 123063: {? 124079: |O 125095: }_ 126111: ~o 127: DEL
</pre>
 
Line 6,087 ⟶ 6,155:
{{trans|Go}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
for (i in 0...16) {
885

edits