Session and Environment Variables

Previous  Next


The MyBASIC2 implementation has made it easy for modular programming and to implement add-on's to applications.  Several session variables and operating system environment variables are used to locate source, include and library files.


Session Variables


These will be literally substituted so they can be a partial folder spec.   Used by $INCLUDE, $LIBRARY, RUN, SPAWN and LOAD.  The following session variables  can be used with file or folder names.


%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


Operating System Environment Variables


These variables are defined in the host operating system.  They can each contain multiple folder names separated by a semi-colon ";".


MyBASIC2_Lib   - Folder for Library Files (DLL).  Used by $LIBRARY and LOAD

MyBASIC2_Inc   - Folder for source and compiled files. Used by $INCLUDE

MyBASIC2_Run   - Folder for source and compiled files. Used by RUN, SPAWN and LOAD


MyBASIC2 Environment Variables


The MyBASIC2 Environment variables are used to exchange data between host application and the MyBASIC2 Interpreter.  You can also use environment variables to share data between scripts.  Environment variables exists as long as the interpreter exists.  You can use the MyBASIC2 IDE Environment Variable Editor to set a variable that you can then use in a script.  Use the following statements and function to set and read MyBASIC2 Environment Variables in your scripts:


OPTION ENVIRONMENT "variable-name" value



value = ENVIRONMENT( variable-name AS STRING ) AS VARIANT