01-30-2024 07:04 AM
Hi,
I am doing some strange lowlevel stuff again...
My overall goal is to modify the TypePaletteFile List and reload for a special use case
RunState.Engine.GetTypePaletteFileList() returns an ObjectArray
using AsPropertyObject.InsertElements(Locals.Count,1, 0) I can add an element to the array, at least the Variables View reflects this.
But I am failing to assign a value to the newly created array element via AsPropertyObject[Locals.Count] = ...
Can anyone please nudge me in the right direction?
Thanks Oli
TS2019 BTW
Solved! Go to Solution.
02-01-2024 08:22 AM - edited 02-01-2024 08:22 AM
Additional information: the error message is independant of which kind of data is being assigned.
02-01-2024 09:25 AM - edited 02-01-2024 09:26 AM
Can you provide a complete excerpt of the statement expressions that you are using?
02-01-2024 09:43 AM
Sure!
Locals.ObjectArray = RunState.Engine.GetTypePaletteFileList(),
//RunState.Engine.UnloadTypePaletteFiles(),
Locals.Count = Locals.ObjectArray.AsPropertyObject.GetNumElements() ,
Locals.ObjectArray.AsPropertyObject.InsertElements(Locals.Count,1, 0),
Locals.TempArray.AsPropertyObject[Locals.Count] = Locals.NewPalette
//Locals.NewPalette holds a ref to a palette created in a previous step
Thanks for your time!
02-05-2024 05:05 PM - edited 02-05-2024 05:09 PM
Ok. A few mistakes.
You don't need to cast to get access of the array object. Just do this:
// create palette file
Locals.NewPalette = RunState.Engine.NewPropertyObjectFile(FileType_TypePaletteFile),
// set properties of file object, uncomment next line to use
// Locals.NewPalette.Path = "C:\\path\\to\\file\\NewPalette.ini",
// Read file, uncomment next line to use (not sure if this is needed)
// Locals.NewPalette.ReadFile(ConflictHandler_Prompt),
// make sure Locals.ObjectArray is declared as an Array of Object Reference
Locals.ObjectArray = RunState.Engine.GetTypePaletteFileList(),
Locals.Count = GetNumElements(Locals.ObjectArray),
InsertElements(Locals.ObjectArray, "[" + Str(Locals.Count) + "]",1),
// if you want to use Count again, update the value as the array was just updated
Locals.Count = GetNumElements(Locals.ObjectArray),
// add file to list
Locals.ObjectArray[Locals.Count-1] = Locals.NewPalette,
02-06-2024 08:15 AM
Thanks for the insights!.... so I basically went wrong thinking I can't handle a SAFEARRAY as an array of object references in TestStand.