Array Help - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Array Help

stevengreen22stevengreen22 Posts: 4Member
Hi guys,

I'm close to reaching for the hammer and hopi9ng someone here can point out an obvious error I've made.
New to pascal and so on so at times I'm shooting in the dark but...

I need the ASCII characters to display in a table format. the chars 0 to 32 are throwing the table out of alignment which is frustrating...very...and my knowledge is so that I can't get aroudn the problem.

Someone in another post gave me the idea for using an array, i wanted to use a loop so that for these numbers the "name" of the key would be used instead of the printable char.

But...I cannot get it to read / write those lines, it simply misses them out and i don't knwo why.

Can anyone point me in the right direction? I'm sure it's something stupid but can't see it.

code =

rogram ASCIITABLE(output);

uses crt;

const columncount = 8; {8 columns as 128 is div perfectly by 8}
columnwidth = 3; {unprintables need 3 spaces, neater output}
Title:string = (' ASCII TABLE ');

unprint: array [0..32] of string =(
{string as below are 'string' variable}
'ACK','BEL','BS ','HT ','LF ','VT ',
'FF ','CR ','SO ','SI ','DLE','DC1',
'CAN','EM ','SUB','ESC','FS ','GS ',
'RS ','US ','SP ');

var j,i: integer;
ch: Char;
idx: byte;

begin {main program}
writeln (Title);

for i := 0 to 32 do
write (chr(i):columnwidth);
write (' ',i:4);
if (((i+1) mod columncount) = 0) then
end; }

for i:= 33 to 127 do
write (chr(i):columnwidth);
write (' ',i:4);
if (((i+1) mod Columncount) = 0) then

{ writeln (' '); }
writeln ('Press any key to continue' ,ch);

read (ch);

Jay...Stop thieving my code :D


  • quikcarlquikcarl Posts: 59Member
    You've got the right idea but slightly overdoing it.

    : read(unprint[i]);
    : write (chr(i):columnwidth);

    Cut out the read and change the write.

    [code] write (unprint[i]:columnwidth);
Sign In or Register to comment.