Jump to content

How to get the reference of a control inside a tab


Recommended Posts

If you get the reference from vi-server then use it this way (don't forget to close the references of the elements not needed anymore, or you loose memory)

post-253-1097731076.png?width=400

The order of the control references in "Pnl" and "Page" is the creation order of the controls, independent of the order designated by the user (via rmb: "reorder controls on page").

Didier

Link to comment
  • 10 months later...
great - thank you a lot

it works perfectly.

but i don't know why it has to be so complicate.

why don't they just use a reference id to communicate with a control,

like hypercard did : send (this message) to (control id x) ???

i think this aspect could really be improved

but it works !

2315[/snapback]

The above method is for dymanic references.

If you only need a reference to a few, static items

just right click on the item and create a reference.

This reference can be saved in a global varaible and acesses

by any vi.

Much simpler but requires manual creation of each reference

Use the general menthod if you want to create references to all

the items. And look at the Lable text to tell which is which.

I use both methods.

Link to comment
 

If you only need a reference to a few, static items 

just right click on the item and create a reference. 

This reference can be saved in a global varaible and acesses 

by any vi. 

5980[/snapback]

 

Oh no. Please don't use global variables of ctrl references. If you absolutely must store the reference somewhere, use a functional global (while loop with shift register). Also, I'm NOT a proponent of writing directly to front panel controls from one VI to another because it makes code unnecessarily obfuscated. When debugging problems, it's hard to know what is coming from where.

Link to comment
Oh no. Please don't use global variables of ctrl references. If you absolutely must store the reference somewhere, use a functional global (while loop with shift register). Also, I'm NOT a proponent of writing directly to front panel controls from one VI to another because it makes code unnecessarily obfuscated. When debugging problems, it's hard to know what is coming from where.

5984[/snapback]

I understand where you're coming from. It's not a technique for beginners. But it has some powerful applications too. There is more discipline to it that I've mentioned. I make several Tag and Reference cluster arrays at init time and store these in a global. Then one, reentrant, program provides subsets of these references to other programs, in a library of core functions, based on Tag types. These then perform common functions for these tags without any additional code in the application. (yes invisibly, therefore somewhat obfuscated, but the presence of the Tag text gives something to track when debuging since each reentrant call holds the list of tags used at each location)

This allows common tasks to be carried out seamlessly, elsewhere. Like Data logging, Alarm limits checking and Scaling before and after I/O. Leaving the customer-specific main diagram virtually empty, except for the code unique to that customer.

This makes a core library that can be quickly copied from one job to the next. Growing more intelligent as it goes.

The key is to devise logical naming conventions for the tags, so they communicate their function just by the name. And syntax checking code can be added were needed to be sure all the needed tags are present, tag sets match, and find orphan tags, not handled anywhere. The Menu functions are also processed in the core. And the screen backgrounds are a collection of png files, created from a power-point file, made by the design engineer. As is the I/O list, from Excel.

It's been a very successful concept. I call it programming by reference, and use it in Altamira's BenchCAT

Link to comment

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.