How to find file(s) in subproject

Find and share HowTos to various installations / configurations!
4 posts • Page 1 of 1
tgdannemiller
Posts:23
Joined: Thu Apr 21, 2016 3:29 pm

How to find file(s) in subproject

Post by tgdannemiller »

I have a project that uses a couple of subprojects. In my project, there is a script that looks for some files using getFileNames() and getPath(). The files can be found if they are in the main project, but not if they are in a subproject (instead of in the main project). The vision UI manager is able to find panels even when they are only in a subproject, so I'm wondering if there is a function I can use in my script to find a file, even if it is in a subproject? Or do I have to write my own script code to move individually through the subprojects looking for the file?

Code line: getFileNames(getPath(PANELS_REL_PATH,"vision/keyInfo")));
The line above finds the files only if they are in the main project.

Thanks,
Tom

mkerk
Posts:75
Joined: Wed Oct 20, 2010 12:25 pm

Re: How to find file(s) in subproject

Post by mkerk »

Hello,

getPath has an optional parameter "int level":
string getPath(string keyword[, string filename[, int langId = activeLang[, int level = 1]]]);

With this parameter you can define in which Level of all directories (= all proj_path(s) and pvss_path entries, which are defined in the general sections of the project config-file) you want to search the path.

Level = 1 is the main project directory (proj_path).
Level = SEARCH_PATH_LEN is the WinCC OA version directory (pvss_path).

For example if you want to determine the absolute path for the /panels/vision/keyInfo in your first Subproject (level = 2), than you have to call:
getPath(PANELS_REL_PATH,"vision/keyInfo/",1,2);
The second parameter is the langId (it´s relevant when you want to search for a language dependent directory, e.g. help or msg dir).

If you have several subprojects and you don´t know in which level the file is saved, than you have to call getPath in a for loop (for (int i=1;i

Gertjan van Schijndel
Posts:634
Joined: Mon Aug 02, 2010 10:37 am

Re: How to find file(s) in subproject

Post by Gertjan van Schijndel »

Thomas Dannemiller wrote:
so I'm wondering if there is a function I can use in my script to find a file, even if it is in a subproject?
The function 'getPath' returns the first absolute file name of a (relative) file, even if it is in a subproject.

However 'getFileNames' searches only in an absolute directory, so you will need to call this for all (sub)projects.

tgdannemiller
Posts:23
Joined: Thu Apr 21, 2016 3:29 pm

Re: How to find file(s) in subproject

Post by tgdannemiller »

Yes Gertjan, I see now if the filename is known and specified, getPath() will find it no matter whether it is in the main project or a subproject, as in the following:

getPath(PANELS_REL_PATH, "vision/keyInfo/AGTkeyInfoPanel1.xml");

If the filename is not known and is being searched for, then a loop is needed as explained by Mousser.

Thanks to you both for the helpful responses.

4 posts • Page 1 of 1