BASIC

Author Topic: STDOUT does not working?  (Read 504 times)

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3482
    • View Profile
    • Space Fractal
STDOUT does not working?
« 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.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2542
    • View Profile
Re: STDOUT does not working?
« Reply #1 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?
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline dreamerman

  • Mr. Polyvector
  • ***
  • Posts: 208
    • View Profile
    • my personal website
Re: STDOUT does not working?
« Reply #2 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.
Check my source code editor for GLBasic - link