From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

OO question in LabVIEW example

Hello,

 

I am trying to learn OO and I have a question in the LabVIEW examples.  See the attached image

 

What is the protected VI's?  It looks like a collection of VIs with a type def.  Isn't this a class?  Why isn't it a class?  What is going on?

 

Thanks

 

Dan Shangraw, P.E.


   

0 Kudos
Message 1 of 7
(2,886 Views)

No image attached.  Which example are you looking at?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 7
(2,878 Views)

Yes, what you are describing sounds like a class. The VIs in a class can be protected so that other VIs can't use them. They don't have to be protected though. See the access scope documentation here: http://zone.ni.com/reference/en-XX/help/371361L-01/lvdialog/c_item_lib_page/

0 Kudos
Message 3 of 7
(2,859 Views)

Capture.PNG

Dan Shangraw, P.E.


   

0 Kudos
Message 4 of 7
(2,845 Views)

Ahh, those are not a class. Those are members of a class. If you use those VIs and typedefs in a place that isn't allowed to access those VIs you'll get a broken arrow. This can potentially save you from a run time bug.

 

Did you see the access scope link I posted above. It explains where the protected VIs are allowed to be used.

0 Kudos
Message 5 of 7
(2,834 Views)

I saw the link to the scope.  Thanks

 

Why isn't the protected vi's in the Board Design Class in the Component class?  Both these entities have the same data.

 

Capture1.PNG

 

 

Dan Shangraw, P.E.


   

0 Kudos
Message 6 of 7
(2,822 Views)

In this example a board is made of components. You can think of "Get Components" as asking the object a question about what it has. It doesn't make sense to ask a component what it has.


Some things that might be confusing:

 

There's no reason to have this folder. There's other protected VIs that aren't in a "protected folder". I think the reason they made the folder is just  to show the developer that Component Orientation and Position.ctl is only used in "Get Component".

 

You might be wondering if  Get Components should be protected. I think it's up to you and your style. Do you think more warnings should "break the run arrow"? If so, protection will break lots of run arrows Smiley Wink

0 Kudos
Message 7 of 7
(2,805 Views)