Console Input/Output at Console Application

Windows specific questions.
Post Reply
mossbruc
Posts: 3
Joined: Sep 29, 2023 22:48

Console Input/Output at Console Application

Post by mossbruc »

Hello everyone,
I'm ripping my hair out and cannot figure it out. I apologize if this has already been answered, but I couldn't find an answer:

Problem: Freebasic 1.09 64 bit version running on Windows 10

A console application started from a CMD window that does not create another screen: How do I output to the CMD window?

I have tried the example from the Wiki:

Code: Select all

Dim a As String

Open Cons For Input As #1
Open Cons For Output As #2

Print #2,"Please write something and press ENTER"
Line Input #1,a
Print #2, "You wrote : ";a

Close
Sleep
Doesn't work when started from CMD window.
Imortis
Moderator
Posts: 1926
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Console Input/Output at Console Application

Post by Imortis »

With a console application there is no need to do anything fancy to write to the console.

Code: Select all

Dim a As String

Line Input  "Please write something and press ENTER"; a
Print "You wrote : ";a

Sleep
Lothar Schirm
Posts: 438
Joined: Sep 28, 2013 15:08
Location: Germany

Re: Console Input/Output at Console Application

Post by Lothar Schirm »

Hi mosbruc,
the code from the example from the Wiki is used if you are running some stuff on an a grafics screen and you want to do something addional on the console. "Open Cons" can e.g. be used to display test messages on the console for debugging purposes if your program is running on a grafics screen or if you run a GUI application (using Windows API, FLTK or an other GUI library).
mossbruc
Posts: 3
Joined: Sep 29, 2023 22:48

Re: Console Input/Output at Console Application

Post by mossbruc »

Hello,

thank you for the response, but this does not work!

Compiling this using FbEdit using the following compiler options:

Code: Select all

fbc -s console -t 64000
and then running the resulting executable within a CMD window in Windows 10 does not prodice any output.
What am I doing wrong here?
mossbruc
Posts: 3
Joined: Sep 29, 2023 22:48

Re: Console Input/Output at Console Application

Post by mossbruc »

Hello everyone,

I figure it out. Somehow the wrong compiling options were selected (-s gui instead of -s console); total user error..

Cheers

Joerg
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Console Input/Output at Console Application

Post by caseih »

EDIT: I didn't see the message that you have it figured out.
Post Reply