Jump to content

Dynamically create references?


Recommended Posts

Hi,

I am using LV8.6. I have created a LV class e.g. "ClassA".

In a VI I can now manually create 10 Controls of type "ClassA" and create a Reference for each of these Controls.

This is the way I usually create my references to objects (e.g. of type "ClassA").

I do work with these objects using call by reference methods, this works so far.

But instead of this "manual reference creation" can I create references to objects of type "ClassA" by using something like an

"Open class reference.vi" and typecast it to any of my classes?

Just like the way like I can create VI References using "Open Vi Reference.vi"

Any help is very appreciated!

Best regards,

Stefan

Link to comment

QUOTE (normandinf @ Dec 16 2008, 03:06 PM)

Hmmm... with "Get LV Class Default Value.vi" I don't think that I can create a new object of e.g. type ClassA. I only read the standard values, don't I.

Or is there a way to get a reference of each object that was created that way? This is what I really need.

The same kind of reference I get like when I rightclick a control and create a reference to that control element.

Stefan

Link to comment

QUOTE (Milchbilch @ Dec 16 2008, 03:25 AM)

But instead of this "manual reference creation" can I create references to objects of type "ClassA" by using something like an

"Open class reference.vi" and typecast it to any of my classes?

Just like the way like I can create VI References using "Open Vi Reference.vi"

The "Open class reference" is a reference to your class. What you are looking for is a reference to your object that is an instance of your class. These are two very different things. No, there is no object reference built into LabVIEW. You have to do something that dynamically creates a data storage location. Your options include

  1. opening a new VI [either by duplicating a template or cloning a reentrant VI] which you could then use to store data either in controls [through the Value property] or in uninitialized shift registers [as per functional global]
  2. creating a queue or notifier of the desired type
  3. using some sort of global VI with an array of objects and adding a new position in the array
  4. etc... I'm sure there are more if you get creative

The class reference is a reference to the .lvclass file itself. You can use it to query the class definition (who is my parent class, how many methods do I have, etc) and to do editing to the class (change wire appearance, etc). It does not give you a reference to an actual object.

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
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.