NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically create local variable in TestStand

Solved!
Go to solution

Can somebody please explain the process of creating a local variable programatically?  I have searched the forums but haven't found what I am looking for yet.

 

I have an array of unknown size.  I use a foreach loop to step through the array and grab the data that I need.  I need to put that string in a Local String Variable that I can use later.

 

Any help is much appreciated.

 

Matt

0 Kudos
Message 1 of 6
(6,795 Views)
Solution
Accepted by topic author Matt Kniller

Look at the NewSubProperty method in the TestStand help.

 

Locals.NewSubProperty("MyNewLocal",PropValType_String,False,"",0)

 

Regards,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 2 of 6
(6,791 Views)

That did exactly what I wanted it to do thank you.  Now I want to take it one step further...

 

I have a local variable array called RI_Equipment that is of an unknown size.  The array contains a container data.  I want to create a variable of name ri_nameField+"_ID" and then set the value of that variable to what is contained in RI_Equipment[x].ri_IDField.  Hope that all makes sense.  Below is the statement I have in TestStand however TS tells me that this will cause a run-time error.  What am I doing wrong?

 

Locals.NewSubProperty(Locals.RI_Equipment[Locals.loopcounter].ri_nameField+"_ID",PropValType_String,False,"",0) = Locals.RI_Equipment[Locals.loopcounter].ri_IDField

 

Matt

0 Kudos
Message 3 of 6
(6,785 Views)

I figured it out...

 

Locals.NewSubProperty(Locals.RI_Equipment[Locals.loopcounter].ri_nameField+"_ID",PropValType_String,False,"",0), Locals.SetValString(Locals.RI_Equipment[Locals.loopcounter].ri_nameField+"_ID",0,Locals.RI_Equipment[Locals.loopcounter].ri_IDField)

0 Kudos
Message 4 of 6
(6,769 Views)

I have exactly this statement in an Action Step preost-expression.

 

Locals.NewSubProperty("MyNewLocal",PropValType_String,False,"",0)

 

The test does not give an error message but I do no see a local variable being created (looking in the Variables pane)

 

Any ideas?

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

There is a separate runtime version of the locals versus the edit time version. Which are you trying to edit? The statement you are using edits the runtime version. The runtime version is only viewable from the variables pane of the execution, you will not see the change in the sequence file's variables pane.

 

-Doug

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