Print output in a CMD window issue

Windows specific questions.
Post Reply
UEZ
Posts: 1028
Joined: May 05, 2017 19:59
Location: Germany

Print output in a CMD window issue

Post by UEZ »

When I compile and run this

Code: Select all

Dim as String sVer = "v0.0"
	Dim As UByte iTab = 25
	Cls
	? "Radio Station remix.kwed.org " & sVer
	?
	? "Radio Station remix.kwed.org is a simple console app that streams music from remix.kwed.org"
	?
	? "By default it plays songs randomly."
	?
	? "Keys:"
	? "* Backspace to play current song again"
	? "* Space to skip current song"
	? "* p to pause or resume current song (toggle)"
	? "* e to play current song endless (infinite loop) (toggle)"
	? "* g to enable / disable glass effect (only if DWM composition (aka Aero) is enabled) (toggle)"
	? "* t to set console window topmost or not (toggle)"
	? "* +, -, or up, down to increase / decrease volume level"
	? "* 0 to play songs randomly again"
	? "* 1 to play from latest to oldest song"
	? "* d to download current song to disk (remix.kwed.org folder in current dir)"
	? "* b to play from current song to oldest song"
	? "* f to play from current song to latest song"
	? "* z to enable / disable 3-band equilizer"
	? "* right to forward song for 5 seconds"
	? "* left to rewind song for 5 seconds"
	? "* ESC or q to exit"
	?
	? "Command-line parameter:"
	? "/NoLevel"; Tab(iTab);   	            "-> disable sound level color flash"
	? "/Order [0-2]"; Tab(iTab); 	        "-> plays the songs 0 = random, 1 = from latest to oldest, 2 = from oldest to latest"
	? "/Cfg [0-15]"; Tab(iTab);	            "-> set text color"
	? "/Cbg [0-15]"; Tab(iTab);	            "-> set background color"
	? "/Number [1-max]"; Tab(iTab);         "-> plays the song hosted with the number, max is the latest song number," 
	? Tab(iTab);	    			        "   can be used with /Top50"
	? "/NoAutoSwitchDevice"; Tab(iTab);     "-> disable automatically switch over when the system's default audio device"
	? Tab(iTab);					        "   setting changes"
	? "/Proxy [address]"; Tab(iTab);        "-> the proxy address to use (either ip adress or DNS name)"
	? "/Glass"; Tab(iTab);				    "-> enables glass effect on console window only if DWM composition (aka Aero) is enabled"
	? "/Topmost"; Tab(iTab);			    "-> places the console window above all non-topmost windows"
	? "/Top50"; Tab(iTab);				    "-> plays the Top50 songs from first to last placed"
	? "/Top50Dir [-1, 1]"; Tab(iTab);	    "-> if 1 (default) plays the titles ascending otherwise descending"
	?  Tab(iTab); 					        "   only available when /Top50 is set!"
	? "/PU2R [n]"; Tab(iTab);		  	    "-> plays songs only ranked n or better (available only in random play mode)"
	? "/Font [""fontname""]"; Tab(iTab);    "-> change the default font Consolas to new font"
	? "/Font [""fontname""]"; Tab(iTab);    "-> change the default font Consolas to new font"
	? "/Eq_bass [gain]"; Tab(iTab);         "-> equalizer bass gain value. Must be between -15 to 15"
	? "/Eq_mid [gain]"; Tab(iTab);          "-> equalizer mid gain value. Must be between -15 to 15"
	? "/Eq_treb [gain]"; Tab(iTab);         "-> equalizer treble gain value. Must be between -15 to 15"
	? "/Eq_frb [frequence]"; Tab(iTab);     "-> equalizer bass frequence value. Must be between 80 Hz to 16000 Hz"
	? "/Eq_frm [frequence]"; Tab(iTab);     "-> equalizer mid frequence value. Must be between 80 Hz to 16000 Hz"
	? "/Eq_frt [frequence]"; Tab(iTab);     "-> equalizer treble frequence value. Must be between 80 Hz to 16000 Hz"
	?
	? "Examples: "
	? """Radio Station remix.kwed.org.exe"" /cfg 7 /cbg 1 /order 1 /glass"
	? """Radio Station remix.kwed.org.exe"" /top50 /number 50 /top50dir -1"


Sleep
then the output cmd window has no vertical scrollbar and the text above "Command-line parameter:" line cannot be seen. Even if it is started in the cmd directly and vertical scrollbar is visible, the text above "Command-line parameter:" is not visible.

Image

With Windows 10 no issues.

My os: Windows 11 23H2 build 22631.4602

Can you please test on your Win11 system if the behavior is the same?

When I run "Dir" in cmd then no issues.

Thx.
Lothar Schirm
Posts: 477
Joined: Sep 28, 2013 15:08
Location: Germany

Re: Print output in a CMD window issue

Post by Lothar Schirm »

Do you use the windows terminal? See https://www.freebasic.net/forum/viewtopic.php?t=32969
UEZ
Posts: 1028
Joined: May 05, 2017 19:59
Location: Germany

Re: Print output in a CMD window issue

Post by UEZ »

Well, it's the cmd window on the tab, as you can see in the screenshot which was started from the Run window. The behavior is kind of strange because the print out from other commands such as "cmd /?" is properly displayed.
Lothar Schirm
Posts: 477
Joined: Sep 28, 2013 15:08
Location: Germany

Re: Print output in a CMD window issue

Post by Lothar Schirm »

I have given up to struggle with the terminal in Windows 11 (I never used Windows 10, my previous version was 8.1). I have set the standard terminal application to "Console Host", and it works.
dodicat
Posts: 8189
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Print output in a CMD window issue

Post by dodicat »

printf(...) does OK from crt.bi.
It will scroll vertically.
fb print is not good with the win 11 terminal, it will not scroll
settings/system/for developers/terminal+ windows console host will give back the old command window we have been using.
UEZ
Posts: 1028
Joined: May 05, 2017 19:59
Location: Germany

Re: Print output in a CMD window issue

Post by UEZ »

I know that in Windows you can change the setting that CMD is defined as default, but I am looking at this from a developer's point of view, i.e. by default the terminal is unfortunately set as default and cannot tell the user what to define as default just because the output does not work properly.

I also find it challenging to find a programming solution instead of tinkering with the Windows settings.

@dodicat: thanks I will try it for this part of the code.

Maybe there is "bug" in code for Print / ? for Windows 11 because print outs from Windows apps in that CMD box work properly.

Edit: with printf(!"Text") works properly.
dodicat
Posts: 8189
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Print output in a CMD window issue

Post by dodicat »

You could do this to preserve tab which printf or puts doesn't do.

Code: Select all

open cons for output as #1
Dim as String sVer = "v0.0"
	Dim As UByte iTab = 25
	Cls
	?  #1, "Radio Station remix.kwed.org " & sVer
	?  #1,
	?  #1, "Radio Station remix.kwed.org is a simple console app that streams music from remix.kwed.org"
	?  #1,
	?  #1, "By default it plays songs randomly."
	?  #1,
	?  #1, "Keys:"
	?  #1, "* Backspace to play current song again"
	?  #1, "* Space to skip current song"
	?  #1, "* p to pause or resume current song (toggle)"
	?  #1, "* e to play current song endless (infinite loop) (toggle)"
	?  #1, "* g to enable / disable glass effect (only if DWM composition (aka Aero) is enabled) (toggle)"
	?  #1, "* t to set console window topmost or not (toggle)"
	?  #1, "* +, -, or up, down to increase / decrease volume level"
	?  #1, "* 0 to play songs randomly again"
	?  #1, "* 1 to play from latest to oldest song"
	?  #1, "* d to download current song to disk (remix.kwed.org folder in current dir)"
	?  #1, "* b to play from current song to oldest song"
	?  #1, "* f to play from current song to latest song"
	?  #1, "* z to enable / disable 3-band equilizer"
	?  #1, "* right to forward song for 5 seconds"
	?  #1, "* left to rewind song for 5 seconds"
	?  #1, "* ESC or q to exit"
	?  #1,
	?  #1, "Command-line parameter:"
	?  #1, "/NoLevel"; Tab(iTab);   	            "-> disable sound level color flash"
	?  #1, "/Order [0-2]"; Tab(iTab); 	        "-> plays the songs 0 = random, 1 = from latest to oldest, 2 = from oldest to latest"
	?  #1, "/Cfg [0-15]"; Tab(iTab);	            "-> set text color"
	?  #1, "/Cbg [0-15]"; Tab(iTab);	            "-> set background color"
	?  #1, "/Number [1-max]"; Tab(iTab);         "-> plays the song hosted with the number, max is the latest song number," 
	?  #1, Tab(iTab);	    			        "   can be used with /Top50"
	?  #1, "/NoAutoSwitchDevice"; Tab(iTab);     "-> disable automatically switch over when the system's default audio device"
	?  #1, Tab(iTab);					        "   setting changes"
	?  #1, "/Proxy [address]"; Tab(iTab);        "-> the proxy address to use (either ip adress or DNS name)"
	?  #1, "/Glass"; Tab(iTab);				    "-> enables glass effect on console window only if DWM composition (aka Aero) is enabled"
	?  #1, "/Topmost"; Tab(iTab);			    "-> places the console window above all non-topmost windows"
	?  #1, "/Top50"; Tab(iTab);				    "-> plays the Top50 songs from first to last placed"
	?  #1, "/Top50Dir [-1, 1]"; Tab(iTab);	    "-> if 1 (default) plays the titles ascending otherwise descending"
	?  #1,  Tab(iTab); 					        "   only available when /Top50 is set!"
	?  #1, "/PU2R [n]"; Tab(iTab);		  	    "-> plays songs only ranked n or better (available only in random play mode)"
	?  #1, "/Font [""fontname""]"; Tab(iTab);    "-> change the default font Consolas to new font"
	?  #1, "/Font [""fontname""]"; Tab(iTab);    "-> change the default font Consolas to new font"
	?  #1, "/Eq_bass [gain]"; Tab(iTab);         "-> equalizer bass gain value. Must be between -15 to 15"
	?  #1, "/Eq_mid [gain]"; Tab(iTab);          "-> equalizer mid gain value. Must be between -15 to 15"
	?  #1, "/Eq_treb [gain]"; Tab(iTab);         "-> equalizer treble gain value. Must be between -15 to 15"
	?  #1, "/Eq_frb [frequence]"; Tab(iTab);     "-> equalizer bass frequence value. Must be between 80 Hz to 16000 Hz"
	?  #1, "/Eq_frm [frequence]"; Tab(iTab);     "-> equalizer mid frequence value. Must be between 80 Hz to 16000 Hz"
	?  #1, "/Eq_frt [frequence]"; Tab(iTab);     "-> equalizer treble frequence value. Must be between 80 Hz to 16000 Hz"
	?  #1,
	?  #1, "Examples: "
	?  #1, """Radio Station remix.kwed.org.exe"" /cfg 7 /cbg 1 /order 1 /glass"
	?  #1, """Radio Station remix.kwed.org.exe"" /top50 /number 50 /top50dir -1"
close #1

Sleep  
UEZ
Posts: 1028
Joined: May 05, 2017 19:59
Location: Germany

Re: Print output in a CMD window issue

Post by UEZ »

I used this approach:

Code: Select all

#include "crt.bi"
#define CRLF !"\r\n"
#define sTab !"\t"
Dim As String sVer = "v0.63 build 2025-01-07 beta"
	
	Cls
	printf(!"Radio Station remix.kwed.org " & sVer & CRLF)
	printf(CRLF)
	printf(!"Radio Station remix.kwed.org is a simple console app that streams music from remix.kwed.org" & CRLF)
	printf(CRLF)
	printf(!"By default it plays songs randomly." & CRLF)
	printf(CRLF)
	printf(!"Keys:" & CRLF)
	printf(!"* Backspace to play current song again" & CRLF)
	printf(!"* Space to skip current song" & CRLF)
	printf(!"* p to pause or resume current song (toggle)" & CRLF)
	printf(!"* e to play current song endless (infinite loop) (toggle)" & CRLF)
	printf(!"* g to enable / disable glass effect (only if DWM composition (aka Aero) is enabled) (toggle)" & CRLF)
	printf(!"* t to set console window topmost or not (toggle)" & CRLF)
	printf(!"* +, -, or up, down to increase / decrease volume level" & CRLF)
	printf(!"* 0 to play songs randomly again" & CRLF)
	printf(!"* 1 to play from latest to oldest song" & CRLF)
	printf(!"* d to download current song to disk (remix.kwed.org folder in current dir)" & CRLF)
	printf(!"* b to play from current song to oldest song" & CRLF)
	printf(!"* f to play from current song to latest song" & CRLF)
	printf(!"* z to enable / disable 3-band equilizer" & CRLF)
	printf(!"* right to forward song for 5 seconds" & CRLF)
	printf(!"* left to rewind song for 5 seconds" & CRLF)
	printf(!"* ESC or q to exit" & CRLF)
	printf(CRLF)
	printf(!"Command-line parameter:" & CRLF)
	printf(!"/NoLevel" & sTab &	sTab &		    "-> disable sound level color flash" & CRLF)
	printf(!"/Order [0-2]" & sTab & sTab &      "-> plays the songs 0 = random, 1 = from latest to oldest, 2 = from oldest to latest" & CRLF)
	printf(!"/Cfg [0-15]" & sTab & sTab &       "-> set text color" & CRLF)
	printf(!"/Cbg [0-15]" & sTab & sTab &	    "-> set background color" & CRLF)
	printf(!"/Number [1-max]" & sTab & sTab &   "-> plays the song hosted with the number, max is the latest song number," & CRLF)
	printf(sTab & sTab & sTab & 			    "   can be used with /Top50" & CRLF)
	printf(!"/NoAutoSwitchDevice" & sTab &	    "-> disable automatically switch over when the system's default audio device" & CRLF)
	printf(sTab & sTab & sTab & 			    "   setting changes" & CRLF)
	printf(!"/Proxy [address]" & sTab &		    "-> the proxy address to use (either ip adress or DNS name)" & CRLF)
	printf(!"/Glass" & sTab & sTab & sTab &	    "-> enables glass effect on console window only if DWM composition (aka Aero) is enabled" & CRLF)
	printf(!"/Topmost" & sTab &	sTab &		    "-> places the console window above all non-topmost windows" & CRLF)
	printf(!"/Top50" & sTab & sTab & sTab &		"-> plays the Top50 songs from first to last placed" & CRLF)
	printf(!"/Top50Dir [-1, 1]" & sTab &    	"-> if 1 (default) plays the titles ascending otherwise descending" & CRLF)
	printf(sTab & sTab & sTab &				    "   only available when /Top50 is set!" & CRLF)
	printf(!"/PU2R [n]" & sTab & sTab &			"-> plays songs only ranked n or better (available only in random play mode)" & CRLF)
	printf(!"/Font [""fontname""]" & sTab & 	"-> change the default font Consolas to new font" & CRLF)
	printf(!"/Font [""fontname""]" & sTab & 	"-> change the default font Consolas to new font" & CRLF)
	printf(!"/Eq_on]" & sTab & sTab & sTab &    "-> enable 3-band equalizer" & CRLF)
	printf(!"/Eq_bass [gain]" & sTab & sTab &	"-> equalizer bass gain value. Must be between -15 to 15 (default 12)" & CRLF)
	printf(!"/Eq_mid [gain]" & sTab & sTab &	"-> equalizer mid gain value. Must be between -15 to 15 (default 8)" & CRLF)
	printf(!"/Eq_treb [gain]" & sTab & sTab &	"-> equalizer treble gain value. Must be between -15 to 15 (default 10)" & CRLF)
	printf(!"/Eq_frb [frequence]" & sTab &	    "-> equalizer bass frequence value. Must be between 80 Hz to 16000 Hz (default 100 Hz)" & CRLF)
	printf(!"/Eq_frm [frequence]" & sTab &	    "-> equalizer mid frequence value. Must be between 80 Hz to 16000 Hz (default 1 kHz)" & CRLF)
	printf(!"/Eq_frt [frequence]" & sTab &	    "-> equalizer treble frequence value. Must be between 80 Hz to 16000 Hz (default 12 kHz)" & CRLF)
	printf(CRLF)
	printf(!"Examples: " & CRLF)
	printf(!"""Radio Station remix.kwed.org.exe"" /cfg 7 /cbg 1 /order 1 /glass" & CRLF)
	printf(!"""Radio Station remix.kwed.org.exe"" /top50 /number 50 /top50dir -1" & CRLF)

Sleep
The formatting of your version seems not to work properly:

Code: Select all

...
Command-line parameter:
/NoLevel      -> disable sound level color flash
/Order [0-2]  -> plays the songs 0 = random, 1 = from latest to oldest, 2 = from oldest to latest
/Cfg [0-15]   -> set text color
/Cbg [0-15]   -> set background color
/Number [1-max]             -> plays the song hosted with the number, max is the latest song number,
                 can be used with /Top50
/NoAutoSwitchDevice         -> disable automatically switch over when the system's default audio device
                 setting changes
/Proxy [address]            -> the proxy address to use (either ip adress or DNS name)
/Glass        -> enables glass effect on console window only if DWM composition (aka Aero) is enabled
/Topmost      -> places the console window above all non-topmost windows
/Top50        -> plays the Top50 songs from first to last placed
/Top50Dir [-1, 1]           -> if 1 (default) plays the titles ascending otherwise descending
                 only available when /Top50 is set!
/PU2R [n]     -> plays songs only ranked n or better (available only in random play mode)
/Font ["fontname"]          -> change the default font Consolas to new font
/Font ["fontname"]          -> change the default font Consolas to new font
/Eq_bass [gain]             -> equalizer bass gain value. Must be between -15 to 15
/Eq_mid [gain]              -> equalizer mid gain value. Must be between -15 to 15
/Eq_treb [gain]             -> equalizer treble gain value. Must be between -15 to 15
/Eq_frb [frequence]         -> equalizer bass frequence value. Must be between 80 Hz to 16000 Hz
/Eq_frm [frequence]         -> equalizer mid frequence value. Must be between 80 Hz to 16000 Hz
/Eq_frt [frequence]         -> equalizer treble frequence value. Must be between 80 Hz to 16000 Hz

Examples:
"Radio Station remix.kwed.org.exe" /cfg 7 /cbg 1 /order 1 /glass
"Radio Station remix.kwed.org.exe" /top50 /number 50 /top50dir -1
dodicat
Posts: 8189
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Print output in a CMD window issue

Post by dodicat »

This seems OK

Code: Select all

#include "crt.bi"

Function load overload(file As String) As String
      Dim As Long  f=Freefile
     IF Open (file For Binary Access Read As #f)=0 THEN
      Dim As String text
      If Lof(f) > 0 Then
            text = String(Lof(f), 0)
            Get #f, , text
      End If
      Close #f
      Return text
  else
        Print "Unable to load " + file
    End If 
End Function

var ff=freefile
open "myfile" for output as ff
Dim as String sVer = "v0.0"
	Dim As UByte iTab = 25
	Cls
	?  #ff, "Radio Station remix.kwed.org " & sVer
	?  #ff,
	?  #ff, "Radio Station remix.kwed.org is a simple console app that streams music from remix.kwed.org"
	?  #ff,
	?  #ff, "By default it plays songs randomly."
	?  #ff,
	?  #ff, "Keys:"
	?  #ff, "* Backspace to play current song again"
	?  #ff, "* Space to skip current song"
	?  #ff, "* p to pause or resume current song (toggle)"
	?  #ff, "* e to play current song endless (infinite loop) (toggle)"
	?  #ff, "* g to enable / disable glass effect (only if DWM composition (aka Aero) is enabled) (toggle)"
	?  #ff, "* t to set console window topmost or not (toggle)"
	?  #ff, "* +, -, or up, down to increase / decrease volume level"
	?  #ff, "* 0 to play songs randomly again"
	?  #ff, "* 1 to play from latest to oldest song"
	?  #ff, "* d to download current song to disk (remix.kwed.org folder in current dir)"
	?  #ff, "* b to play from current song to oldest song"
	?  #ff, "* f to play from current song to latest song"
	?  #ff, "* z to enable / disable 3-band equilizer"
	?  #ff, "* right to forward song for 5 seconds"
	?  #ff, "* left to rewind song for 5 seconds"
	?  #ff, "* ESC or q to exit"
	?  #ff,
	?  #ff, "Command-line parameter:"
	?  #ff, "/NoLevel"; Tab(iTab);"-> disable sound level color flash"
	?  #ff, "/Order [0-2]"; Tab(iTab); 	         "-> plays the songs 0 = random, 1 = from latest to oldest, 2 = from oldest to latest"
	?  #ff, "/Cfg [0-15]"; Tab(iTab);	         "-> set text color"
	?  #ff, "/Cbg [0-15]"; Tab(iTab);	         "-> set background color"
	?  #ff, "/Number [1-max]"; Tab(iTab);         "-> plays the song hosted with the number, max is the latest song number," 
	?  #ff, Tab(iTab);	    			         "   can be used with /Top50"
	?  #ff, "/NoAutoSwitchDevice"; Tab(iTab);     "-> disable automatically switch over when the system's default audio device"
	?  #ff, Tab(iTab);					         "   setting changes"
	?  #ff, "/Proxy [address]"; Tab(iTab);        "-> the proxy address to use (either ip adress or DNS name)"
	?  #ff, "/Glass"; Tab(iTab);				     "-> enables glass effect on console window only if DWM composition (aka Aero) is enabled"
	?  #ff, "/Topmost"; Tab(iTab);			     "-> places the console window above all non-topmost windows"
	?  #ff, "/Top50"; Tab(iTab);				     "-> plays the Top50 songs from first to last placed"
	?  #ff, "/Top50Dir [-1, 1]"; Tab(iTab);	     "-> if 1 (default) plays the titles ascending otherwise descending"
	?  #ff,  Tab(iTab); 					         "   only available when /Top50 is set!"
	?  #ff, "/PU2R [n]"; Tab(iTab);		  	     "-> plays songs only ranked n or better (available only in random play mode)"
	?  #ff, "/Font [""fontname""]"; Tab(iTab);    "-> change the default font Consolas to new font"
	?  #ff, "/Font [""fontname""]"; Tab(iTab);    "-> change the default font Consolas to new font"
	?  #ff, "/Eq_bass [gain]"; Tab(iTab);         "-> equalizer bass gain value. Must be between -15 to 15"
	?  #ff, "/Eq_mid [gain]"; Tab(iTab);          "-> equalizer mid gain value. Must be between -15 to 15"
	?  #ff, "/Eq_treb [gain]"; Tab(iTab);         "-> equalizer treble gain value. Must be between -15 to 15"
	?  #ff, "/Eq_frb [frequence]"; Tab(iTab);     "-> equalizer bass frequence value. Must be between 80 Hz to 16000 Hz"
	?  #ff, "/Eq_frm [frequence]"; Tab(iTab);     "-> equalizer mid frequence value. Must be between 80 Hz to 16000 Hz"
	?  #ff, "/Eq_frt [frequence]"; Tab(iTab);     "-> equalizer treble frequence value. Must be between 80 Hz to 16000 Hz"
	?  #ff,
	?  #ff, "Examples: "
	?  #ff, """Radio Station remix.kwed.org.exe"" /cfg 7 /cbg 1 /order 1 /glass"
	?  #ff, """Radio Station remix.kwed.org.exe"" /top50 /number 50 /top50dir -1"
close ff
puts load("myfile")
kill "myfile"

Sleep
 
I think that all the tabs should be preserved with open cons.
Maybe a bug?
UEZ
Posts: 1028
Joined: May 05, 2017 19:59
Location: Germany

Re: Print output in a CMD window issue

Post by UEZ »

Yes, this looks good - thx.
Post Reply