$INCLUDE Statement

Previous  Next

 

$INCLUDE "file [/once]"

 


 

Includes a file into current file.  File is included at run-time.   To prevent an include file to be included more than once you can add the "/ONCE" qualifier to the filename.  The default extension for an include file is ".BIS' or ".BIC" when compiled. 

 

Using with Compiled Files

It should be noted that when a MyBASIC2 source file with an $INCLUDE is compiled, the include file will be embedded into the compiled file and the include file will not be used when you run a compiled file except when "/ONCE' is specified.  In this case, the include file is not included in the compiled file and will be loaded when you run a compiled file the same way as when running a non-compiled file.

 

Note; If the include file extension is omitted, MyBASIC2 will first look for the compiled include file and if not found it will use the source include file.  Additionally, when using /ONCE, the interpreter will distinguish between ".BIS" and ".BIC" extensions, i.e., if you include MyBASIC2.BIC using /ONCE and then try to include MyBASIC2.BIS using /ONCE it will include both and fail since it will look for the include file name with extension.

 

The following Session Variables can be used with INCLUDE:

 

%AppFolder%    - Folder of application. MyBASIC2 Console.exe for example

%CommonFolder% - Points to Current Common Files folder (Program Files (x86)\Common Files)

%SourceFolder% - Folder of calling MyBASIC2 file

 

Uses "MyBASIC2_Inc" environment variable to search for file if not found. 

 

Example:

 

$INCLUDE "MyBASIC2.bis /once"

$INCLUDE "%SourceFolder%\_INCLUDE\MaxA.bis"

$LIBRARY "mybasic2_extlib.dll"

 

DIM nStatus AS INTEGER

 

' Run the Position vs Position Options Dialog

nStatus = CALL MA_Common@DoOptionsDialog( MA_PosPosOptions, MA_PosPosProcess, MA_hProfile )

 

END