Original Author Paul Laughton, 2011
Page 84
De Re BASIC!
d = FLOOR(6 * RND() + 1)
% roll a six-sided die
GOSUB d, Side1, Side2, Side3, Side4, Side5, Side6
PRINT "Welcome back!"
END
Side1:
<subroutine for side 1>
RETURN
...
Side6:
<subroutine for side 6>
RETURN
Using Source Code from Multiple Files
Include FilePath
Before the program is run, the BASIC! preprocessor replaces any Include statements with the text from
the named file. You can use this to insert another BASIC! program file into your program at this point.
The program is not yet running, therefore the File Path cannot be a string expression.
You may include a file only once. If multiple Include statements name the same file, the preprocessor
inserts the contents of the file in place of the first such Include statement and deletes the others. This
prevents Out-Of-Memory crashes caused by an Include file including itself.
INCLUDE functions/DrawGraph.bas
inserts the code from the file "<pref base drive>/rfo-basic/source/functions/DrawGraph.bas" into the
program.
The File Path may be written without quotation marks, as in the example above, or with quotes:
INCLUDE "functions/DrawGraph.bas"
If present, the quotes prevent the preprocessor from forcing the File Path to lower-case. Normally, this
does not change how BASIC! behaves, because the file system on the SD card is case-insensitive.
DrawGraph.bas and drawgraph.bas both refer to the same file.
However, if you build your program into a standalone Android application (see Appendix D), you can use
virtual files in the Android assets file system. File names in assets are case-sensitive, so you may need to
use quotes with the Include File Path.
Because Include is processed before your program starts running, it is not affected by program logic.
IF 0
INCLUDE functions/DrawGraph.bas
ENDIF
In this example, the contents of the program file replace the Include statement in the body of the
If/Endif, but the statements are never executed because If 0 is always false.