GLBasic forum

Main forum => GLBasic - en => Topic started by: spacefractal on 2018-Jan-18

Title: STDOUT does not working?
Post by: spacefractal on 2018-Jan-18
Im a doing a little pixel palette application to convert images to Spectrum Next, so im need the graphics video. but when that is used, then STDOUT does NOT work at all. Its does nothing at all, and im have no idea how to declare __AllocConsole() to been send to the commandpromth when running from there or from a bat file.
Title: Re: STDOUT does not working?
Post by: bigsofty on 2018-Jan-18
I'm still on 14.x and it works fine for me on Windows & Android. Have you tried it via inline? It may be redirected to a debug log?
Title: Re: STDOUT does not working?
Post by: dreamerman on 2018-Jan-18
Never tried STDOUT in console app but it should work, despite that some time ago I noticed that GLB closes out buffer (or whatever it's called) only after app ends. So to catch STDOUT in my editor I use this work-around:
Code (glbasic) Select

INLINE
        }
                extern "C" {
                        #include <cstdio>
                }
        namespace __GLBASIC__ {
ENDINLINE

FUNCTION stdout_fix:
        INLINE
                setbuf(stdout, NULL);
        ENDINLINE
ENDFUNCTION

Don't put this into main source file, call 'stdout_fix()' after load/init, and should work, also for bat files, so you can do 'path/app.exe >> out.txt' in cmd.