LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Looking for Cleanest Way to Check Indices


@altenbach wrote:

It is not clear how you do conflict resolution, but I guess the "Groups by Socket" is meaningless if there are still duplicates. For example it is not clear why you decide that the first element is 7 and not 2.

 

Here's my quick attempt. Same result (except first element is 2 instead of 7. Maybe less code, or at least easier to read). No guarantees. 🙂

 

altenbach_0-1632260663416.png

 


One flaw there is that it assumes that valid data never references group 15.  That is not a valid assumption.  Valid data can reference any group.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 11 of 14
(497 Views)

I probably would use -1 for missing values. Currently, it is a control. It could be made into an indicator and use the max+1 (or higher) of the first loop.  Or we could check it against the max and create yet another error. (fortunately, my error code is quite scalable and could be extended with just a little bit more code. 😄

0 Kudos
Message 12 of 14
(489 Views)

@altenbach wrote:

... and a quick attempt to consolidate all that duplicate code for the error prep (just for fun 😉 ).

 

altenbach_0-1632329663221.png

 


Thanks for that.  Here's my variant:

eh.png

While looking at error messages, I realized that "Sockets in more than 1 group: 0" could be misinterpreted as meaning that the number of sockets in more than one group is zero.  I think adding "#" clarifies it: "Sockets in more than 1 group: #0".

I also took advantage of the not-too-well-known "%0.0s" format specifier (it means 'discard the string').

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 13 of 14
(475 Views)

Yes, yours is slightly more scalable, because it can deal with more than two input arrays of different lengths.

 

(Of course converting an empty 1D array to a spreadsheet string followed by trimming and formatting is unnecessary work, but no big deal in this case 😉 )

0 Kudos
Message 14 of 14
(461 Views)