LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Does an object already exist

Is there a straightforward way to determine if an object of a specific class has already been instantiated?  I'm looking for some kind of LV primitive or function that would take the name of a class (or a constant class reference) and output a true/false whether an object of that class exists.  Alternatively, I suppose it could even return a reference to that object, or maybe an array of references if more than one object of that class exists.

 

I imagine something equivalent code could be written.  I'm just hoping to avoid reinventing the wheel.

-------------------
Greg
Certifed LabVIEW Developer
0 Kudos
Message 1 of 4
(2,489 Views)

Greg,

 

I do not believe there is any built in way to accomplish this.  Not that I've been able to track down anyway.  You will probably have the best luck implementing a method in code.  Perhaps a funcational global variable (FGV) that keeps track of the created objects.  You could check against the FGV each time you wish to see if an object exists already.  

 

Regards,

Shane C

0 Kudos
Message 2 of 4
(2,440 Views)

As of LV13 there is a VI to return the default value of a LV class by name, it errors out if the class is not in memory.  It is aptly named: Get LV Class Default Value By Name

0 Kudos
Message 3 of 4
(2,431 Views)

This sounds like the Singleton Pattern.  If you search for Design Patterns, you can find a 2008 paper that Elijah Kerry wrote that includes this Pattern.  It references an example that ships with LabVIEW 8.6, but seems to have "disappeared" in 2013.  I was able to find it in LabVIEW 2010 ...  [I'm not 100% certain that this answers your question].

0 Kudos
Message 4 of 4
(2,411 Views)