How PxPLUS finds
and saves your files and programs.
First thing to know are the verbs, functions and
parameters that are necessary to understand the search rules of PxPLUS .
The 'CD' parameter is default 'OFF', which means the current directory is
searched after the PREFIXes. If set to 'ON', PxPLUS checks the current
directory before checking the PREFIX list for a file.
(see below for 'Search Rules')
You can check the value of the parameter by using
: PRINT PRM('CD')
and you can set the parameter by using: SET PARAM 'CD'=1 (or 0)
You can compare the PREFIX with the PATH variable in MS-DOS or UNIX.
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
(PxPLUS OPENs files with absolute paths directly, without performing a
PREFIX "/usr/mydir/data/ /usr/mydir/prog/ /usr/mydir/sub/ D:/other/data/"
Different paths must be separated by a space.
As you can see, you can add a drive letter before a directory, to indicate to
search a different drive than specified with the SETDRIVE verb.
You can specify up to 10 differently numbered
PREFIXes, i.e. PREFIX (0) through PREFIX (9).
PREFIX (0) "/usr/mydir/data/"
PREFIX (1)"/usr/mydir/prog/ /usr/mydir/sub/"
The advantage is that you can DISABLE and ENABLE
a specific PREFIX.
i.e.: DISABLE 2, disables the search in D:/other/data/.
PREFIX (0) " Ö " is the same as PREFIX " Ö "
If you need to include a space within a directory
name, then that directory location must be enclosed in double quotation marks.
PREFIX "C:/Tmp/ C:/usr/ ""C:/Program Files/"""
PRINT PFX or PRINT PFX (n) prints the value of
EQUALS signs for special matching.
Equals signs in your PREFIX 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, PxPLUS will interpret that to mean that the first character of
your 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.
The purpose was to split up large directories, inherited from other Business
Basics, into smaller ones for faster access and better management.
Suppose your application consists of more than one module. The program name
indicates to which module they belong. i.e. GL001 GL002 GL003 belong to the
module 'General Ledger' and AR001 AR002 Ö belong to the module 'Account
Receivable'. Then you can split your directory into separate subdirectories. The
name of these subdirectories must be the same as the first corresponding
characters of the module, in our example GL and AR.
When looking for a program or file, PxPLUS 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.
PxPLUS evaluates the filename 'ARHIST as /myapp/AR/ARHIST for purposes of the
Asterisks as PREFIX Wild Cards.
You can also use * and ** as wild-card characters to support the use of filename
extensions without modifying your code. This feature was added to the PxPLUS
language as of Ver. 4.20 primarily for WINDOWS 2000 users, since the Microsoft
Certification rules for WINDOWS 2000 require that all files have file
extensions. With the wild-card characters, you can rename your files on disk
with a common file extension without modifying your program code.
Using a single asterisk (*):
If your PREFIX directive includes an asterisk plus a specified extension as a
filename, PxPLUS inserts the filename from your OPEN command in place of the
asterisk and searches first for your filename with the extension you specify in
PxPLUS will scan the disk for "/mydir/customer.dat" and OPEN that file if
found. If 'customer.dat' is not found, PxPLUS will attempt to find and OPEN a
file named "customer".
KEYED "abcde",5 will not create a file named "abcde.dat" , but
ERASE "abcde" will erase a file named "abcde.dat" !
Using two asterisks (**):
If your 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. customer.hist), no substitution
Since OPEN (1)"customer" contains a simple filename, PxPLUS will look first
for "/mydir/customer.dat", then, if not found, for "customer".
Since 'customer.hist' is a complex filename and two stars are used in the PREFIX
filename, PxPLUS doesnít add a .dat extension to customer.hist when it
executes the search to find and OPEN the file.
Use the PREFIX PROGRAM format to define the search location(s) PxPLUS will
search first when it attempts to LOAD, RUN, CALL, PERFORM or SAVE programs.
PREFIX PROGRAM "/pvx/mydir/pgm/"
to examine this prefix :
This is not the counterpart of PREFIX PROGRAM !
Use the PREFIX FILE format to do dynamic
translations of filenames in your applications by defining a KEYED file as a
lookup table. Any file you define as a PREFIX FILE must be a variable-length
KEYED file or PxPLUS returns an Error #17: Invalid file type or contents.
If you define a PREFIX FILE, then PxPLUS
searches this special KEYED file for a search location whenever it encounters an
OPEN command with a relative filename, using the filename in your OPEN directive
as the key to the PREFIX FILE. (Reminder: PxPLUS OPENs filenames with absolute
paths directly, without performing a search.) The 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. (PxPLUS retrieves
the data record internally with a READ RECORD.)
PREFIX FILE "fileprefix.dat"
OPEN(1)"customer" ! Internally this becomes
So you don't have to change anything in your
programming code, to alter your type of database. You only have to prepare the
keyed file from the PREFIX FILE.
As of version 4.23, a second field is allowed in
the keyed file for PREFIX FILE. This is an OPTIONS field. These OPTIONS are put
into the OPT= for the OPEN of the real path/filename. The above enhancement
allows an OPT= on the original OPEN, where the additional OPT= is appended to
any of the options from the second field of the PREFIX FILE record.
PREFIX FILE contains the following:
Key="GLMAST", DATA RECORD="[ODB]DSN;TABLE"+sep+"KEY=field1"
If you OPEN(chan)"GLMAST"
internally PxPLUS will:
If you OPEN(chan,OPT="REC=somedata")"GLMAST"
then internally PxPLUS will:
You can obtain the PREFIX FILE value by using
The PxPLUS default is to search all prefixes, in the following order:
For OPEN directives.
1) PREFIX FILE, if set. (Replaces pathname then continues sequence)
2) Current Directory (if íCDí parameter is set)
3) PREFIX 0 to 9
4) PROGRAM PREFIX, if set
5) Current Directory (if íCDí parameter is not set)
For LOAD / RUN / CALL / PERFORM / SAVE
1) PREFIX FILE if set (Replaces pathname then continues sequence)
2) Program Cache
3) Current Directory (if íCDí parameter is set)
4) PREFIX PROGRAM if set
5) PREFIX 0 to 9
6) Current Directory (if íCDí parameter is not set)
The PREFIX search rules apply not only to files
being found, but also to files being created. PxPLUS creates files in the
first location that is permitted by the PREFIX rules. If íCDí (Search Current
Directory) parameter is set, then all files are created in the current directory
(the first permitted location). If the íCDí parameter is not set, then PxPLUS
creates your file in the first location permitted by the search rules above.
You can use the ENABLE and DISABLE directives to control which of the numbered
prefixes PxPLUS will use in the search. (While scanning PREFIXes 0 to 9,
PxPLUS ignores any PREFIX that is DISABLEd.)
Note that the initial check for PROGRAM cache checks for a match against the
original file names. Thus, if you used CALL "ABCD" and you had previously loaded
a program with the same name, PxPLUS 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" and then change your directory / prefix and re-CALL "ABCD". If this
happens for duplicate program names in your system, either clear the CACHE or
donít use it.
Another thing you should avoid is to add the drive letter in front of the
pathname if the current drive is the same as the drive letter in the PREFIX.
SETDRIVE "C:" ! mostly this is the default
PREFIX "C:/myapp/data/ C:/myapp/files/ D:/mydir/somedir/ C:/pvx/lib/"
Better is :
PREFIX "/myapp/data/ /myapp/files/ D:/mydir/somedir/"
First, you don't need /pvx/lib in your
searchpath. Every PxPLUS utility or PxPLUS subdirectory can be found using
the * prefix. i.e. CALL"*web/email"
Second, by leaving out the drive letter, PxPLUS doesn't have to check if the
drive exists, and thus you'll have a big performance gain.
If possible, put the path with a different drive letter at the end of the search