Skip to main content
Version: Next

Test path name

Test path name ( pathname : Text ) : Integer

ParameterTypeDescription
pathnameText→Pathname to directory, folder or document (system syntax)
Function resultInteger←1, pathname refers to an existing document 0, pathname refers to an existing directory or folder <0, invalid pathname, OS file manager error code
History
ReleaseChanges
6Created

Description​

The Test path name function checks if a document or folder whose name or pathname you pass in pathname is present on the disk. You can pass either a relative or absolute pathname, expressed in the syntax of the current system.

If a document is found, Test path name returns 1. If a folder is found, Test path name returns 0.

The following predefined constants are provided by 4D:

ConstantTypeValue
Is a documentInteger1
Is a folderInteger0

If no document nor folder is found, Test path name returns a negative value (i.e. -43 for File not found).

Example​

On Windows, the following tests if the document "Journal.txt" is present in the "Data" folder of the project, then creates it if it was not found:

 If(Test path name("\\Data\\Journal.txt")#Is a document)
    $vhDocRef:=Create document("\\Data\\Journal.txt")
    If(OK=1)
       CLOSE DOCUMENT($vhDocRef)
    End if
 End if

See also​

Convert path system to POSIX
Create document
CREATE FOLDER
Object to path
Path to object

Properties​

Command number476
Thread safeyes