Changes the current working directory on a specified drive and changes the current drive, if specified.
SYS_SetDir (sDir)
Variable | Description |
---|---|
sDir | The name of the directory to make the current working directory. STRING. |
This function sets the working directory for all Silk Test Classic agents that are currently connected. If you use both the Classic Agent and the Open Agent, SYS_SetDir() sets the directory for both agents in order to keep the working directories synchronized.
An exception is raised if the directory does not exist, or if you do not have appropriate access privileges for the directory.
If a drive is specified in the call to SYS_SetDir, then the function changes the current drive, in other words, functioning like a call to SYS_SetDrive. In the following example, both test case Test1 and Test2 print d:\test.
[-] main() [ ] SYS_SetDrive("c") [ ] SYS_SetDir("\qap4") [ ] Test1() [ ] Test2() [ ] [-] testcase Test1() [ ] SYS_SetDir("d:\test") [ ] Print(SYS_GetDir()) [ ] [-] testcase Test2() [ ] SYS_SetDrive("d") [ ] SYS_SetDir("\test") [ ] Print(SYS_GetDir())
In the Windows environments, SYS_SetDir is executed by the agent process, not the Silk Test Classic process. To affect the host process, use the function with the hHost notation or machine handle operator. For more information about the machine handle operator and hHost, see Machine handle operator.
[-] testcase SYS_SetDirExample () [ ] STRING sDir [-] LIST OF STRING lsDirs = {...} [ ] "c:\mydir" [ ] "d:\mydir" [ ] BOOLEAN bFound = FALSE [-] for each sDir in lsDirs [-] if (SYS_DirExists (sDir)) [ ] SYS_SetDir (sDir) [ ] bFound = TRUE [ ] break [-] if (! bFound) [ ] Print ("Unable to change to directory")