CurrentPath Keyword

Description

The path to the current script file in the file system.

Notes

CurrentPath is a keyword whose value is the current path in the file system to the currently executed script file. This path is not including the file name. You can use this keyword to locate files at runtime.

To get the path and the name of a file, use:

CurrentPath + "\" + CurrentFile

Example

Consider this situation: You have a directory named Tests, which has the two sub-directories Scripts and Data, where the Scripts directory contains script files and the Data directory contains supporting files used by the scripts. To enable your scripts to locate the Data directory, you could define the following function in an include file in the Tests directory:

STRING GetDataDir () return
(CurrentPath + "\data") 

Any script calling the GetDataDir function can locate the Data directory, even if a parent directory moves or is renamed. For example, if the Tests directory is c:\rel2\tests, GetDataDir returns the following:

C:\rel2\tests\data

The CurrentPath keyword gets its value based on the file that contains the reference to CurrentPath, in this case, the include file in the Tests directory.

If the parent directory is renamed to rel21 and moved to the e: drive, GetDataDir still locates the Data directory correctly:

E:\rel21\tests\data