LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Basic Ring control question

Solved!
Go to solution

This is humbling, but I just discovered something which I find un-intuitive: if I initialize the Strings[] property of a Text Ring control using an empty String array, the ring control resulting from this operation has a Strings[] array size of 1 and its unique element is a string of length 0...

See attached snippet:

 

Text Ring.png

 

(interestingly BTW, my diagram does not use a Ring Refnum and a generic Property Node, but instead directly the Ring's Property Node, but that has been changed upon generating the snippet)

I see that when opening the property dialog for the Text Ring, I cannot remove the last item, whose name is empty, so that's consistent with the above behavior, but I would expect that an empty String array remains an empty string array.

Comments most welcome.

 

0 Kudos
Message 1 of 6
(3,580 Views)

Use the Code Capture Tool.  It is much better than the built in LabVIEW snippet maker.

 

The element in the array makes sense.  When you drop a new ring onto the front panel, you notice it always starts with at least one item that is empty.  You can't have a zero item ring.  So if you try to feed it an empty array, LabVIEW takes over and turns it into a single element array of an empty string.  If you go into a new string control and try to edit the items, notice you start with an element 0 and you can't delete it.

0 Kudos
Message 2 of 6
(3,573 Views)

I don't have a problem with an empty string. I have a "problem" with a Text Ring having one element which is empty. I just don't see the logic compared to an empty Text Ring (i.e. a String Array). But that's just me, I suppose.

0 Kudos
Message 3 of 6
(3,563 Views)
Solution
Accepted by topic author X.

Maybe it's just semantics.  You can have a text ring with a single element that is an empty string.  You cannot have an empty text ring.  There always has to be at least one element.

 

A text ring is a numeric datatype.  Actually an integer datatype.  There is no such thing as an empty integer.  It always as to have a value.  The default is zero.  In a text ring you always have to have at least one element you can select.  Which means it has to have at one element of a string array associated with it.

 

Though you could have a ring control that is a floating point data type such as a double.  And you could have a data value of NaN you could call a sort of null numeric, though I don't think it is really the same principle.

Message 4 of 6
(3,558 Views)

Now HERE is something VERY interesting.

As I mentioned above, I was a bit surprised that the snippet generated from my VI used a generic Property Node rather than the Text Ring Property Node that I originally used.

I just tried the snippet, and contrary to what I was rumbling about before, the size of the Strings[] array resulting from the diagram is 0 (ZERO) not 1!!! (that's BTW what I was expecting to be the "correct" behavior)

What is going on?

If I replace the two generic property nodes back with the Text Ring Property nodes, I get back to the size = 1 I was puzzled with.

What can of worm did I just fall into?

0 Kudos
Message 5 of 6
(3,555 Views)

Never mind, the snippet was bogus and created a reference to a non existing text ring, hence the empty String[] array...

Replacing the reference control by a reference to the Text Ring on the FP brings back the "bizarre but expected" (or is it "fine but unexpected"?) behavior.

 

@Ravens Fan, I think we will blame it on semantics then...

A Text Ring is a numeric, it is not a an array of strings and thus does not behave like one, although, of course, that's pretty much the only way that I can think of using it...

0 Kudos
Message 6 of 6
(3,543 Views)