Here's how I would do it:
The magic happens in a special syntax for the write/writeln functionCode:program ASCIITABLE; const ColumnCount = 6; ColumnWidth = 8; var i: longint; ch: Char; begin writeln ('A to Z in ASCII'); for i := 0 to 127 do begin write(chr(i):ColumnWidth); // Each column start at index 0, and ends at ColumnCount-1 if (((i+1) mod ColumnCount) = 0) then Writeln; end; Writeln; writeln('Press any key to continue' ,ch); read(ch); end.
If you call Write('a':4); then it'll write " a". Write(1:5); will produce " 1". This is some bad syntactic sugar that's always existed in Pascal
Bookmarks