01-08-2018 12:42 AM
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
Solved! Go to Solution.
01-08-2018 01:19 AM
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.
01-08-2018 02:56 AM
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
01-08-2018 05:57 AM
I have solved my problem. I upload the whole blovk diagram instead of someone needs it.
01-08-2018 06:47 AM - edited 01-08-2018 06:50 AM
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.
01-08-2018 10:43 AM - edited 01-08-2018 10:58 AM
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?
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. 😄
01-08-2018 11:06 AM - edited 01-08-2018 11:06 AM
@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".