LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos
cyro

Additional Boolean Constant Mask

Status: Declined

Any idea that has not received any kudos within a year after posting will be automatically declined. 

This is an idea where I'm not sure if I like it but....

 

I often see code with functional globals and booleans used as command, 99% with FALSE as Get and TRUE as Set.

Code1.png

 

I don't like this and normally you use typedefed enums instead. But if you want to use those VIs created from someone else you have to use these boolean commands.

In most cases these FGVs where created this way because you don't want to create an enum for only two states (laziness) and time is money... Bad style I know 😞

 

My idea is to add an additional boolean constant with only changed appearance, quasi a mask: get.png and set.png

 

Afterwards the code will look like this, which is more intuitive than the first one:

 

Code2.png

 

Thanks,

 

Peter

6 Comments
JCC_(SK)
Active Participant

no kudo

 

enum is only right way

SteveChandler
Trusted Enthusiast

Actually I sort of like it. I have to think about it a little more before giving it kudos. Maybe an enum with a Boolean data type? Hmm.. I don't know if that would buy you anything. It's not like we have to worry about memory and even in that case a Boolean takes the same amount of memory as an I8 or U8. In any event I think this should be very easy to implement after seeing some scripting tricks. (Specifically reply #184 in the thread.)

=====================
LabVIEW 2012


RavensFan
Knight of NI

I think if you properly name the control in the FGV subVI, when you look at context help or hover over the connector, you'll get all the infomration you need as to whether Get = True or Set = True.

 

A control name of Get/Set (Get = F) will tell you that Get is the default value and that it is equivalent to a False Boolean.

crossrulz
Knight of NI

In this case, I would name my control "Set?" and so it is obvious that you are only getting the value if set to FALSE.


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
Thoric
Trusted Enthusiast

I always use an enum, although I can see that using a Boolean would make the code a little quicker to generate and probably hold a smaller compiled footprint. Not sure I fancy customised booleans though...

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Darren
Proven Zealot
Status changed to: Declined

Any idea that has not received any kudos within a year after posting will be automatically declined.