LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Given a string, how do you find the numeric value in sparse ring?

Situation: I receive the string value of the sparse ring, and a control reference to the same type of control, but not the control that sourced the string. How can I convert the string, into the actual numeric value of the ring? For example:

Using the "VISA Select Event Type" ring (Functions -> Instrument I/O -> VISA -> Advanced -> Event -> Select Event Type.ctl), lets say I get the string "ServiceRequest" how do I convert that into 1073684491, the actual value of the ring?

This is a rework of an existing function that worked fine with "normal" rings.

Thanks.
0 Kudos
Message 1 of 5
(3,190 Views)
Have you tried using the value property with the control reference that you receive?
0 Kudos
Message 2 of 5
(3,190 Views)
That would only be useful if the control reference I had pointed to the ring control that sourced the string, but it does not. The value of the control reference I do have is always the default value (until I set it, based on the value of the string).
0 Kudos
Message 3 of 5
(3,190 Views)
This is an interesting question. There does not seem to be any way to get this info from a property node. I would suggest building a subVI which has a case structure in it. You input the string and just traverse through the values of the string in the ring and output the correct one. It's sort of a brute force method but it should do the job.
J.R. Allen
0 Kudos
Message 4 of 5
(3,190 Views)
Unfortunately this method will not work, its a generic routine that must be able to take any ring, so I can't hardwire the cases to known outputs. And, of course, searching the array of Strings[] will just find me a useless index.

My interm solution is this:
1) pick a small, but likely range of possible values for the ring
2) iterate through these values, assigning each one in turn to ring
3) read the RingText property to see if it matches the passed string
4) if it does, then exit. If it doesn't keep looping.
5) if no value produces a matching string, declare defeat (raise an error or produce other output that indicates a match could not be found).

The routine only runs in the UI so I am not too concerned about the time delay this method will i
mpose, but I would greatly appreciate a smoother solution.

Thanks for your suggestions.
0 Kudos
Message 5 of 5
(3,190 Views)