Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

ChDir

  • Last UpdatedJul 18, 2023
  • 2 minute read

ChDir statement changes the system environment current directory on the specified drive.

The parameter Path must be a string or expression that can represent a valid DOS file structure path value. The parameter Dir must be a string or expression that can represent a valid DOS file structure directory name. The Path and Dir parameters together, must be limited to less than 128 characters. The Path drive letter is optional, unless the directory is on another drive. The required Dir parameter must be a valid directory name.

Note: The file system keeps track of the current drive, and the current directory of every drive. Use the CurDir, CurDir$ statement to determine the current directory. The current drive letter can be extracted from the Left character returned in the CurDir statement.

The ChDir statement changes the current directory but not the current drive. To change the current drive, use the ChDrive statement.

Syntax

ChDirPath Dir

Path:

A string or expression that can represent a valid DOS file structure path value. This includes a directory name, and may include a relative or static directory or folder structure and drive letter, in the order:

[<driveletter>:][\<rootdirectoryname>][\<subdirectory> ... \<subdirectory>\] directoryname

Note that the path can be relative to the current directory. A single period represents the current directory (.), and two periods represent the parent directory of the current directory (..). For example:

chdir .. ' changes to the parent directory of the current directory

chdir ..\test ' changes to the test subdirectory of the parent directory

Dir:

A string or expression that can represent a valid DOS file structure directory name. Dir is not case sensitive. Dir is often used with the Path parameter.

ChDrive | CurDir, CurDir$ | Dir | MkDir | RmDir

Example

Dim strPath as String
strPath = CurDir()' store current path
ChDir "\"' change to root dir on current drive
<statements>' do stuff in root directory
ChDir strPath' change back to previous path

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in