NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to programmatically add a search directory path

Is there a way to do this from a CVI program?
0 Kudos
Message 1 of 3
(4,452 Views)
Currently, TestStand 2.0 does not provide any API to programmatically add a search directory path. The only way to programmatically add one would be to edit the "TestExec.ini" file located in the \Cfg folder. However, it is not recommended to do this since this file has a special format and is read whenever you launch TestStand. If the file doesn't have the right format or gets corrupted somehow, you won't be able to launch TestStand.

If you insist in editing the TestExec.ini file I would strongly recommend to look at the format of the other search directory paths before modifying the file. You'd need to do at list 3 modifications to it:

1. Under the [Config] section you'll need to find the following key:

%HI: SearchDirectories = [14]

Increm
ent the number in brackets (in this case 14 would become 15).

2. Add the following key under the [DEF, Config.SearchDirectories] section:
%[15] = Obj

Where the number in brackets should correspond to the upper limit in the Search Directory that we incremented in the previous step. In our case it was incremented from 14 to 15.

3. Add 2 new sections that correspond to the new directory added. In our example, you'd need to add the following:

[DEF, Config.SearchDirectories[15]]
Disabled = Bool
SearchSubDirs = Bool
FileExtRestrictions = Str
Path = Str

[Config.SearchDirectories[15]]
SearchSubDirs = True
Path = "C:\\NewFolder" (This would be the new directory path)

I hope this helps.

Regards,

Carlos Leon
0 Kudos
Message 2 of 3
(4,452 Views)
Hello,

As stated in the previous answers there is no way using the API to do this. However, you can write some code to add a search directory programatically. What you need to do is as follows:

1. Get a reference to the config file. You do this by calling Engine.ConfigFile. This will return to you a reference to the TestExec.ini file.

2. Clone one of the elements of the Search Directory list. The search directories are stored in an array, in which each element is a container that has the following fields: Disabled (Boolean), SearchSubDirs (Boolean), FileExtRestrictions (string), Path (string).

3. Insert the cloned element into the end of the Search Directories array.

4. Once the element is in the array, you can change any one of the fie
lds listed above.

5. Increment the change count and save the config file.

Note: The changes that you make to the config file will not take effect until you restart the Sequence Editor. This is due to the fact that we cache the config file when the Sequence Editor is loaded.

I have attached a sequence file that will do this. Depeneding upon the programming environment you are using, you can mimic the actions performed in this file in your code.

Hope this helps.
0 Kudos
Message 3 of 3
(4,452 Views)