Original Author Paul Laughton, 2011
Page 104
De Re BASIC!
Working with Files
Android devices may have several file storage devices. BASIC! uses one of these devices as its base drive.
You can select a different base drive in the Menu->Preferences item B
ASE
D
RIVE
. In this manual, the
notation <pref base drive> refers to the base drive you selected in Preferences.
BASIC! can work with files anywhere on the base drive, but most file operations are done in BASIC!'s
base directory. Except when you create a standalone apk file (see Appendix D), the base directory is
<pref base drive>/rfo-basic. All file paths are relative to a subdirectory of the base directory.
Paths Explained a beginner's guide
A path describes where a file or directory is located relative to another directory.
A file is a container for data. A directory is a container for files and other directories.
1
A directory that is
in a directory may have other directories in it, and those directories may contain other directories, and
so on. This results in a "tree" of directories and files, called a file system. A file system organizes data on
a storage device, such as a disk or a memory card.
Absolute paths: A path that is relative to the root directory is called an absolute path. For example, the
absolute path to pictures you take with an Android camera may be "/sdcard/DCIM/Camera". In BASIC!,
the base directory is not a root directory, so BASIC! does not use absolute paths.
Relative paths: A path that is relative to anything except the root directory is called a relative path.
Starting from "/sdcard", the relative path down to Camera is "DCIM/Camera". Use the "../" path
notation to go back up: from Camera, the path to "/sdcard/DCIM" is ".." and to "/sdcard" is "../.." .
The relative path from "/sdcard/DCIM/Camera" to "/sdcard/DCIM/.thumbnails" is "../.thumbnails". With
this notation, you can reach any file in the file system.
All paths in BASIC! are relative to a default path that depends on the kind of data you want to use. These
default paths are explained in the next section.
Paths in BASIC!
BASIC! files are stored in subdirectories of the base directory, "<pref base drive>/rfo-basic/". Files are
grouped by type, as follows:
BASIC! program files are in rfo-basic/source/
BASIC! data files are in rfo-basic/data/
BASIC! SQLite databases are in rfo-basic/databases/
All of the BASIC! file commands assume a certain default path. The default path depends on the type of
file each command expects to handle:
1
This container is called a "directory" because it is a listing of the items it contains. You can also call it a "folder",
and you can say "a folder is a container for files and other folders." Both expressions mean the same thing.