Liberty BASIC Help Online

Path and Filename
Complete Path and Filename
 
References to a complete path and filename indicate that the drive letter and all folders and sub folders are included in the file specification.  A complete path and filename is returned by the FILEDIALOG.  An example of a complete path and filename is as follows:
 
C:\My Documents\My Programs\Games\mygame.bas
 
Filename Alone
References to a filename without path information indicate that the disk filename is used with no drive or folder information.  In Liberty BASIC, use of a filename without path information assumes that the file exists on disk in the DefaultDir$.  An example is as follows:
 
mygame.bas
 
Sub Folder
A file that exists in a subfolder of the DefaultDir$ is written by first identifying the sub folder(s), each followed by a backslash, then the filename, like this:
 
images\background.bmp
gamefiles\images\badguy.bmp
 
Relative Path
Relative paths to files that exist in folders at the same level in the directory tree, (or in a higher level), use the ".." designation to indicate "go up one level from the DefaultDir$".  Filenames are usually designated by including a dot and a file extension that specifies the type of file.  Filenames ending in ".txt" are text files, (for instance), while filenames ending in ".bmp" are bitmaps.  Folders do not typically have extensions.  The names below with extensions indicate files, while the names without extensions indicate folders.  Here are some examples of relative paths:
 
..\smiley.bmp          'go up one level to access the file
..\images\redbox.bmp  'go up one level to access the file in the images folder
..\..\customer.txt    'go up two levels to access the file
..\..\data\names.dat  'go up two levels to access the file in the data folder
 
Hard-coding Path and Filename
The phrase "hard-coding" when referring to path and filename information indicates that the pathname specified in the progarm code contains the entire file specification, including the drive letter and all folder information as well as the filename.  If a program is meant for use by the programmer alone, on a single computer, this method works, as long as no changes are made to the directory structure.  When any changes are made to the directory structure or filename, the program code must be changed as well.
 
Caveat
It is very unlikely that other users of a program will have the same directory structure on their computers as the programmer who writes the code.  For this reason, it is best to use one of the other path naming options listed above that does not depend upon all users having the same directory structure on their computers.
 
Filenames Used in Code
Some commands that use path and filename specifications are:
 
LOADBMP
OPEN
PLAYWAVE
BMPBUTTON
 


Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/