Original Author Paul Laughton, 2011
Page 105
De Re BASIC!
The Include and Run commands expect to load program files, so they look in rfo-basic/source/.
SQLite operations look for database files in rfo-basic/databases/.
All other file operations look for data files in rfo-basic/data/.
If you give a filename to a file command, it looks for that filename in the default directory for commands
of that type. If you want to work with a file that is not in that directory, you must specify a relative path
to the appropriate directory. BASIC! adds your path to the default path.
To read the file "names.txt" in "rfo-basic/data/", the path is "names.txt".
To read the program file "sines.bas" in "rfo-basic/source", the path is "../source/sines.bas".
Paths Outside of BASIC!
BASIC! runs on an Android device, and its files are part of the Android file system.
You can use relative paths to access files outside of the base directory. To continue the example from
the previous section, assume the absolute Android path to the <pref base drive> is "/sdcard":
To read the music file "rain.mp3" in "/sdcard/music/", the BASIC! path is "../../music/rain.mp3". The
path is relative to the default directory for general data "<pref base drive>/rfo-basic/data/".
Use care when writing paths that look up from the <pref base drive>. The directory name may not be
what you expect, and it may not be the same on all Android devices.
Every file on an Android device has an absolute path. Unfortunately, on most Android devices every file
has several absolute paths. The default <pref base drive> can be reached with the absolute Android path
"/sdcard". The name "sdcard" is a shortcut (a symbolic link) that means different things on different
devices. "<pref base drive>/rfo-basic/../" may not get to the Android directory "/sdcard", but to
something like "/storage/emulated/legacy".
You can use the command File.root to get the absolute Android path to the BASIC! <pref base drive>.
Paths and Case-sensitivity
While the Android file system is normally case-sensitive. However, the FAT file system, often used on SD
cards, memory sticks, etc., is case-insensitive. When handling files on these devices, Android ­ and
therefore BASIC! ­ can not differentiate between names that differ only in case. In your BASIC! program,
the two paths "../../music/rain.mp3" and "../../MUSIC/Rain.MP3" will both access the same file.
The rules change if you compile the same BASIC! program into a standalone apk (see Appendix D). The
file system inside the apk is case-sensitive. The paths "../../music/rain.mp3" and"../../MUSIC/Rain.MP3"
access different files. If the actual path in your build project is "Assets/<project>/MUSIC/Rain.MP3",
then using the second path would succeed, but the first path would fail.
To prevent any error, it is good practice to match case exactly in file paths and names.