09-23-2019 09:05 AM
Hi again folks, next conundrum.
I have inherited a large user test GUI that besides other things, sets up an active x control to write to a database, all works fine within the GUI.
However I need to write to this same database reference, from within the teststand script that's being run.
Effectively I need to pass the COM reference generated by the GUI, to a variable in the script. So that when the script runs it's VI to write to the database, it can pick up the reference that's already been generated by the GUI.
I have tried making use of this tutorial to accomplish this but it's not worked so far: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000kHD9SAM&l=en-GB
Attached are some screenshots.
Please help!
Thanks, Tom
09-23-2019 09:26 AM
Why don't you make your local variable an object reference and then in your set teststand property value change it from a string to an object?
That way you don't have to typecast to a number and then a string.
09-23-2019 09:30 AM
Hi yes I had actually though of that too. But that aside, should this work? Have I done it correctly?
Will the value magically land in locals.X3ID? or do I need a more elaborate/accurate lookup string?
Excuse my lack of LV experience.
09-23-2019 09:43 AM - edited 09-23-2019 09:44 AM
Actually wiring the refnum to type object didn't work, I got the following:
"You have connected a refnum of one type to a refnum of another type and both types are members of some class hierarchy, but there is neither a simple up cast nor type cast between the two classes."
09-23-2019 04:05 PM
I went and looked at some code where I was passing the Application Manager back to my sequence file (not recommended in most cases). It is an ActiveX object and I realized I used the SetValVariant method.
09-24-2019 04:53 AM
So from looking at your example my code looks viable right?
I have "X3 Com Refnum" set to deliver to "Locals.X3ID" as a string, under event case number "10010"
In my sequence I have the following statement:
"RunState.Thread.PostUIMessageEx(UIMsg_UserMessageBase + 010, 0, "" , Nothing, True)"
How exactly will that statement trigger the VI to deliver that value to the required variable, and do I need to use a parameter instead of local variable?
Many thanks!
09-26-2019 06:12 PM
You need to use the SetValVariant instead of the TestStand set property. Look at my code.
10-01-2019 02:51 AM
Okay so I went into the Teststand Set Property node which contains the Invoke node and set it to SetValVariant. How does this screenshot look.
10-01-2019 02:54 AM
So regarding your code, what do you put in your TS statement that causes this code to run and populate the variable?
Thanks!
10-01-2019 08:35 AM
My screenshot shows what I put in my TestStand sequence to invoke this callback. In my case I'm sending the application manager which is an active X control. In your case you will just send the active X reference from your first post.
Regards,