LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

For Loop exits prematurely - Arrays and Shift Registers

I have attached some preliminary code (work in progress) for the RC4 encryption algorithm. For some reason the middle for loop exits prematurely. In other words it exits after 2 iterations instead of the 256 iterations that N is set to.

I thought this was not possible and therefore I am presuming I have made some not so obvious error in attempting to use a shift register with an array.

Please have a look. Thanks.
0 Kudos
Message 1 of 4
(2,953 Views)
You misunderstand how a for loop operates. You can either wire a number to the N terminal or you can wire an array into it with auto-indexing turned on. With an array input, the for loop will iterate equal to the size of the array. When you wire both (a practice I do not recomend), the for loop will iterate to whichever is smaller - the array size or the N terminal. Both of your for loops on the left side is creating arrays with only two elements. I suspect that what you need in both of them is a shift register instead of exiting the for loop with auto-indexing turned off.
Message 2 of 4
(2,945 Views)
It seems the problem is located in the left two for loops. The array output from the for loops contains only two elemnts.

Hope this help.

HMP
0 Kudos
Message 3 of 4
(2,941 Views)
Thanks for the explanation.
0 Kudos
Message 4 of 4
(2,934 Views)