ASCII CODE / COLUMN WDITH, PLEASE HELP - Programmers Heaven

Howdy, Stranger!

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

Categories

ASCII CODE / COLUMN WDITH, PLEASE HELP

stevengreen22stevengreen22 Posts: 4Member
Hi guys,

Before I begin, Uber thanks for any help!!!

So the scenario is that I'm studying for a degree and we've been asked to look into Pascal due to the rigidity of the language.
this is my first taste of programming at this level./

Our current assignment is to reproduce the ASCII table.

This is low level stuff and I'm very new so bear with me.

So fair I have this:

program ASCIITABLE(output);

var i: Integer;
ch: Char;

begin {main program}

writeln ('A to Z in ASCII');

for i := 01 to 127 do
begin
write ( chr(i ));
writeln (' ', i);

end;

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

end.

as you can see, fairly basic.
What I'd like is to set the column width and blank fill with spaces so they are all aligned nicely adn to also set up 6 colums for tyhe code to be displayed in.

cna anyone help at all?

huge thanks

Comments

  • _Atex__Atex_ Posts: 163Member
    :
    : Our current assignment is to reproduce the ASCII table.
    :
    [code][color=Blue]// Complier FPC v.2.x.x

    {$mode fpc}{$appmode console}

    uses video;

    const hex:array[0..$f] of char='0123456789ABCDEF';

    procedure outchar(x,y:word;attr:byte;ch:char); // Prints a character with a given text attribute @ x,y
    begin
    if ((x=0) or (y=0)) then exit;dec(x);dec(y);
    videobuf^[y*screenwidth+x]:=word(attr shl 8) + byte(ch); // direct screen memory write
    end;

    var i,j:byte;

    begin initvideo;
    for i:=0 to $f do begin
    outchar(4+i*3,1 ,$0f,hex[i]);
    outchar(1 ,3+i*2,$0f,hex[i]);
    for j:=0 to $f do outchar(4+i*3,3+j*2,$06,chr(i shl 4+j));
    end;updatescreen(false);readln;end.[/color][/code]

Sign In or Register to comment.