Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.