www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - GDC - no flush to stdio?

reply "DLearner" <bmqazwsx123 gmail.com> writes:
I was trying to use writef("Escape string" ~ "Display string") to 
simulate a full-screen console.  But writef doesn't seem to flush 
until a newline entered (which disturbs cursor position).

I would have expected a 'flush()' function, but 'flush()' itself 
produces an error (does not exist), and 'fflush()' seems to be 
for file use, not for writing to a screen (stdio).

Please, how do I force a flush to stdio?
Apr 01 2013
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 04/01/2013 11:37 AM, DLearner wrote:
 I was trying to use writef("Escape string" ~ "Display string") to
 simulate a full-screen console.  But writef doesn't seem to flush until
 a newline entered (which disturbs cursor position).

 I would have expected a 'flush()' function, but 'flush()' itself
 produces an error (does not exist), and 'fflush()' seems to be for file
 use, not for writing to a screen (stdio).

 Please, how do I force a flush to stdio?
writef is a shorthand for stdout.writef because stdout is actually a FILE, so stdout.flush() should work. Ali
Apr 01 2013
parent reply "DLearner" <bm.email01 gmail.com> writes:
On Monday, 1 April 2013 at 18:44:16 UTC, Ali Çehreli wrote:
 On 04/01/2013 11:37 AM, DLearner wrote:
 I was trying to use writef("Escape string" ~ "Display string") 
 to
 simulate a full-screen console.  But writef doesn't seem to 
 flush until
 a newline entered (which disturbs cursor position).

 I would have expected a 'flush()' function, but 'flush()' 
 itself
 produces an error (does not exist), and 'fflush()' seems to be 
 for file
 use, not for writing to a screen (stdio).

 Please, how do I force a flush to stdio?
writef is a shorthand for stdout.writef because stdout is actually a FILE, so stdout.flush() should work. Ali
I tried this but got: "No property 'flush' for type '_iobuf'" Sorry but please note I also posted to the GDC forum - the non-return from the anti-spam delay made me think this posting had failed.
Apr 01 2013
parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Mon, Apr 01, 2013 at 08:53:40PM +0200, DLearner wrote:
 On Monday, 1 April 2013 at 18:44:16 UTC, Ali Çehreli wrote:
On 04/01/2013 11:37 AM, DLearner wrote:
I was trying to use writef("Escape string" ~ "Display string") to
simulate a full-screen console.  But writef doesn't seem to flush
until a newline entered (which disturbs cursor position).

I would have expected a 'flush()' function, but 'flush()' itself
produces an error (does not exist), and 'fflush()' seems to be for
file use, not for writing to a screen (stdio).

Please, how do I force a flush to stdio?
writef is a shorthand for stdout.writef because stdout is actually a FILE, so stdout.flush() should work. Ali
I tried this but got: "No property 'flush' for type '_iobuf'"
Did you import std.stdio? I tried the following and it works: import std.stdio; void main() { write("abc"); stdout.flush(); } Do you have a code snippet that you're having trouble with, so that we can look at it more carefully? It's a bit hard to tell what your problem might be without seeing the actual code.
 Sorry but please note I also posted to the GDC forum - the non-return
 from the anti-spam delay made me think this posting had failed.
This forum (d-learn) is the correct forum for posting questions about learning D. The GDC forum is for discussions specific to the GDC compiler (building the GDC compiler, bugs/issues with GDC, etc.). T -- The best compiler is between your ears. -- Michael Abrash
Apr 01 2013
parent reply "DLearner" <bm.email01 gmail.com> writes:
On Monday, 1 April 2013 at 19:01:07 UTC, H. S. Teoh wrote:
 On Mon, Apr 01, 2013 at 08:53:40PM +0200, DLearner wrote:
 On Monday, 1 April 2013 at 18:44:16 UTC, Ali Çehreli wrote:
On 04/01/2013 11:37 AM, DLearner wrote:
I was trying to use writef("Escape string" ~ "Display 
string") to
simulate a full-screen console.  But writef doesn't seem to 
flush
until a newline entered (which disturbs cursor position).

I would have expected a 'flush()' function, but 'flush()' 
itself
produces an error (does not exist), and 'fflush()' seems to 
be for
file use, not for writing to a screen (stdio).

Please, how do I force a flush to stdio?
writef is a shorthand for stdout.writef because stdout is actually a FILE, so stdout.flush() should work. Ali
I tried this but got: "No property 'flush' for type '_iobuf'"
Did you import std.stdio? I tried the following and it works: import std.stdio; void main() { write("abc"); stdout.flush(); } Do you have a code snippet that you're having trouble with, so that we can look at it more carefully? It's a bit hard to tell what your problem might be without seeing the actual code.
 Sorry but please note I also posted to the GDC forum - the 
 non-return
 from the anti-spam delay made me think this posting had failed.
This forum (d-learn) is the correct forum for posting questions about learning D. The GDC forum is for discussions specific to the GDC compiler (building the GDC compiler, bugs/issues with GDC, etc.). T
I tried your example, getting four error messages first of which was 'undefined identifier write, did you mean function fwrite?'. I am using GDC as provided with Debian 6.0.7, and my usual D write-functions are writef and writefln.
Apr 01 2013
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 04/01/2013 01:06 PM, DLearner wrote:> On Monday, 1 April 2013 at 
19:01:07 UTC

 I tried your example, getting four error messages first of which was
 'undefined identifier write, did you mean function fwrite?'.
 I am using GDC as provided with Debian 6.0.7, and my usual D
 write-functions are writef and writefln.
Is that a very old gdc, lined up perhaps with D1? Please try the latest version of dmd as well: http://dlang.org/download.html Ali
Apr 01 2013
parent reply Johannes Pfau <nospam example.com> writes:
Am Mon, 01 Apr 2013 13:26:53 -0700
schrieb Ali =C3=87ehreli <acehreli yahoo.com>:

 On 04/01/2013 01:06 PM, DLearner wrote:> On Monday, 1 April 2013 at=20
 19:01:07 UTC
=20
  > I tried your example, getting four error messages first of which
  > was 'undefined identifier write, did you mean function fwrite?'.
  > I am using GDC as provided with Debian 6.0.7, and my usual D
  > write-functions are writef and writefln.
=20
 Is that a very old gdc, lined up perhaps with D1? Please try the
 latest version of dmd as well:
=20
    http://dlang.org/download.html
=20
 Ali
=20
Looks like version 1.060: http://packages.debian.org/squeeze/gdc-4.3 So it's really quite outdated considering we don't even officially support D1 anymore.
Apr 01 2013
parent "DLearner" <bmqazwsx123 gmail.com> writes:
On Monday, 1 April 2013 at 20:32:25 UTC, Johannes Pfau wrote:
 Am Mon, 01 Apr 2013 13:26:53 -0700
 schrieb Ali Çehreli <acehreli yahoo.com>:

 On 04/01/2013 01:06 PM, DLearner wrote:> On Monday, 1 April 
 2013 at 19:01:07 UTC
 
  > I tried your example, getting four error messages first of 
 which
  > was 'undefined identifier write, did you mean function 
 fwrite?'.
  > I am using GDC as provided with Debian 6.0.7, and my usual D
  > write-functions are writef and writefln.
 
 Is that a very old gdc, lined up perhaps with D1? Please try 
 the
 latest version of dmd as well:
 
    http://dlang.org/download.html
 
 Ali
 
Looks like version 1.060: http://packages.debian.org/squeeze/gdc-4.3 So it's really quite outdated considering we don't even officially support D1 anymore.
For the record, the suggestion made from the GDC list of: fflush(stdout); worked. But of course I will now have to try to load a more recent D compiler.
Apr 02 2013