04-10-2012 08:38 AM
Hi
I wish to read from a radio buttons control when the 'Check Answer' button is pressed. I then wish to compare this value with a value in an array. If they are the same, I wish to update another array. The problem is, when I do this more than once the original array is wiped. I have attached my code below.
Solved! Go to Solution.
04-10-2012 08:54 AM
A shft register will be your friend. It retains the value from the previous iteration and makes it available to the next one. Look at the help.
You will want to change the Mechanical Action on your Check Answer button.
The data type for Select question should be an integer type.
You should have a Wait function in the loop. No need for it to spin thousands or millions of times per second to respond to a human user. Better, learn to use the Event Structure.
Lynn
04-10-2012 09:03 AM
Thank you for your reply Lynn. I thought about using an event structure but you can't use shift registers with it. I'll try using the event structure in conjunction with a for/while loop and shift registers and see how I get on. Will post solution if it works.
Bryanna
04-10-2012 09:04 AM
Your question is not clear anyway I would give my comments what I observed. You are initializing the array inside a while loop so this will initialize the array again and again resulting you will always get the array with elements false when you release the check answer button. So keep the initialize array outside the while loop and right click the tunnel and change that to a shift register. The whatever you perform wire it to the other end of the shift register then you will always have the recent data. If your problem is still not cleared explain your situation bit more.
04-10-2012 09:54 AM
Thank you for your help Lynn, it guided me towards the solution which is attached below for anyone who is experiencing a similar problem.
Bryanna
04-10-2012 10:07 AM
Braynna,
Now a few more things to make it even better.
Change the mechanical action of the Check Answer button to Latch When Released. Pop up on the control from the front panel. Mechanical Action is near the bottom of the menu.
Add an event case for the stop button value change event. Put the terminal inside the event case and wire it to the termination terminal. Then you do not need to press the Check Answer button an extra time to stop.
Wire the shift register straight through the cases where it is not used. UseDefault if Unwired could cause you to lose all your data.
Remove the Timeout case. It never executes, so why have it?
Lynn
04-10-2012 10:14 AM
You are on the right track. Here is how I would use an event structure to do what you are trying to do.
04-10-2012 10:18 AM