Difference between revisions of "$INCLUDE"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 6: Line 6:
  
  
* $INCLUDE is often used to add functions and subs from an external text library.
+
* Qbasic required that a comment or REM preceded all [[Metacommand]]s at the start of the program.
* There must always be a [[REM]] or [[REM|']] comment before the $INCLUDE metacommand.
+
* '''QB64''' does not require a comment or [[REM]] before any [[Metacommand]]. '''Do NOT comment QB64 specific [[Metacommand]]s!'''
* The source file MUST have REM or apostrophies around the name.
+
* The ''source file'' name MUST have REM or apostrophe comments around the text source file name.
 +
* $INCLUDE is often used to add functions and subs from an external text QBasic code library.
 
* The source file included can contain any BASIC statement except [[GOTO]]  
 
* The source file included can contain any BASIC statement except [[GOTO]]  
 
* QB 4.5 can use [[DECLARE]] SUB in BI files such as [[QB.BI]]. '''QB64''' ignores Qbasic's [[DECLARE]] statements.
 
* QB 4.5 can use [[DECLARE]] SUB in BI files such as [[QB.BI]]. '''QB64''' ignores Qbasic's [[DECLARE]] statements.
Line 17: Line 18:
  
 
<center>'''How to $INCLUDE a BAS or Text file with a QB64 Program'''</center>
 
<center>'''How to $INCLUDE a BAS or Text file with a QB64 Program'''</center>
 
+
* '''QB64''' does not require a comment or [[REM]] before any [[Metacommand]]. '''Do NOT comment QB64 specific [[Metacommand]]s!'''
:* 1) Assemble your text code into a TEXT file and name it something with a '''.BI''' or '''.BM''' file name extension. '''NOT as .TXT!'''
+
* The ''source file'' name MUST have REM or apostrophe comments around the text source file name.
:* 2) [[$INCLUDE]] any [[DEFINT]], [[DIM]], [[CONST]], [[SHARED]] arrays or [[DATA]] at the very '''beginning''' of the main program code.  
+
* 1) Assemble your text code into a TEXT file and name it something with a '''.BI''' or '''.BM''' file name extension.
:* 3) $INCLUDE [[SUB]]s or [[FUNCTION]]s at the very bottom of the main program code '''AFTER any SUB procedures.'''
+
* 2) $INCLUDE any [[DEFINT]], [[DIM]], [[CONST]], [[SHARED]] arrays or [[DATA]] at the very '''beginning''' of the main program code.  
 +
* 3) $INCLUDE [[SUB]]s or [[FUNCTION]]s at the very 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.
:* 4) '''Compile''' the program with the included text files '''in the QB64 folder!''' Save the text files to use them like '''Library files'''.
+
* 4) '''Compile''' the program with the included text files '''in the QB64 folder!''' Save the text files to use them like '''Library files'''.
 +
<center>'''Note: Once the program is compiled, the included text files are no longer needed with the program EXE.'''</center>
  
  

Revision as of 16:04, 14 August 2012

$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'


  • Qbasic required that a comment or REM preceded all Metacommands at the start of the program.
  • QB64 does not require a comment or REM before any Metacommand. Do NOT comment QB64 specific Metacommands!
  • The source file name MUST have REM or apostrophe comments around the text source file name.
  • $INCLUDE is often used to add functions and subs from an external text QBasic code library.
  • The source file included can contain any BASIC statement except GOTO
  • QB 4.5 can use DECLARE SUB in BI files such as QB.BI. QB64 ignores Qbasic's DECLARE statements.
  • QB64 users can use all statements in their include files. See below.
  • The $INCLUDE metacommand should be the only statement on a line since execution progresses after the code line.


How to $INCLUDE a BAS or Text file with a QB64 Program
  • QB64 does not require a comment or REM before any Metacommand. Do NOT comment QB64 specific Metacommands!
  • The source file name MUST have REM or apostrophe comments around the text source file name.
  • 1) Assemble your text code into a TEXT file and name it something with a .BI or .BM file name extension.
  • 2) $INCLUDE any DEFINT, DIM, CONST, SHARED arrays or DATA at the very beginning of the main program code.
  • 3) $INCLUDE SUBs or FUNCTIONs at the very bottom of the main program code AFTER any SUB procedures.
Note: TYPE definitions, DATA and DECLARE LIBRARY can be placed inside of sub-procedures.
  • 4) Compile the program with the included text files in the QB64 folder! Save the text files to use them like Library files.
Note: Once the program is compiled, the included text files are no longer needed with the program EXE.


Example: '$INCLUDE: 'QB.BI'


See Library Examples:


See also:



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page