05-29-2012 03:37 AM
Hi guys,
I am testing out array. How do I create a 1D array of x-y using for loop?
05-29-2012 03:54 AM
05-29-2012 04:04 AM
Hi GerW,
I think I am not clear about my question, I mean I want to build a array containing only the difference(adding on to my code). No I did not go through, I am doing self research and writing simple program to test out.
05-29-2012 04:06 AM
Instead of the bigger while loop replace that with a simple for loop and take the x-y outside the for-loop you will get an array of differences.
05-29-2012 04:07 AM
05-29-2012 08:29 AM
I understood the question as the difference between the following elements. So my solution would look like this:
Greets, Dave
05-29-2012 10:20 AM
05-29-2012 10:26 AM
Nextal wrote:I am testing out array. How do I create a 1D array of x-y using for loop?
OK, first of all you did not say what the array should contain. If you want an array that has one array element for each iteration of the while loop, you need to first think a bit harder. Your outer loop has no wait, thus it will spin millions of times per second and you will run out of memory soon, no matter how much memory you have. How many times should the while loop iterate? If you know the number before the program starts, you would use a FOR loop and autoindex at the loop boundary.
If you want to use a whiile loop, you need a mechanism to keep the array size reasonable. For small final arrays, you can just build the array in a shift register if you need it updated as it happens. If you only need the array after the loop stops, you can autoindex at the right loop boundary.
In any case, you should take a step back and decide what you really want. Currently the specifications are very vague and unreasonable.