On 5/22/07, Felipe Monteiro de Carvalho
<[EMAIL PROTECTED]> wrote:
On 5/22/07, A.J. Venter <[EMAIL PROTECTED]> wrote:
> CRT is one way but rather relies on using the whole console. Anyway
> ncrt is safer. Sounds like you need something like this:
> uses ncrt;

I got interrested on this, so I wrote a test program. I tested with
both ncrt and crt, and actually I found that ncrt will erase the whole
console and start writing from position (1,1), while crt will keep
things that already exist on the console and start writing on the next
line.

So, for some uses, crt may be nicer.
This is actually a side effect, there is another problem to consider:
1) crt wins for small environments since it needs no external libs
2) ncrt wins for all other cases even though it needs ncurses and
clears the whole screen.

The real difference is that ncrt is terminal independent - it works on
anything unix supports (less of an issue in this day of virtual
terminals with vt100 compatibility but still) - while crt uses ansi
escape sequences - which are terminal specific.

This has an opposite side though: you CAN use crt to set your console
font color etc. - the changes will remain after your program exits,
ncrt will not.

So it's a case of which is your needs - for general console apps
though - you should use ncrt because it's terminal independent and a
LOT faster (ansi escapes take a long time to execute and make your
whole program feel slow)

A.J.

program console;

{$mode objfpc}{$H+}

uses
  crt, SysUtils; // here you can change crt with ncrt

begin
  Write('[                    ] 0%');
  GotoXY(1, WhereY);
  Sleep(200);

  Write('[=>                  ] 10%');
  GotoXY(1, WhereY);
  Sleep(200);

  Write('[===>                ] 20%');
  GotoXY(1, WhereY);
  Sleep(200);

  Write('[=====>              ] 30%');
  GotoXY(1, WhereY);
  Sleep(200);

  Write('[=======>            ] 40%');
  GotoXY(1, WhereY);
  Sleep(200);

  Write('[=========>          ] 50%');
  GotoXY(1, WhereY);
  Sleep(200);
end.

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives



--
A.J. Venter
CEO - OutKast Solutions C.C.
http://www.outkastsolutions.co.za
Cell: +27 83 455 9978
Fax: +27 21 413 2800
Office: +27 21 591 6766

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to