Certification

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Empty string constant in a cluster

Solved!
Go to solution
Highlighted

Empty string constant in a cluster

I think I remember seeing somewhere that you get points deducted for using a general string constant that happens to be empty as opposed to an empty string constant. This might be mentioned in the style guide.

 

But I just noticed that you can't put an empty string constant in a cluster constant! Only a string constant that is empty.

 

So if I needed to create a cluster constant of empty strings, would I lose style points for using a string constant with nothing in it rather than an empty string constant? If so, is there a way to do this without losing style points?

0 Kudos
Message 1 of 6
(403 Views)
Solution
Accepted by topic author AmandaBacala
11-07-2018 12:29 PM

Re: Empty string constant in a cluster

I wouldn't worry about that. But, in cases where you do want an empty string, like to clear out an indicator, it is good to use dedicated empty string constant



CLA // LabVIEW 2016 // BALUG // Unofficial Forum Rules and Guidelines
0 Kudos
Message 2 of 6
(400 Views)
Solution
Accepted by topic author AmandaBacala
12-13-2018 01:14 PM

Re: Empty string constant in a cluster

The empty string constant isn't really a constant.  Its really a vi similar to this:

Capture.PNG

saved without its block diagram.  That is the reason it won't go in a cluster (and how would you change the string value?)

0 Kudos
Message 3 of 6
(218 Views)

Re: Empty string constant in a cluster

Makes sense! Thank you!

0 Kudos
Message 4 of 6
(204 Views)

Re: Empty string constant in a cluster

If you need to make a cluster constant, other things are much more important:

 

  1. Give each element a descriptive label and show it.
  2. Display the elements in cluster order to avoid surprises (e.g. "arrange vertically").
  3. Give each element a useful default value. (whatever they typically are or even a sentinel string "- empty -", "N/A", "not set", etc.)

 

This often simplifies the code and is automatically self-documenting, especially if you later always use (un)bundle by name.


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 5 of 6
(155 Views)

Re: Empty string constant in a cluster


@Jeff·Þ·Bohrer wrote:

That is the reason it won't go in a cluster (and how would you change the string value?)


This explanation is incorrect. It is true that the space constant is a VI (for no good reason, really), but primitives such as , EOL, Tab, -Inf, Pi, Ln2, etc. are NOT subVIs but still cannot go into a cluster constant container.

 

There reason is more general. Clusters cannot contain constants. Period. Smiley Wink

 

(They can contains other stuff such a free labels and decorations, though. Smiley Very Happy)

 

( I guess disallowing constants was a very early design decision and probably not a bad one. Still, constant could be allowed in principle, because they just define a datatype and initial value)

 

EmptyCluster.png


LabVIEW Champion Do more with less code and in less time
Message 6 of 6
(154 Views)