LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

integer to enumeration conversion - I'm being stupid

It's not working!!!Smiley Sad

 

Is it something to do with the fact the enum is U16?

 

Have I found a horrible bug in 8.6?

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
Download All
0 Kudos
Message 11 of 25
(1,579 Views)

James W wrote:

It's not working!!!Smiley Sad

 

Is it something to do with the fact the enum is U16?

 

Have I found a horrible bug in 8.6?


No, you've found a horrible bug in your coding. Smiley Wink

 

You're never concatenating the string inside your loop. The Format Into String has a "initial string". Wire this to the left part of the shift register. The "resulting string" output goes to the right part of the shift register. You will need to change the format string to "%d;". This will give you an extra colon at the end, which you can chop off.

Message 12 of 25
(1,576 Views)

Ok,

Not to be rude to an Knight of NI, but I have that mess as a result of debug.

I'm trying to get at least 1 array of strings on the output with a meaningful array of message strings in it.

e.g. if the input is 0E80, I don't want an array that says 7, 9, 10 & 11. I want to know which ports are connected - i.e. DGPS, Sensor 1, Sensor 2 & Sensor3.

Unfortunately I can only seem to see the numeric value of the enum being converted to text.

This is downright annoying.

I've checked my other code and this seems to work with other enums, so I can't see what the problem is here.

 

Anyone else seeing numerics only in the string arrays, of do I have a code corruption on my PC?

 

James

 

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 13 of 25
(1,569 Views)

The output of your subVI is an array of U16, not an array of enums. You will never get strings like "DGPS" etc. directly from that.

 

Please upload the typedef. 

0 Kudos
Message 14 of 25
(1,565 Views)

Here is the Type Def. I don't understand why it isn't connected.

 

(Thanks for the quick response and not taking [obvious] offense):smileyhappy:

 

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 15 of 25
(1,557 Views)

Hi James,

 

you really could have made this a lot easier: your "enum" isn't one! Your typedef is a ring! From rings you only get the number. You have to create the string array by using a property node and an additional IndexArray node...

RingRingRing.png

 

Message Edited by GerdW on 04-08-2010 06:05 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 16 of 25
(1,544 Views)

GerdW wrote:

Hi James,

 

you really could have made this a lot easier: your "enum" isn't one! Your typedef is a ring!


Indeed, that's the fundamental problem - you have a ring, not an enum, so no about of jumping through hoops will change that.

 

James: Why did you think you had an enum?

Message 17 of 25
(1,538 Views)

Hi James,

 

I have to add: my example only works because you used "sequential values" for your ring values. When using arbitrary numbers you have to use the "StringAndValues" property with an additional array search node to find the string's index...

Message Edited by GerdW on 04-08-2010 06:26 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 18 of 25
(1,537 Views)

ARGGHHHHHH!!!!

 

 

 

not a ring - DOH

 


smercurio_fc wrote:

GerdW wrote:

Hi James,

 

you really could have made this a lot easier: your "enum" isn't one! Your typedef is a ring!


Indeed, that's the fundamental problem - you have a ring, not an enum, so no about of jumping through hoops will change that.

 

James: Why did you think you had an enum?


 

Why do I think it's an enum? Smiley Indifferent - because I hardly ever use rings, the numbers are sequential and I had no reason to use a ring for this control. I (almost - it seems) always revert to enums for my strict typr def controls.

 

 

Poor. Poor. Poor Code.

 

Sooooooooooo Ashamed (hanging head) Smiley Sad

 

Thank you. Smiley Very Happy

 

- When no one reviews your code on a project this big it's the little mistakes that jump up and bite you in the ar** and give you splinters from scratching your head.

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
Message 19 of 25
(1,523 Views)

D*mn and D*mn again. I've just worked out why it's a ring not an enum.

 

When I have a long list of consecutive values to turn into a Type Def Enum, I don't type them into the enum.

I:

1) create a ring control and pass an empty strings and values array to a property node of it  

2) create an array of strings with the strings in the order I want them.

3) pass the array through a FOR loop and bundle the string with the iteration count.

4) pass the indexed bundle out of the FOR loop into the strings and values of a Ring property node

5) right click on the FP and replace the ring control with an Enum which retains all my values I have just programmed in.

6) customise it.

 

I must have missed out step 5. (I only do this beacuse the dialogue entry is sooo slow ans enums can't be populated at run time.)

 

Sorry.

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
Message 20 of 25
(1,516 Views)