[Gambas-user] commandline output redirect?

Benoit Minisini gambas at ...1...
Wed May 21 14:36:55 CEST 2008


On mercredi 21 mai 2008, Ron wrote:
> Benoit Minisini schreef:
> > On mercredi 21 mai 2008, Ron wrote:
> >> Hi,
> >>
> >> If you create a gambas command line application with a loop in it,
> >> standard output cannot be redirected to a file.
> >>
> >> This works:
> >> -----------------------------------
> >> PUBLIC SUB Main()
> >>   PRINT "test output"
> >> END
> >>
> >> ./test.gambas >test.log
> >> cat test.log
> >> test output
> >>
> >> This doesn't work:
> >> ------------------------------------
> >> PUBLIC SUB Main()
> >>   PRINT "test output"
> >>   WHILE (1)
> >>     'do something
> >>     WAIT 1
> >>   WEND
> >> END
> >>
> >> ./test.gambas >test.log
> >> CTRL-C
> >> test.log is empty
> >> ------------------------------------
> >> Unbuffered printing to default output (with Write "test output")  gives
> >> the same result.
> >>
> >>
> >> Gambas 2.6.0
> >>
> >> Regards,
> >> Ron.
> >
> > Where did you see that WRITE is unbuffered and PRINT is buffered?
>
> Benoit ,
>
> here: http://gambasdoc.org/help/lang/open
>
> next to the ! mark
>

The warning talks about the keyword you add to the OPEN instruction, not to 
the READ and WRITE instructions.

> > Standard output and standard error output are both buffered, whatever
> > stream instruction or function you use.
> >
> > If you want to flush a buffered output stream, just use the FLUSH
> > instruction. I suggest you read the documentation on Gambas File I/O
> > functions.
>
> I'm flushing now inside my loop every now and then, that seems to work.
>
> Is it possible to catch keyboard input while running command line app?
> Sorry for the questions, but my app is using alot of different command
> and routines.

See http://gambasdoc.org/help/comp/gb/application/.read

Regards,

-- 
Benoit Minisini




More information about the User mailing list