$INCLUDE: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
No edit summary Tags: Undo Reverted |
No edit summary Tags: Manual revert Reverted |
||
Line 3: | Line 3: | ||
{{PageSyntax}} | {{PageSyntax}} | ||
: {[[REM]] | [[apostrophe|']] } [[$INCLUDE]]''':''' | : {[[REM]] | [[apostrophe|']] } [[$INCLUDE]]''':''' '{{Parameter|sourceFile}}' | ||
Line 17: | Line 17: | ||
* 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). | * 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). | ** 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 any [[DIM]], [[CONST]], [[SHARED]] arrays or [[DATA]] at the '''beginning''' of the main program code. | ||
* $INCLUDE [[SUB]]s or [[FUNCTION]]s at the bottom of the main program code '''after any SUB procedures.''' | * $INCLUDE [[SUB]]s or [[FUNCTION]]s at the bottom of the main program code '''after any SUB procedures.''' | ||
** '''Note:''' [[TYPE]] definitions, [[DATA]] and [[DECLARE LIBRARY]] can be placed inside of sub-procedures. | ** '''Note:''' [[TYPE]] definitions, [[DATA]] and [[DECLARE LIBRARY]] can be placed inside of sub-procedures. | ||
Line 29: | Line 29: | ||
===More examples=== | ===More examples=== | ||
* [[SelectScreen]] (member-contributed $INCLUDE demo) | * [[SelectScreen]] (member-contributed $INCLUDE demo) | ||
* [[FILELIST$]] (member-contributed file search function) | * [[FILELIST$]] (member-contributed file search function) | ||
* [[SAVEIMAGE]] (SUB program that creates bitmaps) | * [[SAVEIMAGE]] (SUB program that creates bitmaps) | ||
Line 35: | Line 35: | ||
{{PageSeeAlso}} | {{PageSeeAlso}} | ||
* [[INTERRUPT]], [[INTERRUPTX]] | * [[INTERRUPT]], [[INTERRUPTX]] | ||
* [[TYPE]], [[DIM]] | * [[TYPE]], [[DIM]] | ||
* [[Metacommand]] | * [[Metacommand]] |
Revision as of 22:56, 22 January 2023
$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
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.
- Note: TYPE definitions, DATA and DECLARE LIBRARY can be placed inside of 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
- SelectScreen (member-contributed $INCLUDE demo)
- FILELIST$ (member-contributed file search function)
- SAVEIMAGE (SUB program that creates bitmaps)
See also