$INCLUDE: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:
* $INCLUDE is often used to add functions and subs from an external text QBasic code library.
* $INCLUDE is often used to add functions and subs from an external text QBasic code library.
* The $INCLUDE metacommand should be the only statement on a line.
* The $INCLUDE metacommand should be the only statement on a line.


=== How to $INCLUDE a BAS or Text file with a QB64 Program ===
=== How to $INCLUDE a BAS or Text file with a QB64 Program ===
Line 30: Line 29:
* [[SelectScreen]]
* [[SelectScreen]]
* [[FILELIST$]]
* [[FILELIST$]]
* [[SAVEIMAGE]]
* [[SaveImage SUB]]





Latest revision as of 20:00, 5 January 2024

$INCLUDE is a metacommand that is used to insert a source code file into your program which is then executed at the point of the insertion.


Syntax

{REM | ' } $INCLUDE: 'sourceFile'


Description

  • QBasic metacommands must be commented with REM or an apostrophe.
  • The sourceFile name must be enclosed in apostrophes and can include a path.
  • $INCLUDE is often used to add functions and subs from an external text QBasic code library.
  • The $INCLUDE metacommand should be the only statement on a line.

How to $INCLUDE a BAS or Text file with a QB64 Program

  • Assemble the code to be reused into a file.
  • Common extensions are .BI (for declarations, usually included in the beginning of a program) or .BM (with SUBs and FUNCTIONs, usually included at the end of a program).
    • Any extension can be used, as long as the file contains code in plain text (binary files are not accepted).
  • $INCLUDE any DIM, CONST, SHARED arrays or DATA at the beginning of the main program code.
  • $INCLUDE SUBs or FUNCTIONs at the bottom of the main program code after any SUB procedures.
  • Compile the program.
  • Note: Once the program is compiled, the included text files are no longer needed with the program EXE.


Examples

 '$INCLUDE: 'QB.BI'

More examples


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link