Just hit enter to end the program. Works fine in the IDE. But compile and run the .EXE and instead of closing the program it starts a whole new instance of the program so that I have two consoles open.
; Important Remark (borrowed from Help):
;
; On Microsoft Windows, there are two different executable formats: Win32 and Console.
; If you want to create a standard console application, like 'dir', 'del' etc. you must compile
; the executable using the 'Console' format (Compiler Option menu in the PureBasic IDE).
;
; On Linux and OS X, there is no special Console format however setting the Compiler option
; to 'Console' will launch a terminal window automatically when you run your program from the IDE.
;
Define name$
If OpenConsole() ; if result is 0, it has failed and all further call to console functions must be disabled.
Print("Please enter your name: ") ; Ask for name
name$ = Input() ; Wait for user input
PrintN("Hello " + name$)
PrintN("")
; PrintN("Press return to exit")
PrintN("Press return to close console")
Input() ; Wait for Enter/Return Key pressed by user w/o any other keys before
CloseConsole()
EndIf
; acc. to help:
;
; End .. Ends the program execution correctly.
; The 'ExitCode' optional parameter can be specified if the program need to returns an error code.
;
End ;ExitCode
Just because it worked doesn't mean it works. PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Sorry about the out of place CloseConsole(). Just threw together minimum code to show the problem and brain****** it.
Compiling for console did fix it. But I still wonder about why it started up a whole new console window. That's just weird. I was thinking it was choking on a zero length string. Purebasic does not seem to have zero length strings.