Where is Print output?

Windows specific questions.
confused_john
Posts: 2
Joined: Jan 28, 2021 19:46

Where is Print output?

Postby confused_john » Jan 28, 2021 21:11

Windows 10. Where should I see the result of Print?
I have the IDE, an upper pane with a vertical bar halfway across which does not appear to be significant. A lower pane 'Results Window"
Print "Hello World" compiles and runs but I cannot see where it is printed.
John
MrSwiss
Posts: 3827
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Where is Print output?

Postby MrSwiss » Jan 29, 2021 4:00

Code: Select all

Print "Hello World from FreeBASIC"
Sleep   ' keep console open until user action
confused_john
Posts: 2
Joined: Jan 28, 2021 19:46

Re: Where is Print output?

Postby confused_john » Jan 29, 2021 10:18

That's the answer, thank you. In the meantime I had discovered that if I ran the executable from DOS I could see the output.
Thanks again, John
Macq
Posts: 8
Joined: Feb 18, 2021 4:01
Location: Queensland, Australia

Re: Where is Print output?

Postby Macq » Feb 18, 2021 4:27

Something that I have noticed while learning the Win32API: If you compile for GUI and then use "print" statements, the output can be seen if you launch your program from a cygwin terminal, but not if you do so from a CMD window. The GUI part of your program runs as normal. It's useful for debugging.

Here's me experimenting with a vertical scroll bar attached to a text window:

/cygdrive/g/My_DOCS/FreeBasicProjects/TestScroll $ ./TestScroll.exe
yChar = 16 nDispLines= 18 VscrollPos@si= 0
yChar = 16 nDispLines= 18 VscrollPos@si= 0


You can also compile for console and then you get a GUI and a console window with your print output in it.
dodicat
Posts: 6950
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Where is Print output?

Postby dodicat » Feb 18, 2021 17:36

You can use puts if you
#include "crt.bi"
puts or printf always prints to the console.
Vortex
Posts: 48
Joined: Sep 19, 2005 9:50

Re: Where is Print output?

Postby Vortex » May 14, 2021 7:58

Hi John,

You could also try the WriteFile API function. FreeBASIC's Print command is the best option to send the output to the console.

Code: Select all

#include "windows.bi"

Public Function StdOut ( Zstr As Zstring Ptr) As Integer

Dim As HANDLE hOutput
Dim As DWORD bWritten

hOutput=GetStdHandle(STD_OUTPUT_HANDLE)

WriteFile(hOutPut,Zstr,lstrlen(ZStr),@bWritten,NULL)

Function=bWritten

End Function


Dim As String test

test="This is a test."

StdOut test
jj2007
Posts: 2146
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Where is Print output?

Postby jj2007 » May 14, 2021 9:08

While developing a GUI application, it is often useful to have a console, too, so that you can print debugging info.

Unfortunately *), most IDEs are unable to autodetect if there is a Sleep (without args) command at the end of the code; otherwise, they could keep the console window open until the user closes it, and we would not see once a month desperate posts by new members complaining that they don't see their "Hello World".

*) I write this for the numerous IDE developers in this forum ;-)
counting_pine
Site Admin
Posts: 6287
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: Where is Print output?

Postby counting_pine » May 14, 2021 13:57

Yeah, having the option to keep the window open after the program has finished is often useful. More reliable and cleaner than putting Sleep at the end of runnable code.
It was achievable in FBIDE by tweaking the Run command.
PaulSquires
Posts: 899
Joined: Jul 14, 2005 23:41

Re: Where is Print output?

Postby PaulSquires » May 14, 2021 15:51

WinFBE has a similar functionality. Under 'Environment Options', 'Compiler Setup', check the box "Run compiled programs using command window".
I believe I added this functionality based on a request from fxm way back in version 1.3.9 in July 2017. Hope this helps those who use WinFBE but may not be aware of this functionality.
badidea
Posts: 2333
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Where is Print output?

Postby badidea » May 14, 2021 20:24

Geany also does this by default with the text "Press any key to continue . . ."
Xusinboy Bekchanov
Posts: 402
Joined: Jul 26, 2018 18:28

Re: Where is Print output?

Postby Xusinboy Bekchanov » May 15, 2021 0:33

I use this functionality too.
To do this, in the VisualFBEditor parameters in the Run item, I select cmd or PowerShell. At the end of debugging, it will not close without this parameter either.
jj2007
Posts: 2146
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Where is Print output?

Postby jj2007 » May 15, 2021 7:48

In case somebody is interested in detecting console vs gui automatically, here are the strings I use in RichMasm:

Code: Select all

txGuess   db "key", 0   ; Inkey, inkey, getkey but not GetKeyState
   db "rint", 0   ; ok for print and Print
   db "MemState", 0   ; console only macro
   db "StdOut", 0
;    db "Input$", 0   ; MasmBasic console input; ambiguous because there is Input$(#1...
   db "deb 4", 0, 0   ; second zero marks end of console keywords
   db "Print #", 0   ; print to file does not need a console
   db "ntRtf", 0, "ntRtf", 0   ; same for a true printer
   db "WM_", 0, "WM_", 0   ; 2*WM_COMMAND, WM_CHAR, WM_CREATE, WM_CLOSE
   db "Box", 0   ; MessageBox, MsgBox
   db "wMsg", 0
   db "Gui", 0, "Gui", 0   ; 2xGuiImage, GuiControl etc
   db "SendMessage", 0
   db "CreateWindow", 0
   db "GetMessage", 0
   db "ShowWindow", 0
   db "SW_", 0, "hW", 0   ; SW_xxx and hWnd or hWin
   db "LoadI", 0   ; LoadIcon, LoadImage
   db "dcSta", 0   ; dcStatic
   db "Image", 0   ; typically found in graphics apps
   db "WinMain", 0   ; Pelles C
   db "Dlg", 0, 0   ; second zero is end marker

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 2 guests