ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

save data in one column in array

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 🙂

0 Kudos
Message 1 of 6
(3,087 Views)
  • It would help to attach a VI that contains typical default data in the string control. Your string is empty.
  • You can combine both loops into one.
  • Your current result is 2D, not 3D.
  • Maybe all you need is a single case structure, wired directly to the number form the byte array and outputting a single number depending on the input.
  • What should the output be if none of the matches are equal?
  • ...
0 Kudos
Message 2 of 6
(3,083 Views)

In any case, maybe something like this...? (filling the other cases accordingly and maybe even making the output tunnel conditional)

 

 

 

convert.png

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

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.

 

0 Kudos
Message 4 of 6
(3,063 Views)

Ohh I've figured it out, the data type of the input of case structure was wrong, it's working now, thanks! 🙂

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

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

 

 

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