NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

searchfiles

Solved!
Go to solution

I am trying to use searchfiles API in teststand by calling Engine.SearchFiles. I am trying to search a string called "OUT". When i execute the steps, i dont see any results that is matched. But i am sure every other file has the word "OUT" in it.

 

I always get the NumMatches output as 0. Unable to figure out what the actual problem is.

 

COuld anybody please help ? I am actually using this method to get the results and store it in a file. I cannot use Find/Replace dialog for the same,

 

0 Kudos
Message 1 of 14
(4,053 Views)

Did you use the IsComplete method?  From the TS Help:

 

Purpose
Begin a new find in files search.

Remarks
Returns a SearchResults object that is a handle to the asynchronous search already in progress. To wait for the search to complete, call the SearchResults.IsComplete method.

 

I couldn't see your sequence file because it is newer than my version.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 14
(4,047 Views)

Hi Jiggawax,

 

I used the IsComplete method. But still i couldnt get the result. The IsCOmpleteMethod always returns True and the NumMatches always 0

I have attached the snapshots for your reference since you are unable to open my sequence..

Download All
0 Kudos
Message 3 of 14
(4,045 Views)
Solution
Accepted by topic author Krischai81

I threw together an example.  It works nicely for me.  I found that it doesn't search the file names for the string.  Odd???  Maybe NI can explain that one.

 

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 4 of 14
(4,004 Views)

Hi jigg,

 

The search function at edit time searches only the sequence file data (Runstate.SequenceFile.Data property) of the sequence file when searching, which does not contain the sequence file path or name.  You will notice the same behavior when using the search pane in sequence editor.

Al B.
Staff Software Engineer - TestStand
CTA/CLD
0 Kudos
Message 5 of 14
(4,001 Views)

Hi Jigg,

 

Thanks for the reply. The solution you gave me works. But could you please enlighten me why the ActiveX calls i used in my sequence doesnt work. Is there any reason for it ? Does the Sequential Process model doesnt support it ?

 

Thanks

Kris

0 Kudos
Message 6 of 14
(3,996 Views)

They are both valid ways to call into the TestStand API.  The ActiveX steps should not be affected by the process model or any other code in your sequence file.  They are direct calls to the engine.  However, you had it creating an object in your first step.  Not sure what that will do?  To eliminate that aspect of it I just use the expression calls.

 

Maybe it's using a different engine object???... i'm really not sure.  Sorry I don't have more information on that.  If I had your code I could've figured it out but i'm lame and haven't upgraded just yet.  I didn't care to recreate it using the ActiveX steps.

 

Do you need ot use the ActiveX steps?

 

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 7 of 14
(3,993 Views)

Hi Jigg,

 

I will do a one to one comparison and figure it out. Will post immediately after I find the reason. I dnt really need to use ActiveX calls, but pretty curious to know the reason. But thanks for the update, I will keep you posted.

 

Thanks

Kris

0 Kudos
Message 8 of 14
(3,991 Views)

Hi Jigg,

 

I figured out the error in my sequence file.

When i call the "SearchFiles" Method, the parameter "directoriesAndFilePaths" was given a variable which had a path like "C:\\Test\\Example\\Search.seq". But when i replaced the "\\" with Single Slash ("\"), the sequence started working.

 

I am not sure why. I had always assumed TestStand recognizes "\\", when specifying a path instead of "\".

 

Are you aware of such situations when "\\" should be used or "\" should be used when specifying the path of a directory?

 

Thanks

Kris

0 Kudos
Message 9 of 14
(3,985 Views)

Yeah I noticed that too when I created the example.  Honestly I haven't nailed that down yet.  In this case I think it's because the method wants the paths without the escape characters.  Usually it's just trial and error for me...

 

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 10 of 14
(3,975 Views)