LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert string to enum using LabVIEW 7.0

Solved!
Go to solution
I learned LabVIEW on 8.6, but here at work we must use Solaris workstations built in '95, so the most advanced version of LV they will run is 7.0.  On LV8.6 it was very to change a string to an enum using the "format from text" vi.  On LV7.0 this is not available.  I have made my own type conversion vi with a case structure, but this is very inconvenient because every time I add an item to the enum, I must add a case to this vi.  I have added error checking code so there is a warning if I add to the enum but forget to update the conversion vi.  Is there a way to replicate the "format from text" vi using LV7.0?
0 Kudos
Message 1 of 15
(20,524 Views)
Solution
Accepted by topic author j_osh_o

SFS.png

 

The Scan from String primative will do the job in LV7.0.  Its a darn good idea to create a type-def control of the enum you use! If the constant and the indicator are instances of your type def, when you modify the control (add, delete, rename, swap values) you can hit the apply changes button and PRESTO all your controls, constants and indicators that use the type def are updated with the new info. 


"Should be" isn't "Is" -Jay
Message 2 of 15
(20,512 Views)

Update to original post:

Attached is the string to enum conversion vi.  I hope that this can be redone in a way that it automatically updates when the enum is updated>

0 Kudos
Message 3 of 15
(20,506 Views)

apply.PNG

Saved from 7.1 to 7.0

I attached the new vi and typedef.  I did not add all the items in the enum you will need to edit thetype def, add your remaining states, save it and select File>Apply changes to update the constant and the indicator in the vi

 

Enjoy


"Should be" isn't "Is" -Jay
Download All
0 Kudos
Message 4 of 15
(20,498 Views)
On LV7.0 the type input for the scan from string vi is labeled "default".  I can see now that the "default" input sets the type, so all I have to do is wire my type-def enum to the "default" input and I have solved my problem.  Thanks for your replies.
Message 5 of 15
(20,474 Views)

jimmybull20_0-1589306877087.png

 

I tried this and it does not work for me. See the output error. Any suggestions

Download All
0 Kudos
Message 6 of 15
(9,926 Views)

I tried this and it does not work. Any suggestion. 

 

jimmybull20_0-1589305584427.png

 

0 Kudos
Message 7 of 15
(9,939 Views)

In your first message, the input string is empty.  So unless you have an enum value that is an empty string, you'll get the default value for the enum.

In your second message, the enum appears to be empty.  So there is probably nothing there to decode and thus doesn't have a value called "Hello" in it.

 

But that is hard to tell since you only attached pictures and not an actual VI.

 

 

0 Kudos
Message 8 of 15
(9,927 Views)

Thanks for your replay. I uploaded the wrong screen shot. I updated the post. Also added the code. This is the same code someone else added on this topic saying it works. 

0 Kudos
Message 9 of 15
(9,916 Views)

All I see is that your first message seemed to disappear.  The second message is still there, and looks the same.

 

I don't see any code added.

0 Kudos
Message 10 of 15
(9,911 Views)