Thang Nguyen Posted March 7, 2009 Report Share Posted March 7, 2009 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 Quote Link to comment
Mark Yedinak Posted March 7, 2009 Report Share Posted March 7, 2009 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. Quote Link to comment
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.