$CONSOLE: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m Add more info for "ONLY" |
||
(One intermediate revision by the same user not shown) | |||
Line 8: | Line 8: | ||
{{PageDescription}} | {{PageDescription}} | ||
* [[_CONSOLE]] '''ON''' or '''OFF''' may be used to show or hide the console window at run time. | * [[_CONSOLE]] '''ON''' or '''OFF''' may be used to show or hide the console window at run time. | ||
* The ''':ONLY''' option | * The ''':ONLY''' option bypasses the graphical program window, allowing the program to run in a text-only console window. This is especially useful for: | ||
** Legacy programs that do not use graphics. | |||
** Scenarios where graphical output is not needed or desired. | |||
* [[_DEST]] [[_CONSOLE]] may be used to send screen output to the console window. | * [[_DEST]] [[_CONSOLE]] may be used to send screen output to the console window. | ||
* [[_SCREENHIDE]] and [[_SCREENSHOW]] can be used to hide or show the main program window. | * [[_SCREENHIDE]] and [[_SCREENSHOW]] can be used to hide or show the main program window. | ||
Line 71: | Line 73: | ||
{{PageSeeAlso}} | {{PageSeeAlso}} | ||
* [[_CLIPBOARD$ (function)]], [[_CLIPBOARD$]] (statement) | * [[_CLIPBOARD$ (function)]], [[_CLIPBOARD$]] (statement) | ||
* [[_CONSOLE]] | * [[_CONSOLE]], [[_ECHO]] | ||
* [[$SCREENHIDE]], [[$SCREENSHOW]] (QB64 [[Metacommand]]s) | * [[$SCREENHIDE]], [[$SCREENSHOW]] (QB64 [[Metacommand]]s) | ||
* [[_SCREENHIDE]], [[_SCREENSHOW]] | * [[_SCREENHIDE]], [[_SCREENSHOW]] |
Latest revision as of 17:37, 12 May 2025
The $CONSOLE Metacommand creates a console window that can be used throughout a QB64 program module.
Syntax
- $CONSOLE[:ONLY]
Description
- _CONSOLE ON or OFF may be used to show or hide the console window at run time.
- The :ONLY option bypasses the graphical program window, allowing the program to run in a text-only console window. This is especially useful for:
- Legacy programs that do not use graphics.
- Scenarios where graphical output is not needed or desired.
- _DEST _CONSOLE may be used to send screen output to the console window.
- _SCREENHIDE and _SCREENSHOW can be used to hide or show the main program window.
- _DELAY or SLEEP can be used to allow the console window to be set in front of the main program window.
- QB64 Metacommands are not commented out with ' or REM, unlike QuickBASIC metacommands
- Change the title of the $CONSOLE windows created using _CONSOLETITLE
- Note: Text can be copied partially or totally from console screens in Windows by highlighting and using the title bar menu.
- To copy console text output, right click the title bar and select Edit for Mark to highlight and repeat to Copy
Examples
Example 1: Hiding and displaying a console window. Use _DELAY to place console in front of main program window.
$CONSOLE _DELAY 4 _CONSOLE OFF _DELAY 4 _CONSOLE ON _DEST _CONSOLE PRINT "Close this console window or click main window and press a key!" |
Example 2: How to use a Console window to copy screen output using the Edit menu by right clicking the console title bar.
$CONSOLE _DEST _CONSOLE c&& = -1: d& = -1: e% = -1: f%% = -1 hx$ = HEX$(f%%) PRINT "Max hex _BYTE = "; hx$; " with"; LEN(hx$); "digits ="; VAL("&H" + hx$) hx$ = HEX$(e%) PRINT "Max hex INTEGER = "; hx$; " with"; LEN(hx$); "digits ="; VAL("&H" + hx$) hx$ = HEX$(d&) PRINT "Max hex LONG = "; hx$; " with"; LEN(hx$); "digits ="; VAL("&H" + hx$) hx$ = HEX$(c&&) PRINT "Max hex _INTEGER64 = "; hx$; " with"; LEN(hx$); "digits ="; VAL("&H" + hx$) hx$ = HEX$(9223372036854775807) PRINT "Max _INTEGER64 value = "; hx$; " with"; LEN(hx$); "digits" hx$ = HEX$(-9223372036854775808) PRINT "Min _INTEGER64 value = "; hx$; " with"; LEN(hx$); "digits" |
Max hex _BYTE = FF with 2 digits = 255 Max hex INTEGER = FFFF with 4 digits = 65535 Max hex LONG = FFFFFFFF with 8 digits = 4294967295 Max hex _INTEGER64 = FFFFFFFFFFFFFFFF with 16 digits =-1 Max _INTEGER64 value = 7FFFFFFFFFFFFFFF with 16 digits Min _INTEGER64 value = 8000000000000000 with 16 digits |
- Console: Right click and select Edit > Select All (mouse highlight after) then hit Enter or select Edit > Copy to the clipboard.
Max hex _BYTE = FF with 2 digits = 255 Max hex INTEGER = FFFF with 4 digits = 65535 Max hex LONG = FFFFFFFF with 8 digits = 4294967295 Max hex _INTEGER64 = FFFFFFFFFFFFFFFF with 16 digits =-1 |
- Copied text: The above text was copied after Select All was selected and the smaller area was re-highlighted with the mouse.
See also
- _CLIPBOARD$ (function), _CLIPBOARD$ (statement)
- _CONSOLE, _ECHO
- $SCREENHIDE, $SCREENSHOW (QB64 Metacommands)
- _SCREENHIDE, _SCREENSHOW
- C Console Library