Print Function when using Console

Just starting out? Need help? Post your questions and find answers here.
Brian W
New User
New User
Posts: 5
Joined: Sat Jan 07, 2023 1:18 pm

Print Function when using Console

Post by Brian W »

I have been using PureBasic to run Engineering algorithms that have the inputs specified in the Programs. The output comes up on the Debug Screen OK.
Tried to use the input and print functions to display on the Console. But, no luck. Programs execute to end ok but do not show inputs or outputs.
Even the following simple program from the Help Section will not work.

If OpenConsole()
Print (" Press enter to exit")
Input ()
CloseConsole ()
EndIf
End

Any suggestions would be appreciated.

Brian W
BeePee
New User
New User
Posts: 1
Joined: Mon Jan 30, 2023 9:53 am

Re: Print Function when using Console

Post by BeePee »

Hello,

What is your version of PureBasic?
What OS are you working on?

Could you test with an error handler?

This is an example :

Procedure ErrorHandler()
MessageRequester("Test OnError", "Error: " + ErrorMessage())
; or
;Debug ("Error: " + ErrorMessage())
EndProcedure

OnErrorCall(@ErrorHandler())

If OpenConsole()
Print (" Press enter to exit")
Input ()
CloseConsole ()
EndIf
End

Best regards. BeePee
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Print Function when using Console

Post by Fred »

Did you compile with the executable type set to 'Console' if you use Windows ?
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

Re: Print Function when using Console

Post by Lord »

Code: Select all

If OpenConsole()
Print (" Press enter to exit")
Input ()
CloseConsole ()
EndIf
This snippet shows here the text in- and output,
regardless wich compiler is chosen or executeable-
format is set to 'console' or 'windows'.
Tested with PB 5.73 LTS, PB 6.00 LTS ASM- and
PB 6.00 LTS C backend.
All tested with in Windows x64.
Image
User avatar
Janni
Enthusiast
Enthusiast
Posts: 127
Joined: Mon Feb 21, 2022 5:58 pm
Location: Norway

Re: Print Function when using Console

Post by Janni »

If Brian W are using Linux he needs to set the executable format to 'Console' in Compiler Options.
Spec: Linux Mint 20.3 Cinnamon, i7-3770K, 16GB RAM, RTX 2070 Super
Brian W
New User
New User
Posts: 5
Joined: Sat Jan 07, 2023 1:18 pm

Re: Print Function when using Console

Post by Brian W »

As usual thanks for help on my problem. I run a Mac Mini M1 with latest version of PureBasic for Mac OS.
In short, changing the Compiler Options from MacOS to Console solves the problem and i can now Text In and Text Out.
I found out that I need to do this everytime that I start a program as the Compiler Option reverts to Mac OS on startup.

Brian W
Australia
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Print Function when using Console

Post by Shardik »

Brian W wrote: Thu Feb 02, 2023 1:48 am I found out that I need to do this everytime that I start a program as the Compiler Option reverts to Mac OS on startup.
You may change the default "MacOS" to "Console" in the Preferences:
- In the menu of the IDE click onto "PureBasic > Preferences..."
- Click onto "Compiler > Defaults"
- In the dropdown box behind "Executable format:" select "Console"
- Click onto "OK"
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Print Function when using Console

Post by mk-soft »

Normally, this information is stored in the pb file. Unless you have disabled this function in options / preferences.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply