NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to extract data from text file after searchstring

Hello,

i want to create an external file with some limits.

The file should be imported a teststart to globals.

In the limit teststeps i want to add a pre-expression that reads out the global and sets the limits.

 

The file looks like:

a_low=1.1

a_high=2.2

b_low=3.1

b_high=3.2

 

Currently i have a function that reads out the file content into a global string variable.

My question is:

Are there built in functions where i can pass this global variable + the name of a line (like "a_high) and it returns the numeric value behind it?

 

Thanks

0 Kudos
Message 1 of 4
(2,299 Views)

Is there a faster way than this?

Thanks for help

 


//Define Name to search in file
FileGlobals.Limit.LimitLowName = "limitname",

//1. Find Index of line in file
FileGlobals.Limit.IndexLineStart = Find(StationGlobals.Limits.FileContent,FileGlobals.Limit.LimitLowName),

//2. Find Index of separator in this line
FileGlobals.Limit.IndexLineSeparator = Find(StationGlobals.FileContent,"=",FileGlobals.Limit.IndexLineStart),

//3. Find Index of end in this line
FileGlobals.Limit.IndexLineEnd = Find(StationGlobals.Limits.FileContent,"\r\n",FileGlobals.Limit.IndexLineStart),

//4. Copy selection to step limit as numeric
Step.Limits.Low = Val(Trim(Mid(StationGlobals.Limits.FileContent,(FileGlobals.Limit.IndexLineSeparator+1) , (FileGlobals.Limit.IndexLineEnd - FileGlobals.Limit.IndexLineSeparator )))),

0 Kudos
Message 2 of 4
(2,279 Views)

Hello OnlyOne,

 

please take a look at the property loader step type which is made exactly for your use case.

 

https://zone.ni.com/reference/en-XX/help/370052R-01/tsref/infotopics/redesignedproploader/

 

Best regards

Andreas Gareis
Senior Applications Engineer, NI
Certified LabVIEW Developer & TestStand Architect
Message 3 of 4
(2,249 Views)

Hi,

thank you for the link. I already tested it. But it takes hours and 10000 clicks to do this for 500 teststeps.

So i simply created a loop that reads out my ini-file and directly creates StationGlobals of it. They are then used in the high/low settings of the teststeps.

I also do not 100% trust if the propertyloader is still working correctly if i delete one the 500 steps and create it new (= id changes).

In my solution i only have to reinsert the StationGlobal limit names and it will 100% work.

 

0 Kudos
Message 4 of 4
(2,242 Views)