styrum Posted May 1, 2019 Report Posted May 1, 2019 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. Quote
Tim_S Posted May 1, 2019 Report Posted May 1, 2019 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. Quote
styrum Posted May 1, 2019 Author Report Posted May 1, 2019 (edited) 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 May 1, 2019 by styrum Quote
Tim_S Posted May 1, 2019 Report Posted May 1, 2019 (edited) 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 May 1, 2019 by Tim_S Quote
Darin Posted May 1, 2019 Report Posted May 1, 2019 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. 1 1 Quote
styrum Posted May 1, 2019 Author Report Posted May 1, 2019 (edited) 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 May 1, 2019 by styrum Quote
styrum Posted May 1, 2019 Author Report Posted May 1, 2019 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 Quote
ShaunR Posted May 1, 2019 Report Posted May 1, 2019 (edited) 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 May 1, 2019 by ShaunR Quote
styrum Posted May 3, 2019 Author Report Posted May 3, 2019 (edited) 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 May 3, 2019 by styrum Quote
ShaunR Posted May 4, 2019 Report Posted May 4, 2019 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 2 Quote
Aristos Queue Posted May 4, 2019 Report Posted May 4, 2019 The method I think you’re looking for is this one: https://zone.ni.com/reference/en-XX/help/371361R-01/lvscript/virefnum_set_conpane/ Quote
styrum Posted May 4, 2019 Author Report Posted May 4, 2019 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? Quote
Aristos Queue Posted May 5, 2019 Report Posted May 5, 2019 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/ Quote
shoneill Posted May 6, 2019 Report Posted May 6, 2019 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 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.” Quote
paul_cardinale Posted May 20, 2019 Report Posted May 20, 2019 Is this what you are trying to di? Scripter.vi Template.vi Quote
paul_cardinale Posted August 23, 2019 Report Posted August 23, 2019 Is this what you are trying to do? My Script.vi My Template.vi Setup Static VI Ref.vi Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.