Certification

cancel
Showing results for 
Search instead for 
Did you mean: 

Empty string constant in a cluster

Solved!
Go to solution

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
(6,978 Views)
Solution
Accepted by AmandaBacala

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

0 Kudos
Message 2 of 6
(6,975 Views)
Solution
Accepted by AmandaBacala

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?)


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 6
(6,793 Views)

Makes sense! Thank you!

0 Kudos
Message 4 of 6
(6,779 Views)

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.

0 Kudos
Message 5 of 6
(6,730 Views)

@JÞB 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. 😉

 

(They can contains other stuff such a free labels and decorations, though. :D)

 

( 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

Message 6 of 6
(6,729 Views)