08-20-2009 11:04 AM
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
Solved! Go to Solution.
08-20-2009 11:24 AM
Look at the NewSubProperty method in the TestStand help.
Locals.NewSubProperty("MyNewLocal",PropValType_String,False,"",0)
Regards,
08-20-2009 12:26 PM
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
08-20-2009 01:03 PM
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)
05-17-2013 08:27 AM
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?
05-20-2013 09:31 AM
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