LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

In LVOOP how do you typecast the generic LabVIEW Object to a more specific class?

I'm working on creating a LVOOP Collection class similar to ones you find in VB and MFC. I am using a Private array of "LabVIEW Objects" in my class to manage the collection. This has worked great for getting objets into the collection and managing them, but when I take one back out, I cannot find a way to typecast them to a more specific type so that I can call methods on them.
 
I would think the "To More Specific Class" VI would be the way to go, but then I am at a loss when I try to specify the "target class". Here I tried to use the "Class Specifier Constant" but could not locate a way to specify my user defined class type.
 
 
Pseduocode Detail
--------------------------
Collection Class
     Private array of LabVIEW Objects called Items
     Public VI AddItem(LabVIEW Object)
          Takes the supplied LabVIEW object and adds it to the array Items
     Public VI GetItem(index, LabVIEW Object)
          Returns the LabVIEW Object at the specified index
 
Collection Widget
     Private DBL called Price
     Public VI SetPrice(DBL)
           Sets the Price to the supplied value
     Public VI GetPrice(DBL)
           Returns the Price
 
I create an instance of the Collection class and call AddItem VI four times to add four different instances of the Widget class that each had the SetPrice method called with values1.00, 2.25, 10.00 and 22.50. Then if I call the Collections GetItem method to get the second Item I cannot find a way to call the GetPrice on the returned object.
 
 
 
0 Kudos
Message 1 of 3
(3,013 Views)
You can use an instance of your class (so a constant, or a control or any wire with the right type) for the target class input.


Message Edited by Matt W on 06-07-2007 07:16 PM

Message 2 of 3
(3,004 Views)

Matt,

Thanks for the reply. I had done this and received error messages. But late last night a coleague was revewing the work I had done and he discovered my issue. I had gone the extra mile to try and support keyed access to the objects in the collection, so instead of an array of LabVIEW Objects, my collection actually contained an array of KeyedItem objects which were LabVIEW Objects with an associated unique identifier string. In my Collection.GetItem method I had forgotten to extract the LabVIEW Object from the KeyedItem object, so I was actually returning a KeyedItem object which was not typecasting very well. Being new to LVOOP I had assumed I was doing the typecast wrong.

Thanks again.

0 Kudos
Message 3 of 3
(2,986 Views)