Opening a console?

Linux specific forum
Joubarbe
Enthusiast
Enthusiast
Posts: 555
Joined: Wed Sep 18, 2013 11:54 am
Location: France

Opening a console?

Post by Joubarbe »

Code: Select all

OpenConsole()

PrintN("Blah blah!")

Delay(5000)
That should work even if the program is not compiled in "Console" mode, right?
I'm on a Pixelbook, with the Linux beta stuff, and I cannot manage to open a console. Would be useful to do some unit tests.

Thanks.
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: Opening a console?

Post by Sicro »

I once wished for this feature too and Fred implemented it, but in a later PureBasic (beta?) version he removed it again, because it probably caused problems.

I can not find my feature request here in the forum anymore. He apparently deleted the request after he integrated the feature.
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Joubarbe
Enthusiast
Enthusiast
Posts: 555
Joined: Wed Sep 18, 2013 11:54 am
Location: France

Re: Opening a console?

Post by Joubarbe »

Hmm? That’s a bit strange, Linux is mentioned in the OpenConsole() documentation page, and it even returns 1, so I think it should work and the problem comes from something else, like a missing package or a denied access?
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1243
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Opening a console?

Post by Paul »

From HELP file...
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.
When I test on both Linux and MacOS it works as the help file says.
Image Image
Joubarbe
Enthusiast
Enthusiast
Posts: 555
Joined: Wed Sep 18, 2013 11:54 am
Location: France

Re: Opening a console?

Post by Joubarbe »

Doesn’t work either.
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: Opening a console?

Post by Marc56us »

Hi all,

An answer to this old topic, because I found a solution while looking for a solution to a question on the Fr forum.

A linux application (compiled for console mode) opens a console from the IDE (after F5) only if xterm is installed.

I didn't find where this is configured, so I couldn't change this ($TERM doesn't seem to be used).

Modern distributions no longer install xterm by default, so:
debian base (ubuntu etc)

Code: Select all

$ sudo apt install xterm
Slackware

Code: Select all

$ slackpkg install xterm
Tested on PB 6.00 x64 on ubuntu and Slackware (with xfce). Test your own configuration if different.

Hope this helps
:wink:

If this setting is in the IDE code it should be possible to change it? Ideally using the $TERM system variable would allow everyone to use their terminal.

Edit: Searching through the IDE source code (purebasic-devel\PureBasicIDE\LinuxMisc.pb
Line 135) on GitHub and testing, it appears that the IDE is looking for one of the terms in order: gnome-terminal, konsole, aterm, mlterm, rxvt, xterm (?). Installing some of then then console output opens in first of them installed.
User avatar
W4GNS
User
User
Posts: 31
Joined: Tue Jan 04, 2011 5:51 am
Location: Virginia

Re: Opening a console?

Post by W4GNS »

Marc56us wrote: Wed Jul 27, 2022 3:00 pm Hi all,

An answer to this old topic, because I found a solution while looking for a solution to a question on the Fr forum.

A linux application (compiled for console mode) opens a console from the IDE (after F5) only if xterm is installed.

I didn't find where this is configured, so I couldn't change this ($TERM doesn't seem to be used).
Thank you! You have saved me a great deal of hair pulling. A note should be added to the help file
Post Reply