Quote Originally Posted by JSoftware View Post
Here's how I would do it:
Code:
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.
The magic happens in a special syntax for the write/writeln function

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



-----------
// Each column start at index 0, and ends at ColumnCount-1
if (((i+1) mod ColumnCount) = 0) then
Writeln;

Can you explain how this creates a new column? we're div the ascci numeral by 6 and if no remainder then a new line is created?

Sorry if this sounds retarded, I can "see" how it works, I just can't explain it to myself....

(not the best sentence I've ever written....)