Placing text in a particular area (x,y) [Free Pascal] - Programmers Heaven

Howdy, Stranger!

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

Categories

Placing text in a particular area (x,y) [Free Pascal]

PM5KPM5K Posts: 3Member
Hi!
i am doing a project for college and im making a nice looking GUI for my main screen. I have a text border around the screen and i want text to sit in the middle or somewhere in the border. I tried to use "gotoxy" but i dont have the library for it or theres another command that is used. im using free pascal and this is all i can use for the minute, does anyone know where i can get hold of the library file or know an alternative that will do exactly what i want it to do (respect that i cant change the border and GUI setup

thanks
PM5k

Comments

  • bpajkbpajk Posts: 156Member
    : Hi!
    : i am doing a project for college and im making a nice looking GUI for my main screen. I have a text border around the screen and i want text to sit in the middle or somewhere in the border. I tried to use "gotoxy" but i dont have the library for it or theres another command that is used. im using free pascal and this is all i can use for the minute, does anyone know where i can get hold of the library file or know an alternative that will do exactly what i want it to do (respect that i cant change the border and GUI setup
    :
    : thanks
    : PM5k
    :
    I sugges writing procedures that puts text in the middle or at the borders. You do it like so:
    [CODE]
    //for text shorter than 80 chars
    procedure PutTextCenter(const s:string; const length, line: byte);
    var column: byte;
    begin
    column:=round((80-length)/2);
    gotoxy(column, line);
    writeln(s)
    end;
    [/CODE]

    Something like this, I don't have the compiler on me to test this right now.
  • dolev9dolev9 Posts: 147Member
    well

    im not sure about free pascal but try this - its called interrupts.

    it will move the text to the location but it wont write anything - just use 'write' after that.


    uses dos;
    var
    reg : registers;

    begin
    reg.ah := 2;
    reg.bh := 0;
    reg.dh := linenumber;
    reg.dl := rownumber;
    intr($10,reg);
    end.



    this program tested under turbo pascal - another example for you.

    program bla;
    uses dos,crt;
    var
    reg : registers;

    begin
    clrscr;
    reg.ah := 2;
    reg.bh := 0;
    reg.dh := 10;
    reg.dl := 10;
    intr($10,reg);

    write('bla');
    readkey;


    end.





    good luck

    dolev


Sign In or Register to comment.