Jump to content

Is there anyway to create and pass the reference of object programmatically?


Recommended Posts

Hi,

I would like to know if there is anyway to create and pass the reference of an object programmatically?

I will tell a little bit about my current project.

There is a main VI which is the main window control of the system. I have many different classes in the project but for this example I will talk about two main class which is the map and the vehicle. When the program is initialized the vehicle object is created first and the reference of this object is passed as an initialize data for the map object. The pass by reference is implemented based on the method introduced by Jim Kring. The process of the map object will read the property position of the vehicle to plot it on the map display. Now I have to develope my project to another level which is plot multiple vehicles on the map. These vehicle is generated programmatically. As I said, my map object has only reference of the initializing vehicle. I don't know how can I pass the reference of a new generated object to the object I had already created.

I highly appreciate your time for reading and answering my question.

Best regards,

Thang Nguyen

Link to comment

It sounds like your object could be refactored. Rather than initializing the map with a reference to a vehicle object why don't you have a method on the map object for plotting a vehicle's position. Simply call this method with the correct vehicle reference each time you need to plot a position. This will work equally well for a single vehicle or multiple vehicles because the vehicle information is only required and passed to the method that needs it. The vehicle reference should not be an attribute of the map.

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.