PATHSCAN$ function  

Purpose

Find a file on disk and return the path and/or file name parts.

Syntax

fil$ = PATHSCAN$(director, filespec$[, pathspec$])

Remarks

The PATHSCAN$ function scans specified directories to find a particular file.  If the file is found, it returns either the full path/file name, or a selected part of it.  If the file is not found, a nul (zero-length) string is returned.  If you wish to simply parse a text file name, without regard to its validation on disk, you should use the companion function PATHNAME$.

director

This is one of the following words which is used to specify the requested part:

FULL

Return the full drive/path/file name.

PATH

Return the path portion of the path/file name.  That is the text up to and including the last backslash (\).

NAME

Return the name portion of the path/file name.  That is the text to the right of the last backslash (\), ending just before the last period (.) in the string.

EXTN

Return the extension portion of the path/file name.  That is the last period (.) in the string plus the text to the right of it.

NAMEX

Return the NAME and the EXTN parts combined.

filespec$

A file name which is expected to exist on disk.  It must not be an ambiguous name -- that is, it may not include a query (?) or an asterisk (*) character.

pathspec$

An optional path string which includes one or more paths to be searched to find filespec$.  If multiple path names are included in this string, they must each be separated by a semicolon (;) delimiter.  If pathspec$ is not given, or it is a nul (zero-length) string, the following directories are searched:

  1. The directory from which the application was loaded.

  2. The current directory.

  3. The Windows System32 directory.

  4. The Windows System16 directory.

  5. The Windows directory.

  6. The directories in the PATH environment variable.

See also

DIR$, PATHNAME$, PARSE, PARSE$, PARSECOUNT

Example

The following information assumes that the file named "MyFile.txt" currently exists in the directory "C:\PB".

f$ = "MyFile.txt" : p$ = "C:\MyDir;C:\PB"

PATHSCAN$(FULL, f$, p$) ' returns  "C:\PB\MyFile.txt"
PATHSCAN$(PATH, f$, p$) ' returns  "C:\PB\"
PATHSCAN$(NAME, f$, p$) ' returns  "MyFile"
PATHSCAN$(EXTN, f$, p$) ' returns  ".txt"
PATHSCAN$(NAMEX,f$, p$) ' returns  "MyFile.txt"