NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

SearchAndReplace String Variable

Solved!
Go to solution

In the TestStand 2013 Process Model (NI_ReportGenerator), I am trying to modify the report after testing but before generating it. I've done this before in TS3.1/4.2 with no trouble but it's a bit trickier now.

 

This works on this variable which always exists at runtime:

 

Parameters.MainSequenceResults.TS.SequenceCall.SequenceFile= SearchAndReplace( Parameters.MainSequenceResults.TS.SequenceCall.SequenceFile, Locals.SequenceVA, FileGlobals.Parker.UUT.ReplaceWith )

 

However, the other variables may or may not exist so I generate them programatically. I make sure they exits, then do the same as above only I 'create' the name of the variable:

 

("Parameters.MainSequenceResults.TS.SequenceCall.ResultList[" + Str(Locals.Index) + "].TS.SequenceCall.SequenceFile")= SearchAndReplace(("Parameters.MainSequenceResults.TS.SequenceCall.ResultList[" + Str(Locals.Index) + "].TS.SequenceCall.SequenceFile"), Locals.SequenceVA, FileGlobals.Parker.UUT.ReplaceWith )

 

Doesn't work even though I've stepped through the sequence and verified the variable exists at run and matches the built string name.

 

Thinking the SearchAndReplace function was getting confused witht he Quotations I attempted to use an object reference to clean it up:

 

Locals.StringPointer=&("Parameters.MainSequenceResults.TS.SequenceCall.ResultList[" + Str(Locals.Index) + "].TS.SequenceCall.SequenceFile")

*Locals.StringPointer= SearchAndReplace(*Locals.StringPointer, Locals.SequenceVA, FileGlobals.Parker.UUT.ReplaceWith )

 

I verifed *Locals.StringPointer = to the variable name I am interested in.

 

I don't see the problem here. Is it just a limitation of SearchAndReplace? 

 

Any help appreciated, thanks.

 

0 Kudos
Message 1 of 6
(5,194 Views)

Hello,

 

A lot of the terminology used is specific for your application, so it's a little hard to follow. When you say it doesn't work, have you checked what the output: is there an error, is nothing returned, is the entire string returned? Maybe you could post a small example sequence file that demonstrates the behavior.

Taylor B.
National Instruments
0 Kudos
Message 2 of 6
(5,148 Views)

Sorry for the missing info. The string isn't changed by the SearchAndReplace Function.

 

Here is a TS2013 example. The string to change is in a Parameter container stirng array similiar to my problem. The string "Change this word -> dog" is created and attempted to change by programatically creating the Parameter Name. The SearchAndReplace does nothing.

 

Later, I use the SearchAndReplace with the Parameter Name directly and it works (dog -> cat).

 

I need to create the name programattically because I don't know how many String Array values there will be.

 

Thanks

Dave

 

 

0 Kudos
Message 3 of 6
(5,134 Views)
Solution
Accepted by topic author Cabman

Hello,

 

The example really cleared things up. It appears ("Parameters.Main.Test[" + Str(Locals.Index) + "]") is being evaluated as a String not as the actually value. Instead, try this expression:

 

Parameters.Main.Test[Locals.Index]= SearchAndReplace(Parameters.Main.Test[Locals.Index], "dog", "cat" )

 This way you get the looping that you want, and it programmatically sets the value. I will also attach the modifications that I made to your example.

Taylor B.
National Instruments
Message 4 of 6
(5,132 Views)

Ok that's embarrassing Smiley Embarassed  I believe that's where I started and it didn't work for me; but I must have had something else wrong. Works great both in the example and my original code.

 

Thanks, much appreciated.

0 Kudos
Message 5 of 6
(5,127 Views)

No problem! Happy to hear it's working.

Taylor B.
National Instruments
0 Kudos
Message 6 of 6
(5,125 Views)