Metacommand: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(26 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''Metacommands''' are program wide commands that start with $.
'''Metacommands''' are commands that start with '''dollar sign ($)'''. Those commands usually switch the program between different operation modes/behavior or provide extended functionality.




==Legacy Metacommands (QBasic/QuickBASIC)==
{| align="right" style="max-width:25%;"
===Syntax===
|  __TOC__
:REM [[$INCLUDE]]: '[[QB.BI]]' 'loads a reference file or library
|}
== Legacy Metacommands (QBasic/QuickBASIC) ==
:*Legacy metacommands are normally used at the program start, they should have their own program line and must be commented with an ''[[Apostrophe|']]'' or [[REM]].
* [[$DYNAMIC]] {{Text|set all program arrays as changeable in size using [[REDIM]].}}
* [[$INCLUDE]] {{Text|designates a text code library file to include with the program.}}
* [[$STATIC]] {{Text|set all program arrays as unchangeable in size using [[DIM]].}}


:REM [[$DYNAMIC]] 'enables resizing of array dimensions with REDIM


:REM [[$STATIC]] 'arrays cannot be resized once dimensioned
== QB64 Metacommands ==
:*QB64 metacommands must not necessarily used at the program start. However, it's still the best location for some of it (see individual descriptions).
:*QB64 metacommands must not be commented with an ''[[Apostrophe|']]'' or [[REM]], but should have their own program line too.
* [[$ASSERTS]] {{Text|enables debug tests with the [[_ASSERT]] macro.}}
* [[$CHECKING]] {{Text|turns event and error checking OFF or ON.}}
* [[$COLOR]] {{Text|includes named color name constants in a program.}}
* [[$CONSOLE]] {{Text|creates a console window that can be used throughout a program.}}
* [[$DEBUG]] {{Text|enables debugging features, allowing you to step through your code line by line.}}
* [[$EMBED]] {{Text|is used to embed any file's contents into the compiled executable. Recall the embedded file contents using [[_EMBEDDED$]].}}
* [[$EXEICON]] {{Text|is used with an .ICO icon file name to embed the image into the compiled executable.}}
* [[$INCLUDEONCE]] {{Text|prevents that include file contents is injected multiple times into a program.}}
* [[$MIDISOUNDFONT]] ({{Text|deprecated|red}}) {{Text|enables the MIDI support for [[_SNDOPEN]].}}
* [[$NOPREFIX]] ({{Text|deprecated|red}}) {{Text|allows QB64-specific keywords to be used without the underscore prefix.}}
* [[$RESIZE]] {{Text|used with ON allows a user to resize the program window where OFF does not.}}
* [[$SCREENHIDE]] {{Text|hides the program window from view.}}
* [[$SCREENSHOW]] {{Text|displays the program window after it was hidden.}}
* [[$UNSTABLE]] {{Text|will enable the use of features that have not yet been made a permanent part of the language.}}
* [[$VERSIONINFO]] {{Text|adds metadata to Windows only binaries for identification purposes across the OS.}}


===Description===
* QBasic Metacommands are normally used at the program start and are in effect throughout the program.
* QBasic Metacommands are always prefixed with $ and MUST be commented with an apostrophe or [[REM]].
* [[$INCLUDE]] is always followed by a colon and the full text code file name is commented on both sides.
* [[$DYNAMIC]] allows larger arrays that are changeable in size at runtime.
* [[$STATIC]] makes all arrays unchangeable in size.
* '''QBasic metacommands should have their own program line because they are commented.'''


 
== QB64 Precompiler Commands ==
==QB64 Metacommands==
:*These are a special type of ''{{Text|QB64 Metacommands|blue}}'', which allow for conditional compiling, hence including or excluding certain code sections depending on given conditions.
===Syntax===
* [[$ELSE]] {{Text|used in conjunction with [[$IF]] for the precompiler.}}
:[[$CHECKING]]{OFF|ON} 'disables QB64 C++ event and error checking (no spaces)
* [[$ELSEIF]] {{Text|used in conjunction with [[$IF]] for the precompiler.}}
 
* [[$END IF]] {{Text|used in conjunction with [[$IF]] for the precompiler.}}
:[[$CONSOLE]] 'creates a QB64 console window throughout the program
* [[$ERROR]] {{Text|used to trigger compiler errors from within the precompiling pass.}}
 
* [[$IF]] {{Text|used to set an [[IF]] condition for the precompiler.}}
:[[$RESIZE]]:{ON|OFF} 'determines if re-sizing of the program screen by the user is allowed(no spaces)
* [[$LET]] {{Text|used to set a variable for the precompiler.}}
 
:[[$SCREENHIDE]] 'hides the QB64 program window throughout the program
 
:[[$SCREENSHOW]] 'displays the main QB64 program window
 
:[[$EXEICON]]:'iconfile.ico' 'embeds an .ICO file into the final executable (Windows only)
 
:[[$VERSIONINFO]]:key=value 'embeds version info metadata into the final executable (Windows only)
 
:[[$IF]]...[[$END IF]] 'precompiler directive
 
 
===Description===
* [[$INCLUDE]] can be used at the beginning or at the end of program SUB procedures.
* [[$CHECKING]]:OFF should only be used with '''errorless''' code where every CPU cycle counts! Use '''ON''' to re-enable event checking. Event checking can be turned OFF or ON throughout a program.
* [[$CONSOLE]] creates a console window which can be turned off later with [[_CONSOLE]] OFF.
* [[$RESIZE]]:ON allows a user to resize the program window. OFF is default.
* [[$SCREENHIDE]] hides the QB64 program window throughout the program until [[$SCREENSHOW]] is used.
* [[$IF]]...[[$END IF]] allows selective inclusion of code in the final program.
* '''Do not comment out with ' or [[REM]] QB64-specific metacommands.'''




{{PageSeeAlso}}
{{PageSeeAlso}}
* [[Statement]], [[Function (explanatory)]]
* [[Statement]], [[Sub (explanatory)]]
* [[REM]]
* [[Function (explanatory)]]
* [[DIM]], [[REDIM]]
* [[Apostrophe]], [[REM]]
* [[ON TIMER(n)]]
 
 




{{PageNavigation}}
{{PageReferences}}

Latest revision as of 12:18, 19 November 2024

Metacommands are commands that start with dollar sign ($). Those commands usually switch the program between different operation modes/behavior or provide extended functionality.


Legacy Metacommands (QBasic/QuickBASIC)

  • Legacy metacommands are normally used at the program start, they should have their own program line and must be commented with an ' or REM.
  • $DYNAMIC set all program arrays as changeable in size using REDIM.
  • $INCLUDE designates a text code library file to include with the program.
  • $STATIC set all program arrays as unchangeable in size using DIM.


QB64 Metacommands

  • QB64 metacommands must not necessarily used at the program start. However, it's still the best location for some of it (see individual descriptions).
  • QB64 metacommands must not be commented with an ' or REM, but should have their own program line too.
  • $ASSERTS enables debug tests with the _ASSERT macro.
  • $CHECKING turns event and error checking OFF or ON.
  • $COLOR includes named color name constants in a program.
  • $CONSOLE creates a console window that can be used throughout a program.
  • $DEBUG enables debugging features, allowing you to step through your code line by line.
  • $EMBED is used to embed any file's contents into the compiled executable. Recall the embedded file contents using _EMBEDDED$.
  • $EXEICON is used with an .ICO icon file name to embed the image into the compiled executable.
  • $INCLUDEONCE prevents that include file contents is injected multiple times into a program.
  • $MIDISOUNDFONT (deprecated) enables the MIDI support for _SNDOPEN.
  • $NOPREFIX (deprecated) allows QB64-specific keywords to be used without the underscore prefix.
  • $RESIZE used with ON allows a user to resize the program window where OFF does not.
  • $SCREENHIDE hides the program window from view.
  • $SCREENSHOW displays the program window after it was hidden.
  • $UNSTABLE will enable the use of features that have not yet been made a permanent part of the language.
  • $VERSIONINFO adds metadata to Windows only binaries for identification purposes across the OS.


QB64 Precompiler Commands

  • These are a special type of QB64 Metacommands, which allow for conditional compiling, hence including or excluding certain code sections depending on given conditions.
  • $ELSE used in conjunction with $IF for the precompiler.
  • $ELSEIF used in conjunction with $IF for the precompiler.
  • $END IF used in conjunction with $IF for the precompiler.
  • $ERROR used to trigger compiler errors from within the precompiling pass.
  • $IF used to set an IF condition for the precompiler.
  • $LET used to set a variable for the precompiler.


See also


QB64 Programming References

Wiki Pages
Main Page with Articles and Tutorials
QB64 specific keywords (alphabetical)
Original QBasic keywords (alphabetical)
QB64 OpenGL keywords (alphabetical)
Keywords by Usage
Got a question about something?
Frequently Asked Questions about QB64
QB64 Phoenix Edition Community Forum
Links to other QBasic Sites:
Pete's QBasic Forum
Pete's QBasic Downloads