`_STDOUT`, `_STDERR` methods?
Closed this issue · 4 comments
Thank you for adding _ECHO
but I've realised that it doesn't entirely solve the problems of dealing with a command-line driven app that may also have a GUI.
I'm writing PortaDOOM, a Doom launcher; it's replacing a 1500+ line batch script that manages all the parameters and calls the appropriate doom-engine.
The launcher needs to operate in a mix of two modes: if passed command-line parameters it'll need to validate those and call the desired doom-engine without having to bring up a UI. Output will need to be produced on stdout and stderr for interaction with regular batch scripts.
If provided without parameters (such as simply double-clicking the EXE file), or certain parameters, a UI needs to be presented.
Unfortunately $CONSOLE: _CONSOLE OFF
always causes a console window to appear momentarily when the executable is launched even when this is not needed. I'd prefer if this didn't happen.
A simple fix would be to specify a way to not show the console until _CONSOLE ON
is used, rather than show it by default and await a _CONSOLE OFF
command. NB: I can't use $CONSOLE:OFF as I still need to output to console if the app is called from command-line.
An alternative solution is to allow direct writing to stdout / stderr, bypassing any state of QB64's own console (including $CONSOLE:OFF
). This would be my preferred solution as, in this instance, I want to output directly to the OS and not work though QB64's console(s). I may want to capture stderr output separate from stdout in a batch file so as to not display any output from my app under batch control, unless an error occurs.
The console window is momentarily shown when it's created, and it's unfortunately an undesirable behavior we haven't been able to solve so far. You may be interested in trying to do it from a c++ header file. Checkout this wiki article: http://www.qb64.org/wiki/C_Libraries#Console_Window
Is there a chance you can defer initalising the console until it's first written to? I don't know how this works. I was going to try using the Windows API to write to stdout but I haven't look at the specifics yet.
I don't know how it works either, so we must all investigate :-)
Please be patient on that one.
Moved to https://github.com/QB64Team/qb64