Console off
Console off
Hello,
when working with a graphical user interface and you do not need the "console" window, is there an instruction to close this console window in Freebasic. I did not find in the documentation
thank you
when working with a graphical user interface and you do not need the "console" window, is there an instruction to close this console window in Freebasic. I did not find in the documentation
thank you
Re: Console off
Last edited by MrSwiss on Jun 28, 2019 16:22, edited 1 time in total.
Re: Console off
You can use switch -s gui.
Example:
fbc -s gui myfile.bas
But make sure that myfile.bas is graphical, otherwise you might need the task manager to kill it.
(Sorry Mr Swiss, I didn't see your answer)
Example:
fbc -s gui myfile.bas
But make sure that myfile.bas is graphical, otherwise you might need the task manager to kill it.
(Sorry Mr Swiss, I didn't see your answer)
-
- Posts: 556
- Joined: Mar 10, 2007 15:44
- Location: Ohio, USA
- Contact:
Re: Console off
Just a side note.
On many IDE's, when using the "Quick Run" option, it leaves the console window up for any "debugging" printing. But in the compiled exe will not have a console window.
On many IDE's, when using the "Quick Run" option, it leaves the console window up for any "debugging" printing. But in the compiled exe will not have a console window.
Re: Console off
If you are writing code for windows it can be done inside the code.(Without any compiler switches)
Example:
Example:
Code: Select all
declare function hideconsole alias "FreeConsole"() as boolean
declare function showconsole alias "AllocConsole"() as boolean
screen 19
hideconsole
print "Press a key for console"
sleep
showconsole
sleep
Re: Console off
I tried the first solution using the compiler options and it works perfectly.
better, the calculations made by the program (it is a calculation program) are carried out with a saving of time of 10%.
I will try the 2nd solution a little later in the evening.
Thank you very much to all .
better, the calculations made by the program (it is a calculation program) are carried out with a saving of time of 10%.
I will try the 2nd solution a little later in the evening.
Thank you very much to all .
Re: Console off
Indeed he would be using Windows because in no other operating system would it make sense to be talking about hiding the console. Windows is the only operating system that makes distinctions between console and GUI applications and has special console windows. However Microsoft is finally changing and modernizing the console system, including a proper terminal emulator, and hopefully a revamping of the console mechanism, making it more unix-like finally. The way things should works is that anything written to standard only ends up in a console window if the program is run from a command prompt.
Nearly all Linux applications write to standard out and standard error for a variety of reasons, mostly debugging and information. But most people never see them because they launch apps directly from the desktop, so they have nothing attached to stdout and stderr. Hopefully the Windows console subsystem will eventually work like that.
Maybe it's no longer like this, but at one point, I found that if my program outputed anything to standard out, even as a GUI app, Windows would popup a console window. So I had to remove anything that printed anything to standard out. But that was years ago.
I'm skeptical that hiding the console window sped up your program by 10%, although it is possible. The Windows console is horribly slow. Why did turning off the console window increase your speed?
Nearly all Linux applications write to standard out and standard error for a variety of reasons, mostly debugging and information. But most people never see them because they launch apps directly from the desktop, so they have nothing attached to stdout and stderr. Hopefully the Windows console subsystem will eventually work like that.
Maybe it's no longer like this, but at one point, I found that if my program outputed anything to standard out, even as a GUI app, Windows would popup a console window. So I had to remove anything that printed anything to standard out. But that was years ago.
I'm skeptical that hiding the console window sped up your program by 10%, although it is possible. The Windows console is horribly slow. Why did turning off the console window increase your speed?
Re: Console off
I do not know why, but actually the execution of calculations is a little faster.
the program displays intermediate calculation results on the console. I think that removing the console should eliminate these displays and thus save some time.
I will do other tests with longer calculations to better measure the calculation times and make sure that there is a gain in all cases.
the program displays intermediate calculation results on the console. I think that removing the console should eliminate these displays and thus save some time.
I will do other tests with longer calculations to better measure the calculation times and make sure that there is a gain in all cases.
Re: Console off
Does anybody know how to suppress console window by using switches for -gen gcc compiler parameter?
@dodicat: thanks for tip
@dodicat: thanks for tip
dodicat wrote:If you are writing code for windows it can be done inside the code.(Without any compiler switches)
Example:Code: Select all
declare function hideconsole alias "FreeConsole"() as boolean declare function showconsole alias "AllocConsole"() as boolean screen 19 hideconsole print "Press a key for console" sleep showconsole sleep
Re: Console off
The same flag should work for the GCC backend as the ASM one. If not, I'd say that's a bug.
Re: Console off
No bug, works like a charm, both FBC's 32/64 bit.caseih wrote:If not, I'd say that's a bug.
It does, the question was a dumb one, because the two switches don't influencecaseih wrote:The same flag should work for the GCC backend as the ASM one.
each other, in any way (-s specifier is in any case, Windows only).
Re: Console off
Okay right. The console or gui flag is a linker flag too, not a compiler flag. I know most FB programmers don't use multiple modules and makefiles, but if you did, you wouldn't have to recompile anything to hide the gui; just re-link it with the subsystem flag you want.
Re: Console off
Sorry, I think I didn't express it properly. Of course the code works with -gen gcc properly but what I want to know is if there is a command line switch argument for gcc to set the linker not to show the console window by default.caseih wrote:The same flag should work for the GCC backend as the ASM one. If not, I'd say that's a bug.
Re: Console off
No, the default setting is console (if the -s switch is omitted, too).UEZ wrote:... command line switch argument for gcc to set the linker not to show the console window by default.
It's also a somewhat dangerous setting, in case of running a console job even
once in a while, only ...
See first comment from dodicat, earlier in this thread, for reasons.
Re: Console off
GCC itself uses the flag "-mwindows" which it passes to the linker.UEZ wrote:Sorry, I think I didn't express it properly. Of course the code works with -gen gcc properly but what I want to know is if there is a command line switch argument for gcc to set the linker not to show the console window by default.