Jump to content
styrum

Programmatically Changing Strictly Typed VI ref Constant or Control for Open VI Reference

Recommended Posts

 How can I programmatically change the VI which such constant uses (which we just drag onto it normally)? It is a just a "Constant" class according to its ClassName and can not be typecasted to anything else and doesn't seem to have any property or method to set that VI.

Share this post


Link to post
Share on other sites

Not clear on what you're trying to do, but... Open VI reference does not need a type specifier to open a reference. When the type specifier is passed in, then the VI at the VI path must conform to the front panel layout and data types. When the type specifier is not passed in, the To More Specific Class primitive can be used to change.

Share this post


Link to post
Share on other sites

I want to use a Call By Reference or a Start Asynchronous Call node in my TEMPLATE code. Which means I MUST have a type specifier constant (or control) wired to the Open VI Reference. In my CONCRETE code created based on the template code using VI scripting I need to replace the type specifier, or rather the VI which that type specifier extracts the connector pane from, so that the Call By Reference (or Start Asynchronous Call) node can use a new connector pane within themselves instead of the one it has in the template code. Normally (manually) we just drag and drop a VI with a desired connector pane onto type specifier constant or control. But how can we do that (tell it which VI to use) programmatically?

Edited by styrum

Share this post


Link to post
Share on other sites

Well, you don't do what you're describing in the way you're looking to. You could do what you're describing using invoke nodes to get/set control values and run the VI.

What problem are you trying to solve?

Edited by Tim_S

Share this post


Link to post
Share on other sites

Start with a control in your template.   Get a reference to that control and cast it to VIRefNum.  Then call the 'Make Strict Reference' method using a VI reference to the desired VI.  Finally, get the Terminal reference of the VIRefNum and invoke the method 'Change to Constant'.  The constant winds up in a different location, if you are OCD like I am then read the position of the control terminal before and write that position to the constant after.

It is pretty common to have more scripting versatility with a control or indicator than the corresponding constant.

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you, Darin! That's exactly what I needed!

By the way, what does OCD stand for in this context?

BTW2: After calling Change to Constant the constant appears instead of the terminal exactly at the same place the terminal used to be, just as if I right-clicked on the terminal and selected Change To Constant. Well, at least in LabVIEW 2016.

Edited by styrum

Share this post


Link to post
Share on other sites

For whoever is looking to do anything like this or anything else as far as programmatically changing code in a VI goes, I think I should remind that the best way to find and get a reference to any object you want to mess with on the FP or BD of the target VI is one of "hidden gems", <LabVIEW 20XX>\vi.lib\Utility\traverseref.llb\TRef Find Object By Label.vi

Share this post


Link to post
Share on other sites
5 hours ago, Darin said:

if you are OCD

My OCD is when people type "casted" as the past tense of "cast". Not helpful, I know but It drives me nuts! I'm the same with "set".

Edited by ShaunR

Share this post


Link to post
Share on other sites

OK. So OCD is "obcessive compulsive disorder" I figured. Sorry, sickos patients, my native language is not English, but I still know what past participle is and even, for example, when to use past perfect tense in English (How many Americans do?).😋 "Cast Operator: () (programming) A type cast provides a method for explicit conversion of the type of an object in a specific situation. v. cast, casted" (https://english.stackexchange.com/questions/94565/can-casted-be-the-past-tense-of-cast)

 

 

Edited by styrum

Share this post


Link to post
Share on other sites
22 hours ago, styrum said:

OK. So OCD is "obcessive compulsive disorder" I figured. Sorry, sickos patients, my native language is not English, but I still know what past participle is and even, for example, when to use past perfect tense in English (How many Americans do?).😋 "Cast Operator: () (programming) A type cast provides a method for explicit conversion of the type of an object in a specific situation. v. cast, casted" (https://english.stackexchange.com/questions/94565/can-casted-be-the-past-tense-of-cast)

 

 

It's a conjugation. I think Americans are the biggest perpetrators especially for "setted". They do other funny stuff like leaving out letters and putting dates the wrong way round :D

  • Haha 2

Share this post


Link to post
Share on other sites

Maybe that will work too (again with a control, not with a constant). But there is no explanation there regarding the type expected as the Conpane (variant) parameter of that Set Conpane method. How do we get that Conpane from a VI we want to take it from before we can feed it to that method?

Share this post


Link to post
Share on other sites

Call change to constant afterward if it matters to you (nearly zero effect on generated code since Open VI Ref cannot be constant folded). But (I’m not at machine right now) it would surprise me if that same property weren’t on the constant. You should check  

To get the conpane of a VI: https://zone.ni.com/reference/en-XX/help/371361R-01/lvscript/vi_connector_pane058datatype/

Or use this method on App refnum if the VI is not in memory (it reads the conpane without loading the VI): https://zone.ni.com/reference/en-XX/help/371361R-01/lvscript/app_getviconpane_datatype/

Share this post


Link to post
Share on other sites
On 5/4/2019 at 4:29 PM, ShaunR said:

It's a conjugation. I think Americans are the biggest perpetrators especially for "setted". They do other funny stuff like leaving out letters and putting dates the wrong way round :D

Even God appears to agree with Shaun....

Mark 1:34 “And he healed many who were sick with various diseases, and cast out many demons. And he would not permit the demons to speak, because they knew him.”

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.