LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

property nodes, controls by reference

Solved!
Go to solution

Hello,

 

I just would like to know what is the difference between the two approaches see them below in the snippet. Both function. What is the real role/reason of the typecast? Both are OK to use?

Thanks!

 

refnums_example.png

0 Kudos
Message 1 of 10
(3,708 Views)
Solution
Accepted by topic author Blokk

It depends on what you are feeding into it.

 

If indeed, you are feeding GENERIC control refs, then the TYPECAST does nothing.

 

If, however, you are feeding in mixed references [ Boolean, string, I64, cluster], then the TYPECAST casts them all into GENERIC refs.

 

I would NEVER recommend doing that, however.

 

1 --- If all you are doing is changing the DISABLED property, and since the DISABLED property is common to all controls (i.e. it's generic), the generic ref is fine as it is.

 

2 --- If you must cast, use the CAST TO MORE GENERIC TYPE or the CAST TO MORE SPECIFIC TYPE and let them tell you (error out) if there is a problem.  The TYPECAST will take anything you give it and spit out a reference, but it won't necessarily be legit.

 

Using the CAST TO MORE SPECIFIC TYPE is useful when you get an array of controls out of a cluster, but you KNOW that they're all ListBoxes, so you can cast them to a ListBox type and do ListBox-specific stuff on each one.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 10
(3,683 Views)

I fully agree that the Type Cast is not the right solution here.  Well, in this case, you already have an array of type Control.  Therefore there is no additional casting that needs to be done.  But if you did, use the To More Generic Class so that you can do some error checking.


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
Message 3 of 10
(3,664 Views)

Thanks for the explanations!

Regards,

0 Kudos
Message 4 of 10
(3,660 Views)

Hmmm.  I just now noticed that the top version is labelled "CLD Example Solution".

 

Was that really given out by NI?

 

Seems to me like bad practice.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 5 of 10
(3,655 Views)

official CLD exam example solution, ATM.

By the way, they have also left a bug in the Car Wash solution (the slider does not get back to Entry position after pulling it to Exit after a wash cycle finished).

0 Kudos
Message 6 of 10
(3,650 Views)

Well, those example solutions are just PASSING exams that somebody actually did.  They are far from perfect, but they passed.  Don't get lost in the details.  Look at the general concepts, structures, and architectues.


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 7 of 10
(3,639 Views)

Well, those example solutions are just PASSING exams that somebody actually did. 

 

OK, it's not as if NI said that this is the "right" solution.

 

Don't get lost in the details. 

 

This question is about the details.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 8 of 10
(3,635 Views)

CoastalMaineBird wrote:

Don't get lost in the details. 

 

This question is about the details.


Yes it is.  But at the same time, my advice for when studying for the CLD is to not get lost in the details.  You will find all kinds of problems in those sample solutions.  It is ok to ask about it if something doesn't make sense.  But the purpose of the solutions was to show architectures and general concepts.


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
Message 9 of 10
(3,631 Views)

I know and agree that for CLD exam the planning, the style, and the design structure, so the big picture is important. That is why I asked this particular question here in the general forum, since I am not familiar with classes. And I got detailed explanation.

 

Actually I did not know that the given CLD exam solutions were actual exam projects from exam takers who passed the level 🙂 Now it make sense, and I hope I did not sound like complaining, I was just surprised, since I did not know the above information about these examples.

There is also a readme html file in every Solution folder:

 

"

This provided solution is one viable solution out of many based on exam requirements. It is not considered the only nor best possible solution and is solely provided for your benefit and exam preparation.

Refer to the CLD Preparation Guide for more information about exam requirements."

0 Kudos
Message 10 of 10
(3,624 Views)