ScreenRes & Console

Windows specific questions.
slavkok
Posts: 38
Joined: Feb 10, 2009 10:11

ScreenRes & Console

Postby slavkok » Dec 24, 2009 16:08

Hello...

When I set the gfx screen with ScreenRes the console window is stil on ( I know for -gui switch)
But I want to use that console to put some data out for debugging. Is that possible? As PRINT outputs to the new graphic window.

Slavko.
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Postby phishguy » Dec 24, 2009 16:48

Code: Select all

open cons for output as #1
print #1,"Console output message"
fxm
Posts: 9178
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Postby fxm » Dec 24, 2009 16:57

I usually use 2 different methods to input / output on the text console (while the program runs in a graphic window :
- first simple method using "shell" to just output string
- second method using "open cons" to manage input/output of strings
(see also documentation)

examples of my own procedures

Code: Select all

FUNCTION Shell_Starting_Window_Print_Line (BYREF Text AS STRING) AS INTEGER
'
' Write a text line in the starting window (console window)
' even if the program runs in a graphic window
' (Text = "" allows to write an empty line,
'  and consequently equivalent to "CR" + "LF")
'
' Value (INTEGER) of function return :
'   0 : OK
'   1 : error
 
  Shell_Starting_Window_Print_Line = SHELL("ECHO." + Text)
 
END FUNCTION



FUNCTION Open_Cons_Starting_Window_Print (BYREF Text AS STRING) AS INTEGER
'
' Write a text line in the starting window (console window)
' even if the program runs in a graphic window
'   (CHR$(8), CHR$(9), CHR$(10), CHR$(13) allow to move the cursor :
'      <bs>, <tab>, <lf>, <cr>)
'
' Value (INTEGER) function return :
'   0 : OK
'   1 : error or FreeBasicVersion < 0.15

  DIM NumFile AS INTEGER
 
  Open_Cons_Starting_Window_Print = 1
  #IF __FB_VERSION__ >= "0.15"
  NumFile = FREEFILE
  Open_Cons_Starting_Window_Print = OPEN CONS(FOR OUTPUT AS #NumFile)
  PRINT #NumFile, Text;
  CLOSE #NumFile
  #ENDIF

END FUNCTION



FUNCTION Open_Cons_Starting_Window_Line_Input (BYREF Text AS STRING) AS INTEGER
'
' Wait for a string input from the starting window (console window)
' even if the program runs in a graphic window
'
' Value (INTEGER) of function return :
'   0 : OK
'   1 : error or FreeBasicVersion < 0.15

  DIM NumFile AS INTEGER
 
  Open_Cons_Starting_Window_Line_Input = 1
  #IF __FB_VERSION__ >= "0.15"
  NumFile = FREEFILE
  Open_Cons_Starting_Window_Line_Input = OPEN CONS(FOR INPUT AS #NumFile)
  LINE INPUT #NumFile, Text
  CLOSE #NumFile
  #ENDIF
 
END FUNCTION
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Postby MichaelW » Dec 24, 2009 17:05

phishguy wrote:

Code: Select all

open cons for output as #1
print #1,"Console output message"

This works, but to have both the fbgfx window and the console available it must be built as a console app (-s gui will cause the console to be hidden).
slavkok
Posts: 38
Joined: Feb 10, 2009 10:11

Postby slavkok » Dec 24, 2009 18:38

Thanks... Work just fine.

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 22 guests