Is it at all possible to read array-based properties using ServerObject.Interface in Scripting?
I am trying to read out the VectorValues property of a CProfileFloat profile object and populate a Form with the individual array values.
I can't get ServerObject.Interface to work at all as it complains about type mismatches.
I was doing something like:
Set FlowProfile = Server.FindObject(sFlowProfilePointFullName)
Vector1 = FlowProfile.Interface.VectorValues(0)
which did not work.
What is the correct way to do this?
Solved! Go to Solution.
@rlao works for me...
Dim scxServer As ScxV6Server Set scxServer = New ScxV6Server scxServer.Connect "Test", "superuser", "superusersuperuser" Dim objDoubleArray As ScxV6Object Set objDoubleArray = scxServer.FindObject("New Float") Dim arrDoubleArray arrDoubleArray = objDoubleArray.Property("VectorValues")
[apologies for bad variable names etc etc... definitely awkward having an array called 'arrDoubleArray' that is full of 'Singles' ;)]
The following JScript example works in a mimic script:
var Profile = Server.FindObject( "Time Profiles.Float" ); var Values = Profile.Interface.VectorValues; var Times = Profile.Interface.VectorTimes; var FirstValue = Values.getItem(0); var FirstTime = Times.getItem(0);
I've not tried this from VBScript.
I'm trying to do this in VBScript, but your reply actually helped me figure out what I was doing wrong.
Basically, in addition to what I was doing in my original post, I was also trying to read VectorValues out into a ReDim variable sized to the MaxVectors of the float profile. Turns out that doesn't work and the solution was actually much, much simpler than what I was trying to do.
It was more or less like your JScript answer:
Set FlowProfile = Server.FindObject(sFlowProfileFullName) Dim FlowArray FlowArray = FlowArray.Interface.VectorValues Flow1 = FlowArray(0) Flow2 = FlowArray(1) Flow3 = FlowArray(2) etc...
Extremely simple and I can't believe it took me this long to figure out.
Discuss challenges and get support in energy and automation with 30,000+ experts and peers.
Over 10,000+ support articles are available to help you find answers to your product and business challenges.
Find peer based solutions to your questions. Provide answers for fellow community members!