| Directives |
|
| Formats |
Where:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description | Use the PREFIX
directive to define a series of search paths to
be inserted in front of all relative file references used
in OPEN / LOAD / RUN
/ CALL / PERFORM directives.
(ProvideX opens files with absolute paths directly,
without performing a search.) Each prefix can contain 0 (zero) or more search locations. (A search location is either a directory or a disk/directory pair.) You can specify up to 10 differently-numbered prefixes (i.e., PREFIX(0) through PREFIX(9)) as well as a PREFIX PROGRAM and a PREFIX FILE. See the descriptions of the various formats, below. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| See Also | ProvideX Search Rules, Equal Signs for Matching, Asterisks as PREFIX Wildcards, ProvideX Search Rules Using the PREFIX Directive in the ProvideX User's Guide. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Format 1 | Set Prefix 0 (Zero)
If no numbered prefix is specified, then the PREFIX command affects PREFIX(0) by default. For example, PREFIX "C:\TMP"would apply to PREFIX(0). |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Format 2 | Set Any Prefix Number
Use this format to define a maximum of 10 numbered prefix table entries (range 0 to 9) to set file search rules. Each table entry can contain multiple paths; e.g.,
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Format 3 | Set Program Retrieval Rules
Use the PREFIX PROGRAM format to define the search location(s) ProvideX will search first when it attempts to LOAD/RUN/CALL/PERFORM/SAVE programs; e.g.,
If you omit the prefix string or use a null string (PREFIX PROGRAM ""), ProvideX will reset the program prefix to null. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Format 4 | Using Paths in Keyed File
Use the PREFIX FILE format to specify the special Keyed file that contains information to be used for dynamic translations of files when they are opened in your applications. Any file you define as a PREFIX FILE must be a variable-length Keyed file or ProvideX returns Error #17: Invalid file type or contents. If you define a PREFIX FILE, then ProvideX searches this special Keyed file for a search location whenever it encounters an OPEN command with a relative filename, using filename$ as the key to the PREFIX FILE. (Remember that ProvideX opens filenames with absolute paths directly, without performing a search.) Normal PREFIX search rules still apply after a filename has been located in the PREFIX FILE. When you write to this special Keyed file, treat the filename from your program's OPEN command as the Key. The data record for each key contains the true filename you want opened instead. (ProvideX retrieves the data record internally with a READ RECORD.)
The return value from the Function PFX(-1) can be used to determine if a PREFIX FILE is set and what its pathname is. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PREFIX FILE record layout: The PREFIX FILE is defined as a keyed file with a primary/external key equal to the largest filename that your application will use. The first field in this file will contain the real pathname to be accessed and the second field the option OPT= option value to be used during the open. Any options specified in this second field will be added to any options specified on the OPEN. In PxPlus (as of build 9182) a third field may be specified that contains the IOLIST to use, when opening the file with an IOL=* option. In addition, when using PxPlus, if the pathname (the first field) is empty in the PREFIX FILE record, the original file name will be used allowing the PREFIX FILE to add only the open options and IOLIST. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ProvideX Search Rules | The ProvideX
default is to search all prefixes, in the following
order:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The PREFIX
search rules apply not only to files being
found, but also to files being created. ProvideX creates files in the first location that is permitted by the PREFIX rules. If 'CD' (Search Current Directory) is on, then all files are created in the current directory (the first permitted location). If the 'CD' system parameter is off, then ProvideX creates the file in the first location permitted by the search rules above. Windows search rules are used to find DLLs (i.e., not PREFIX search rules or current directory). Use the ENABLE and DISABLE directives to control which of the numbered prefixes ProvideX will use in the search. (While scanning prefixes 0 to 9, ProvideX ignores any prefix that is disabled.) Note that the initial check for PROGRAM cache checks for a match against the original filenames. Thus, if you used CALL"ABCD" and you had previously loaded a program with the same name, ProvideX would use the one in cache. This eliminates the directory searches involved, but if you have duplicate program names in your system, it is possible to get the wrong one, for instance, if you CALL"ABCD", change the directory / prefix, then re-CALL"ABCD". If this happens for duplicate program names in your system, either clear the cache or do not use it. For more information, refer to DISABLE Disable Use of Prefix Table Entry, ENABLE Re-Enable Use of Prefix Table Entry, and the 'CD' System Parameter. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Equal Signs for Matching | Equal signs
in a PREFIX search string have special
meaning. Each character of the filename that corresponds
by position to an equals sign will be used to form a
subdirectory name to be used in the search. For instance,
if you include 1 equals sign, ProvideX will interpret that to mean
that the first character of filename$ is also
the subdirectory name. If you include 2 equals signs, it
will take the first 2 characters as matching the
subdirectory name, and so on. ProvideX automatically finds the location to retrieve or create files by looking first for a subdirectory with a name matching, character-by-character, in sequence, the portion of the filename that corresponds to the equals signs. This allows you to sort files into subdirectories based on automated substitution of the first few characters of your filename, and accelerates the search for and/or creation and saving of files in subdirectories.
If a directory entry in a PREFIX
contains equals signs as shown in the example above,
ProvideX evaluates the initial two characters as matching
characters and uses them as the name of the subdirectory
where the search will commence for relative file
references. In the following example: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Asterisks as PREFIX Wildcards | You can also
use * and ** as wildcard characters to support the use of
filename extensions without modifying your code. This
feature was added to the ProvideX language as of Version
4.20 primarily for Windows 2000 users, since the
Microsoft Certification rules for Windows 2000 require
that all files have file extensions. With the wildcard
characters, you can rename files on disk with a common
file extension without modifying the program code.
If the PREFIX directive includes an asterisk plus a specified extension as a filename, ProvideX inserts the filename from your OPEN command in place of the asterisk and searches first for the filename with the extension you specify in the prefix; e.g.,
ProvideX will scan the disk for "c:\somedir\FOOFOO.PRG" and open that file if found. If FOOFOO.PRG is not found, ProvideX will attempt to find and open a file named "FOOFOO". If the PREFIX directive includes two asterisks plus a specified extension as a filename, the substitution described above for a single star will occur only if your OPEN directive includes a simple filename (i.e., a filename without an extension). If your filename is complex (e.g., MY_FILE.DAT), no substitution occurs; e.g.,
Since OPEN (chan)"FOOFOO" contains a simple filename, ProvideX will look first for "c:\somedir\FOOFOO.PRG", then, if not found, for "FOOFOO". Since MyFile.Dat is a complex filename and two stars are used in the PREFIX filename, ProvideX doesn't add a .PRG extension to MyFile.Dat when it executes the search to find and open the file. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Format 5 | Virtual
Directories
Use the above PREFIX DIRECTORY format to define virtual directories within your PxPlus system. When the system is parsing pathnames, it will compare the pathname specified by the program with all the Virtual directory names specified in the PREFIX DIRECTORY directive. If a match is found, the system will replace the directory name with the value specified in dirpath$. For Example, if you issued the directive:
Any reference to "*usr/" would reference the directory "/user/mike". So accessing a file "*usr/tempdata" would actually reference "/user/mike/tempdata". If desired the dirpfx$ may consist of "*/name..." in which case any pathname that ends with name... will be replaced with the value in dirpath$. (This option was added in build 9190) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *Note* | If the directory specified in dirpath$ does not exist, the system will create it upon first reference. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||