I'm trying to programmatically (using expressions) create an Array of Containers and set the container elements using an expression:
ThisContext.AsPropertyObject.SetPropertyObject("Locals.IO",PropOption_InsertIfMissing,ThisContext.Engine.NewPropertyObject(PropValType_Container,False,"",0)),
ThisContext.AsPropertyObject.SetPropertyObject("Locals.IO.IOToBeProcessed",PropOption_InsertIfMissing,ThisContext.Engine.NewPropertyObject(PropValType_Container,False,"",0)),
Locals.SetValString("IO.IOToBeProcessed.Name",PropOption_InsertIfMissing,""),
Locals.SetValNumber("IO.IOToBeProcessed.Modbus Address",PropOption_InsertIfMissing,0),
Locals.SetValString("IO.IOToBeProcessed.Type",PropOption_InsertIfMissing,""),
Locals.SetValString("IO.IOToBeProcessed.Raw Signal",PropOption_InsertIfMissing,""),
Locals.SetValNumber("IO.IOToBeProcessed.Raw Min",PropOption_InsertIfMissing,0),
Locals.SetValNumber("IO.IOToBeProcessed.Raw Max",PropOption_InsertIfMissing,0),
Locals.SetValNumber("IO.IOToBeProcessed.Scale Min",PropOption_InsertIfMissing,0),
Locals.SetValNumber("IO.IOToBeProcessed.Scale Max",PropOption_InsertIfMissing,0),
Locals.SetValString("IO.IOToBeProcessed.Tag",PropOption_InsertIfMissing,""),
Locals.SetValString("IO.IOToBeProcessed.Notes",PropOption_InsertIfMissing,"")
The above works fine, but it does not create IOToBeProcessed as an array of the elements I added after creating that container. If I change my code to this:
ThisContext.AsPropertyObject.SetPropertyObject("Locals.IO",PropOption_InsertIfMissing,ThisContext.Engine.NewPropertyObject(PropValType_Container,False,"",0)),
ThisContext.AsPropertyObject.SetPropertyObject("Locals.IO.IOToBeProcessed",PropOption_InsertIfMissing,ThisContext.Engine.NewPropertyObject(PropValType_Container,True,"",0)),
Locals.SetValString("IO.IOToBeProcessed.Name",PropOption_InsertIfMissing,""),
Locals.SetValNumber("IO.IOToBeProcessed.Modbus Address",PropOption_InsertIfMissing,0),
Locals.SetValString("IO.IOToBeProcessed.Type",PropOption_InsertIfMissing,""),
Locals.SetValString("IO.IOToBeProcessed.Raw Signal",PropOption_InsertIfMissing,""),
Locals.SetValNumber("IO.IOToBeProcessed.Raw Min",PropOption_InsertIfMissing,0),
Locals.SetValNumber("IO.IOToBeProcessed.Raw Max",PropOption_InsertIfMissing,0),
Locals.SetValNumber("IO.IOToBeProcessed.Scale Min",PropOption_InsertIfMissing,0),
Locals.SetValNumber("IO.IOToBeProcessed.Scale Max",PropOption_InsertIfMissing,0),
Locals.SetValString("IO.IOToBeProcessed.Tag",PropOption_InsertIfMissing,""),
Locals.SetValString("IO.IOToBeProcessed.Notes",PropOption_InsertIfMissing,"")
This sets the property "AsArray" for the container, so IOToBeProcessed would then be created as an array, which is what I need. Unfortunately, TestStand then starts complaining that I can't add elements to the container as its part of an array:
The post-expression for the step 'IO' could not be evaluated.
Error in call to TestStand API member 'PropertyObject.SetValString'.
You cannot create a subproperty in an item that is not a container.
Error accessing item 'IO.IOToBeProcessed.Name'.
Where am I going wrong, how do I get IOToBeProcessed to be an array of said elements?
Thanks in advance