www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Suggestion for writef/writefln (or can this be already done now?)

reply Id <Id_member pathlink.com> writes:
Some commandline programs write, per example, percentage of completion in the
screen.
Those programs usually write a line, and update the numbers by overwriting over
the same line continuously.

Is this possible with writef/writefln or another function already made in
Phobos?
Aug 28 2004
parent reply Andy Friesen <andy ikagames.com> writes:
Id wrote:
 Some commandline programs write, per example, percentage of completion in the
 screen.
 Those programs usually write a line, and update the numbers by overwriting over
 the same line continuously.
 
 Is this possible with writef/writefln or another function already made in
 Phobos?
You can achieve this by writing a \r (instead of \n) at the end of line. I don't know if this works the same way in Linux, though. -- andy
Aug 28 2004
parent reply Nick <Nick_member pathlink.com> writes:
In article <cgqcmd$31fg$1 digitaldaemon.com>, Andy Friesen says...
You can achieve this by writing a \r (instead of \n) at the end of line. 
  I don't know if this works the same way in Linux, though.
Works exactly the same in Linux. A problem is the writef-doesn't-flush thing, thing though. Unless you write out a newline somewhere, your writefs won't do anything at all. You can get around this by using stdout.writeString from std.string instead. Nick
Aug 28 2004
parent reply "Walter" <newshound digitalmars.com> writes:
"Nick" <Nick_member pathlink.com> wrote in message
news:cgqde2$4q$1 digitaldaemon.com...
 In article <cgqcmd$31fg$1 digitaldaemon.com>, Andy Friesen says...
You can achieve this by writing a \r (instead of \n) at the end of line.
  I don't know if this works the same way in Linux, though.
Works exactly the same in Linux. A problem is the writef-doesn't-flush thing, thing though. Unless you
write out
 a newline somewhere, your writefs won't do anything at all. You can get
around
 this by using stdout.writeString from std.string instead.
or calling std.c.stdio.fflush(stdout) should work.
Aug 28 2004
parent Nick <Nick_member pathlink.com> writes:
In article <cgqio8$20p$3 digitaldaemon.com>, Walter says...
 Works exactly the same in Linux.

 A problem is the writef-doesn't-flush thing, thing though. Unless you
 write out a newline somewhere, your writefs won't do anything at all.
 You can get around this by using stdout.writeString from std.string
 instead.
or calling std.c.stdio.fflush(stdout) should work.
Yes, but that's so... C-ish :-P Nick
Aug 28 2004