System Functions

PTH( )

Return Pathname


1. Get Pathname of File:


The following were added in PxPlus v7.00:

2. Get Full Pathname of File:

PTH(filename$ [, filename$, ...] [,ERR=stmtref])

3. Get Pathname of Dictionary:




Can be a numeric expression indicating the open channel number to use or a string expression containing the pathname or table name (if string is prefixed by the keyword TABLE) of the file to use.


String containing filename(s) whose existence is to be validated and full pathname returned.


Program line number or statement label to which to transfer control.

(TABLE support was added in PxPlus 2018.)


Format 1

Pathname of the open file specified by the value in filespec.

Format 2

Full pathname of the file specified in the filename. If none of the filenames provided exist, an Error #12: File not found exception is generated.

Any filename that starts with a square bracket (ODBC, Remote, or other special file type) is not validated but simply returned to the application.

Multiple filenames may be provided, comma-separated. If multiple filenames are provided, the path of the first file found will be returned.

Pathnames with the special file command tags [WDX] and [LCL] are supported by this format.

(The ability to specify multiple filenames was added in PxPlus v10.00.)
([WDX] and [LCL] support was added in PxPlus 2016.)

Format 3

Pathname of the current data dictionary file open.


The PTH( ) function returns the operating system path of the file specified. (The value returned is an ASCII string reporting the full pathname, including directories and the filename.)

If the file is a device (e.g. a printer), the device name is returned.

The file must be open for Format 1 of the PTH( ) function to operate.


With "/usr/ar"as current directory:

open (26)"PRODFL"
print "Just opened file: ",pth(26)

Just opened file: /usr/ar/PRODFL

PTH( ) returns the device name when the file is a device:

open (30)PRINTER$