NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Include a string value into a step parameter name

Solved!
Go to solution

Hello,

 

I would like to include a string value into the "name" of a step parameter but I didn't found how to do this.

 

To be clear, I have a container with 5 strings ("A","B","C","D","E", for exemple) and I have locals.Results.A, locals.Results.B, etc.

 

I'm doing a foreach on my container and I want to save the result of my calulation in the good locals.Results but I don't know how to "use" my strings values to complete the value that i have to set for the parameter name of my sub sequence (I tried locals.Results.(container.string1) but it does not functionning)

 

Unfortunaly, I can't send a screen shot of my work, but if it's needed, I'll create a "false sequence".

 

I hope i have been clear.

 

Sincerely,

Jonathan

0 Kudos
Message 1 of 7
(3,689 Views)

In Pre-Expression or Post-Expression, you could add "Step.Name=" and after that add an expression that includes your desired string.

0 Kudos
Message 2 of 7
(3,663 Views)

First of all, thank you for answering me.

 

But I think that it's not what I need.

Indeed, I could effectively rename my step dynamically, but it won't change the name of my subsequence parameter.

 

In the exemple attached to this message, I show what I want to do (obviously, my sequence have much more parameters).

The goal is to set the parameter_OUT as : "Locals.Results." + the value of the current element. So when the current element is "a", I set the Parameter_OUT as : "Locals.Results.a"

 

I hope it's clearer.

 

Thanks a lot,

 

Sincerely,

Jonathan

Download All
0 Kudos
Message 3 of 7
(3,646 Views)

I think that I found a solution.

 

It seems that we can use the GetValString function to perform this.

 

Locals.Results.GetValString(mycurrentstring;0)

 

I'll try it on next tuesday on report it here if it's functionning

0 Kudos
Message 4 of 7
(3,632 Views)

In fact, this method is functionnning only for passing parameters by value, but I need to pass them by reference, so, it is not the solution.

0 Kudos
Message 5 of 7
(3,604 Views)
Solution
Accepted by topic author JonathanFrem

Here is a solution to conturn the problem.

 

 

In a foreach (Locals.ActualTest in Locals.Test) loop

Locals.Test is a string array in my exemple

 

- Save the results in a locals.Numeric1

- Then save the result in the good Locals.Results.TestX by using the SetValNumber method in a statement :

==> Runstate.Main.Locals.SetValNumber("Results."+locals.ActualTest;0x1;locals.Variable)

It will create the variable and register the value inside.

 

Thanks to all who has worked on my issue.

I let this topic openned for the week in the case of somebody has a better solution.

 

Jonathan

0 Kudos
Message 6 of 7
(3,597 Views)
Solution
Accepted by topic author JonathanFrem

I found an other solution.

 

We can use the "Evaluate" function to do this.

Here's an exemple :

 

Evaluate("Results."+locals.ActualTest)

 

Teststand warn me about a "syntax error" when I use this but it is functionning.

 

Sincerely,

Jonathan

0 Kudos
Message 7 of 7
(3,472 Views)