07-08-2014 09:32 AM
I am making a program that calculates a double value each time the user clicks on an OK button. To do this I am using a while loop over the NI-SCOPE which generates a new signal each run through and a while loop around the code I am using (it requires the use of a while loop). I am wondering, how can I store a value each time it is calculated in a list or array so the user can see all the values.
Solved! Go to Solution.
07-08-2014 09:32 AM
Also, I tried wiring the double value to an array indicator of doubles, but it would not work.
07-08-2014 09:36 AM
You will want to store your array in a shift register on your loop. When you calculate a new value, just use Build Array to add the new value.
07-08-2014 09:37 AM - edited 07-08-2014 09:37 AM
07-08-2014 09:47 AM
Whenever I do this, the program stores the calculated value as one element, then 0 as the next, so that two spots are filled in every run through. And I did do the tutorials, but I completely forgot about shift registers.
GerdW wrote:
07-08-2014 09:49 AM - edited 07-08-2014 09:49 AM
07-08-2014 09:50 AM
@Punsach wrote:
Whenever I do this, the program stores the calculated value as one element, then 0 as the next, so that two spots are filled in every run through. And I did do the tutorials, but I completely forgot about shift registers.
Please post your code. This doesn't sound right.
07-08-2014 09:51 AM
crossrulz wrote:
Please post your code. This doesn't sound right.
07-08-2014 10:14 AM
Your program feels really inside out. I highly recommend getting rid of the outside loop. Move the acquisition into the event structure with the Next Pulse event. Stop the inner loop only with the Program Stop event.
But your big issue is that you should only be adding on to the array in very specific cases. I would assue you only want to add on to the array when you go to the next pulse. So move that logic into that event somehow. This will be a fun one with shift registers, but it will make it run a lot better.
07-08-2014 10:23 AM - edited 07-08-2014 10:23 AM
@crossrulz wrote:
Your program feels really inside out. I highly recommend getting rid of the outside loop. Move the acquisition into the event structure with the Next Pulse event. Stop the inner loop only with the Program Stop event.
But your big issue is that you should only be adding on to the array in very specific cases. I would assue you only want to add on to the array when you go to the next pulse. So move that logic into that event somehow. This will be a fun one with shift registers, but it will make it run a lot better.
Is that the cause of the issues with the repeated 0?
And the thing is I need to allow the user a chance to move the cursors in the case they are not positioned correctly, hence the inner and outer loop.