05-19-2019 02:30 PM
Hello,
I have a string which is only made of: . , -
Each of these marks equals a number such as:
. is 1
- is 2
, is 3
What I'm trying to do is create an array which would contains numbers instead of these marks, though I'm struggling a bit. The thing is: I managed to create a for loop to check each element, but my result array is 3D.
I would like to save my result into 1D array. Can I get some suggestions on how it could be done? I've attached the VI below.
Anything would be much appreciated 🙂
05-19-2019 02:39 PM - edited 05-19-2019 02:40 PM
05-19-2019 02:49 PM
In any case, maybe something like this...? (filling the other cases accordingly and maybe even making the output tunnel conditional)
05-19-2019 03:41 PM
Thanks for your quick replay!
I believe that will do the thing, although I don't know how to set these marks in case structure. When i have "." or "-" in a case structure, it shows that there are no case for some selector values. I only need to take care of these 3 marks, so there is no need to worry about whether the match is equal.
here is the attached vi.
05-19-2019 03:53 PM
Ohh I've figured it out, the data type of the input of case structure was wrong, it's working now, thanks! 🙂
05-20-2019 05:58 AM
Congratulations on your "exercise in using the Data Conversion functions". Once you have converted your String to a 1D Array of single-character Strings (first two steps), simply feed that Array into a For Loop containing a Case Statement that replaces the single String letter with the number it is supposed to match. Be sure to include a Default case and "do something sensible" if you get an "illegal letter" in the mix. You don't need any Comparison functions -- let the Case Selector do all the work.
Bob Schor