Skip to content

Set_dfpath Command

Obsolete

This command is obsolete and is valid only in character-mode DataFlex.

See the cWorkspace class for information about pathing in DataFlex.

See Also

Purpose

To identify the directories to be searched when file commands are executed on filenames that do not themselves specify the directory.

Syntax

set_dfpath to directory(ies)

What It Does

Set_dfpath replaces the value (if any) of the DFPATH environment variable with the directory(ies) identified in directory(ies).

set_dfpath to postInventory

In this example, the value of the DFPATH environment variable is replaced by the value of the string variable postInventory.

To suppress DataFlex pathing entirely, execute:

set_dfpath ""

Set_dfpath must be used in the program above all file commands that are to make use of it. Set_dfpath may be used multiple times in a program, but it should not be changed while any file is open.

The value of directory(ies) specifies the directory or directories that are to be searched whenever a DataFlex command calls for the opening, creation, deletion, renaming, or copying of a file, including database (.dat) files. The directories are searched in the order in which they are named.

The current directory will not be searched unless it is named in directory(ies) (or directory(ies) is empty). The current directory may be placed in the search path by using a period (.) as a pathname.

DFPATH is used only for files that are named without path specification. Where a statement includes a directory path with the filename, or the directory name of a database file in the file list contains a directory, DFPATH will have no effect.

Different commands use DFPATH somewhat differently:

  • Erasefile and Renamefile search only the first directory path named.
  • Copyfile searches only the first directory path and places the copy in the first directory path.
  • Open, Make_file, and Direct_input open the first file with the specified name found in the directories.
  • Append_output and Direct_output open the first file with the specified name found in the directories to which the user has write privileges. If none is found, a new file is created in the first directory in which the user has write privileges.

Notes

  • When directory(ies) contains directory paths that do not exist, most operating systems report an error. The error reported in such cases will vary by operating system and will not be generated until a file command makes use of the value of directory(ies).

  • Set_dfpath does not change the value of the DFPATH environment variable—it merely replaces the value for purposes of the program by setting the DF_OPEN_PATH attribute, which you can access with the Get_Attribute command. If you wish to restore the value from the environment variable, you can do so with the Get_environment command.