Board index » delphi » Positioning the cursor.

Positioning the cursor.

I know I can use gotoxy to place the cursor where I want it, but if I do
that, I have to set the cursor again after every writeln statement. Is there
a way to set the number of spaces text appears across the screen (without
using some sort of write('          '); command? I'd like it to set the
cursor so I don't have to call it every time I want to output text.

TIA.

--
Gargamel : Arch-enemy of the bane of all humanity - The Smurfs. |
---------------------------------------------------------------'
garga...@argonet.co.uk /// For every PC out there, there's a Risc
                       /// waiting to be fulfilled.

 

Re:Positioning the cursor.


In article <na.656ed648a0.a500d0sb...@argonet.co.uk>,

Quote
Gargamel  <sb...@argonet.co.uk> wrote:
>I know I can use gotoxy to place the cursor where I want it, but if I do
>that, I have to set the cursor again after every writeln statement. Is there
>a way to set the number of spaces text appears across the screen (without
>using some sort of write('          '); command? I'd like it to set the
>cursor so I don't have to call it every time I want to output text.

Window()

Osmo

Re:Positioning the cursor.


Quote
Gargamel <sb...@argonet.co.uk> wrote:
> I know I can use gotoxy to place the cursor where I want it, but if I do
> that, I have to set the cursor again after every writeln statement. Is there
> a way to set the number of spaces text appears across the screen (without
> using some sort of write('          '); command? I'd like it to set the
> cursor so I don't have to call it every time I want to output text.

Use this instead of writeln:

procedure puts(x,y: word; s: string; fg, bg: byte);
var d,i,c: integer;
begin
     d:=y*80+x; i:=1; c:=(bg shl 4+fg) shl 8;
     repeat
           memw[$B800:d]:=word(s[i])+c;
           inc(i); inc(d, 2);
     until i>length(s);
end;

where
        x,y   : the screen-coordinates to display the string
    s     : the string you want to display
    fg,bg : the foreground and background color

f.e. puts(10,10,"Hello World",7,0);

Quote
> TIA.
> --
> Gargamel : Arch-enemy of the bane of all humanity - The Smurfs. |
> ---------------------------------------------------------------'
> garga...@argonet.co.uk /// For every PC out there, there's a Risc
>                        /// waiting to be fulfilled.

Re:Positioning the cursor.


Quote
Gargamel <sb...@argonet.co.uk> wrote:
>I know I can use gotoxy to place the cursor where I want it, but if I do
>that, I have to set the cursor again after every writeln statement. Is there
>a way to set the number of spaces text appears across the screen (without
>using some sort of write('          '); command? I'd like it to set the
>cursor so I don't have to call it every time I want to output text.
>TIA.
>--
>Gargamel : Arch-enemy of the bane of all humanity - The Smurfs. |
>---------------------------------------------------------------'
>garga...@argonet.co.uk /// For every PC out there, there's a Risc
>                       /// waiting to be fulfilled.

After you gotoxy for your starting position, every writeln thereafter will
move the cursor one row down to column 1.

Re:Positioning the cursor.


In article <71terv$...@kruuna.Helsinki.FI>, ronka...@cc.helsinki.fi (Osmo

Quote
Ronkanen) wrote:
> Window()

> Osmo

Ta muchly.

--
Gargamel : Arch-enemy of the bane of all humanity - The Smurfs. |
---------------------------------------------------------------'
garga...@argonet.co.uk /// For every PC out there, there's a Risc
                       /// waiting to be fulfilled.

Re:Positioning the cursor.


In article <71uaur$5...@mailnews.kub.nl>, Jaap van Hengstum <s757...@kub.nl>
wrote:

Quote
> Use this instead of writeln:

> procedure puts(x,y: word; s: string; fg, bg: byte);
> var d,i,c: integer;
> begin
>      d:=y*80+x; i:=1; c:=(bg shl 4+fg) shl 8;
>      repeat
>            memw[$B800:d]:=word(s[i])+c;
>            inc(i); inc(d, 2);
>      until i>length(s);
> end;

> where
>  x,y   : the screen-coordinates to display the string
>     s     : the string you want to display
>     fg,bg : the foreground and background color

> f.e. puts(10,10,"Hello World",7,0);

No offense, but, urrgh!
This, although, I'm sure it's perfectly well-written and effective, would
require me to declare where I want to put every text item. (Plus I already
have a textout procedure which processes my strings which are stored as
arrays, and I wouldn't know where to start to incorporate the code above). I
don't really like using code I don't understand, so I'll use window(), as
suggested by Osmo. I might not understand how it works, but I know exactly
how to use it (now), and it defines the limits for all text items until I
declare another window.
Thanks anyway.

--
Gargamel : Arch-enemy of the bane of all humanity - The Smurfs. |
---------------------------------------------------------------'
garga...@argonet.co.uk /// For every PC out there, there's a Risc
                       /// waiting to be fulfilled.

Re:Positioning the cursor.


Quote
Gargamel wrote:

> No offense, but, urrgh!
> This, although, I'm sure it's perfectly well-written and effective, would
> require me to declare where I want to put every text item. (Plus I already
> have a textout procedure which processes my strings which are stored as
> arrays, and I wouldn't know where to start to incorporate the code above). I
> don't really like using code I don't understand, so I'll use window(), as
> suggested by Osmo. I might not understand how it works, but I know exactly
> how to use it (now), and it defines the limits for all text items until I
> declare another window.
> Thanks anyway.

If you knew a solution, why did you ask...? :)

Re:Positioning the cursor.


Quote
Gargamel wrote:

> No offense, but, urrgh!
> This, although, I'm sure it's perfectly well-written and effective, would
> require me to declare where I want to put every text item. (Plus I already
> have a textout procedure which processes my strings which are stored as
> arrays, and I wouldn't know where to start to incorporate the code above). I
> don't really like using code I don't understand, so I'll use window(), as
> suggested by Osmo. I might not understand how it works, but I know exactly
> how to use it (now), and it defines the limits for all text items until I
> declare another window.
> Thanks anyway.

If you knew a solution, why did you ask...? :)

Re:Positioning the cursor.


In article <36456EE6.4...@mb.sympatico.ca>,

Quote
James  <jo...@mb.sympatico.ca> wrote:
>Gargamel wrote:

>> No offense, but, urrgh!
>> This, although, I'm sure it's perfectly well-written and effective, would
>> require me to declare where I want to put every text item. (Plus I already
>> have a textout procedure which processes my strings which are stored as
>> arrays, and I wouldn't know where to start to incorporate the code above). I
>> don't really like using code I don't understand, so I'll use window(), as
>> suggested by Osmo. I might not understand how it works, but I know exactly
>> how to use it (now), and it defines the limits for all text items until I
>> declare another window.
>> Thanks anyway.

>If you knew a solution, why did you ask...? :)

He knew because I told him. Had he not asked then how could I have told
him.

Osmo

Re:Positioning the cursor.


In article <71uaur$5...@mailnews.kub.nl>,
Jaap van Hengstum  <s757...@kub.nl> wrote:

Quote
>Gargamel <sb...@argonet.co.uk> wrote:
>> I know I can use gotoxy to place the cursor where I want it, but if I do
>> that, I have to set the cursor again after every writeln statement. Is there
>> a way to set the number of spaces text appears across the screen (without
>> using some sort of write('          '); command? I'd like it to set the
>> cursor so I don't have to call it every time I want to output text.

>Use this instead of writeln:

>procedure puts(x,y: word; s: string; fg, bg: byte);
>var d,i,c: integer;
>begin
>     d:=y*80+x; i:=1; c:=(bg shl 4+fg) shl 8;

Assumption 1: 80 column screen.

Quote
>     repeat
>           memw[$B800:d]:=word(s[i])+c;

Assumption 2: Color screen, but not CGA.

Quote
>           inc(i); inc(d, 2);
>     until i>length(s);
>end;

If you are going to reinvent the wheel, try to make it round.

Quote
>where
>    x,y   : the screen-coordinates to display the string
>    s     : the string you want to display
>    fg,bg : the foreground and background color

>f.e. puts(10,10,"Hello World",7,0);

Osmo

Other Threads