Board index » delphi » Same line screen printing...

Same line screen printing...

Hi y'all

in certain programs such as PKZIP and UnZip, it displays a percentage.
But, the percentage is on the same line.  How do I make the cursor go
back to a certain place or to the beginning of the line?  So I can reprint
the line using the new percentage.
                                               Thank you,
                                                    Joshua Davis

--

                       The South Will Rise Again.....
                 |---------------------------------------|
                 |\     \                         /     /|
                 |  \  *  \                     /  *  /  |
                 |    \     \                 /     /    |
                 |      \  *  \             /  *  /      |
                 |        \     \         /     /        |
                 |          \  *  \     /  *  /          |
                 |            \     \ /     /            |
                 |              \         /              |
                 |              /    *    \              |
   Free By       |            /     / \     \            |...Southern By
     Birth...    |          /  *  /     \  *  \          |    The Grace Of
                 |        /     /         \     \        |      GOD!!!
                 |      /  *  /             \  *  \      |
                 |    /     /                 \     \    |
                 |  /  *  /                     \  *  \  |
                 |/     /                         \     \|
                 |---------------------------------------|
                (I'm not racist, just a PROUD SOUTHERNER!!)

 

Re:Same line screen printing...


Quote
In article <slrn44nl5ie.j5n.dav...@mcnet.marietta.edu> Joshua Davis wrote:
>Hi y'all

>in certain programs such as PKZIP and UnZip, it displays a percentage.
>But, the percentage is on the same line.  How do I make the cursor go
>back to a certain place or to the beginning of the line?  So I can reprint
>the line using the new percentage.
>                                               Thank you,
>                                                    Joshua Davis

There are quite a few ways to accomplish this.>

If you are using the CRT unit, you can position the cursor before writing. Or
you can save the current position and restore it after writing.

                x := WhereX;
                Write(PercentComplete:4);
                Gotoxy(x, WhereY)

You can also backspace to get to the beginning of the field.

                Write(PercentDone:4, #8#8#8#8);

Or you can emit the whole lime each time.

                Write(#13'Completed ', PercentDone, '%');

If you see little flashes of cursor while doing this, you might consider
turning the cursor off.  See Timo's FAQs or SWAG.

                      ...red

Knowledge is one of the few things that you
can give away and still keep for yourself.

Re:Same line screen printing...


Quote
>Hi y'all

>in certain programs such as PKZIP and UnZip, it displays a percentage.
>But, the percentage is on the same line.  How do I make the cursor go
>back to a certain place or to the beginning of the line?  So I can reprint
>the line using the new percentage.
>                                               Thank you,
>                                                    Joshua Davis

Have you tried using GotoXY?  You need to detect the current row position of
the cursor and use that to go to the correct line.

Re:Same line screen printing...


jope...@delphi.com (Jose' M. Perez) wrote:

Quote
>>Hi y'all

>>in certain programs such as PKZIP and UnZip, it displays a percentage.
>>But, the percentage is on the same line.  How do I make the cursor go
>>back to a certain place or to the beginning of the line?  So I can reprint
>>the line using the new percentage.
>>                                               Thank you,
>>                                                    Joshua Davis

>Have you tried using GotoXY?  You need to detect the current row position of
>the cursor and use that to go to the correct line.

Try using write(your string, #$0A); (or was it #$0D :-) ). At least it
is one of those (#$0A or #$0D). One of them forces the cursor to go to
the beginning of the current line, the other puts the cursor on the
next line. WriteLn is translated into Write with both of the codes
added.

Hopes this helps.

Arjan Kleene
--
University of Twente
the Netherlands, Europe

email: a.kle...@student.utwente.nl
   or: kle...@cs.utwente.nl

Re:Same line screen printing...


Quote
Joshua Davis (dav...@mcnet.marietta.edu) wrote:

: Hi y'all

: in certain programs such as PKZIP and UnZip, it displays a percentage.
: But, the percentage is on the same line.  How do I make the cursor go
: back to a certain place or to the beginning of the line?  So I can reprint
: the line using the new percentage.
:                                                Thank you,
:                                                     Joshua Davis

Joshua, you'll have to use the GotoXY() statement.  Basically here is an
example.  It's not pretty, but it should help explain.

Uses Crt, Dos;

Var
   Done : Boolean;
   PercentComplete := integer;

Begin
     Done := false;

     While Not done do
           GotoXY(24,10);
           Write(percentComplete);
           If PercentComplete => 99 then
              done := true;
End.

Other Threads