LabVIEW Idea Exchange

About LabVIEW Idea Exchange

Have a LabVIEW Idea?

  1. Browse by label or search in the LabVIEW Idea Exchange to see if your idea has previously been submitted. If your idea exists be sure to vote for the idea by giving it kudos to indicate your approval!
  2. If your idea has not been submitted click Post New Idea to submit a product idea to the LabVIEW Idea Exchange. Be sure to submit a separate post for each idea.
  3. Watch as the community gives your idea kudos and adds their input.
  4. As NI R&D considers the idea, they will change the idea status.
  5. Give kudos to other ideas that you would like to see in a future version of LabVIEW!
Top Kudoed Authors
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding CONSTs to LabVIEW

I would love it if LabVIEW had logical constants, similar to what other languages have. Basically, a logical constant is similar to a variable (i.e. it's a value which is assigned a name), but its value is set at compile time. CONSTs help code readability.

 

In LabVIEW, a CONST would basically be similar to a global variable, with two differences:

 

1. It would be read only (so no race conditions, everyone can relax).

2. Changing the value on the front panel of the CONST VI will automatically require the user to save the VI, without needing to manually set the new value as the default.

 

Today, you can implement these in LabVIEW using all kinds of methods, but non of them is as convenient as this.


___________________
Try to take over the world!
15 Comments
Knight of NI

Could that be something like an "even stricter type definition" (I am sure we can find a better word! Smiley Very Happy), that also includes the value as fixed?

 

Changing the value would involve editing the ctl (or whatever it will be called).

Knight of NI Knight of NI
Knight of NI

I don't want to have a separate file for each CONST. We can do that today by having a subVI.

 

Two advantages globals have over this is that you can have several in a single file and that their name is prominent in the diagram.


___________________
Try to take over the world!
Knight of NI

It almost seems like when you define constants in a Declarations section of a text based language like VB.  It is code in some ways never really runs, but its presence in the file has meaning to a compiler.

 

This leads to some other questions.  In text based languages, you can define consts as being global/local, or public/private.  How would you implement that in a LabVIEW VI.  If you define a constant in an upper level VI, is the definition of that constant available to all subVI's the upper level VI calls?

Trusted Enthusiast
Implementation: Simply have a right click menu item called "Read Only" on the Global definition, and use the already-present functionality of "Make Current Value Default". Would that be a viable solution, tst?
Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Trusted Enthusiast

You can also have a single VI outputting a cluster with all your Constants in it so the VI count increases by one only, not one per constant.

 

I see the convenience but I question the benefit.

Knight of NI Knight of NI
Knight of NI

> use the already-present functionality of "Make Current Value Default". Would that be a viable solution, tst?

 

Only if you don't have to manually set the new value to be default.

 

 

> I see the convenience but I question the benefit.

 

You're absolutely right. This is more about convenience, but there is also a benefit in the final appearance of the code:

 

Consts.png

 

In any case, convenience is also important. It might not make business sense, but I'm sure many of LV's regular users wouldn't mind if NI dropped off the new features race for a year and focused on bugs and usability.


___________________
Try to take over the world!
Trusted Enthusiast
In all seriousness, this is the core of my participation on the Idea Exchange: "It might not make business sense, but I'm sure many of LV's regular users wouldn't mind if NI dropped off the new features race for a year and focused on bugs and usability."
Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Active Participant
Ditto.  And, I enjoy learning from the feedback on the various ideas (e.g. Christian's coercion post).  We'll see if their listening... Smiley Very Happy
Certified LabVIEW Architect
Wait for Flag / Set Flag
Separate Views from Implementation for Strict Type Defs

One global to rule them all,
One double-click to find them,
One interface to bring them all
and in the panel bind them.
Knight of NI
Even NI has not fully embraced the concept of "constants". The ones in the numeric palette are fine (Pi, etc.), but have you ever double-clicked the "space constant" from the string palette? Smiley Very Happy
Knight of NI Knight of NI
Knight of NI

> ...but have you ever double-clicked the "space constant" from the string palette?

 

I have noticed it's a VI in the past. That's probably because it's easier to create a VI than the relevant C code. It's the same thing with the True constant in the boolean palette (the constant itself is not a VI, but it's placed in a merge VI). In any case, creating something like that once for merging on a palette is not the same as the needs you have in everyday development.


___________________
Try to take over the world!