LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to connect a 1D numeric array to case structure selector?

Solved!
Go to solution

Hello everyone, 

I have try to build a block diagram which takes 5 hex and convert them to binary later than compare those binary number with already entered 40 digit binary. After all, I want to write a string which indicates which part is not same. I tried to use case structure however I cannot connect a 1D numeric array to that

For example 
0110 and 0011 => compare result is 1D array=[1] [3]

total result that I want to write in a string is = Pin=50
                                                                           Pin=25

thank you so much

0 Kudos
Message 1 of 7
(4,244 Views)

It typically helps if you would save and attach a Vi containing typical default data in all controls.

 

Case structures only accept scalars, so you could place it inside a FOR loop to execute once for each array element. In your case you need to convert the array data in a form suitable for your purpose. Most of your code makes very little sense, so a better explanation how your input strings look and how it needs to be processed would be useful for us.

0 Kudos
Message 2 of 7
(4,223 Views)

 

I have try to build a string according to 8 cases. I have a numeric array which has 0 to 8 elements. The array size is not fixed, it can be change. However that 8 cases are settled.

Case for 0; "Pin=0"
Case for 1; "Pin=1"
Case for 2; "Pin=2"
...
Case for 7; "Pin=7"

array example is like that,
[0]
[2]
[4]
[7]

the string I want like this,
Pin=0
Pin=2
Pin=4
Pin=7

Capture.JPG


0 Kudos
Message 3 of 7
(4,203 Views)
Solution
Accepted by alpguclu

I have solved my problem. I upload the whole blovk diagram instead of someone needs it.

0 Kudos
Message 4 of 7
(4,183 Views)
Solution
Accepted by alpguclu

1. Why didn't you just autoindex on the array?  Then you would not need the Index Array either.

2. Instead of the case structure, make an array of strings for the possible output values.  Then you just use Index Array to get the value.

3. You should not have that many outputs on your FOR loop.  You really only need 1 autoindexing output tunnel.

4. The rest of the code looks way too complicated.  Try using a Boolean Array to make things simpler.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
Message 5 of 7
(4,172 Views)

Tim, I think you can combine your two FOR loops into one. (while it creates slightly more work, I don't think it'll make a noticeable difference). Is the "array 3" output even neened?

 

PickErrorPins.png

 

I would even go as for as creating a 1D U8 array lookup table and do the formatting of the string conditionally. Less typing of near identical strings, thus less places where typos can hide. 😄

 

PickErrorPinsB.png

0 Kudos
Message 6 of 7
(4,148 Views)

@altenbach wrote:

Tim, I think you can combine your two FOR loops into one. (while it creates slightly more work, I don't think it'll make a noticeable difference).

 


Nice call.  But let's go slight further: no Index Array is needed

 

 


altenbach wrote:I would even go as for as creating a 1D U8 array lookup table and do the formatting of the string conditionally. Less typing of near identical strings, thus less places where typos can hide. 😄

I was thinking that originally, but then found there there a bunch of empty strings used as if they were "do not care".


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 7
(4,137 Views)