LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop a while loop with array outside

Solved!
Go to solution

The solution given by Pnt works fine. Now I would like something a little bit complicated. I would like that first before each value from the array is running, that the user clicks to a button to start the waiting time (I know how to do this with event structure). After I would like that at the 90% of the time of waiting given by the differents by the array, some event appeared (I guess that I could do this in case structure) during 500 ms and then the remaining time has to be elapsed and another event appears. For example, for a value of 10s, at 9 sec, an event appeared during 500 ms and this event disappeared and following 500 ms another event appeared during 500 ms. After 1 sec, another value from the array is running.

 

Thank you for the help.

0 Kudos
Message 11 of 57
(1,712 Views)

What is "differents"?

 

Your description isn't too clear.  Perhaps you can draw a picture or a timeline or something to describe this.

0 Kudos
Message 12 of 57
(1,697 Views)

Okay I'm sorry I will try to make it clear.

 

Each value from the array represent an individual trial. At the beginning of each trial I would like that the user clicks to a button to start the wait time (I know how to programate a click on the button but I can't with this architecture program in the way that the button appears back with each new value from the array). After 90% of the time of waiting (so if the value in the array is 10 sec, after 9 sec) a stimulus appears during 500 ms and disappears. And after the value is elapsed (i.e., after 10 sec) another event appears. For these two events to program no problem. After the delay is elapsed i would like to have 1 second of waiting after the new trial (and make appear the circle).

 

My aim actually is to select randomly from the array one of the 9 values. When this value is selected it can't be used again. I would like the loop ends after a x number of trials. I wonder so if array is well suited for my problem. I know the random number function but I can not easily remove a value when it was used.  I hope that I am clear.

 

0 Kudos
Message 13 of 57
(1,691 Views)

Sure, an array is perfect for this.

 

You would probably want another array of booleans where each index matches up with a value in your numeric array.  Once you select a value and use it, set the same index in the boolean array to true.  When you randomly choose a value in the numeric array again, check to see if the boolean flag is true.  If it is still false, use the value and change the flag to true.  If it is true, choose another random number and check again.  Keep the number of values used in a shift register and stop the larger while loop after that number matches your desired "x" trials.

0 Kudos
Message 14 of 57
(1,684 Views)

Thank you very much for the reply. I am not sure to understand could you give me a picture of this please if you have any time. I thank you in advance

0 Kudos
Message 15 of 57
(1,665 Views)
Thank you very much for the reply. I tried your solution but it doesn't work. I guess I miss something could you give me a picture of this please if you have any time. I thank you in advance
0 Kudos
Message 16 of 57
(1,637 Views)
Which solution are you referring to? Why don't you go ahead and post what you've done so far.
0 Kudos
Message 17 of 57
(1,628 Views)
The solution given by Ravens fan
0 Kudos
Message 18 of 57
(1,618 Views)
Take a look at this in LV 8.0
0 Kudos
Message 19 of 57
(1,609 Views)

 Thank you very much for the solution given. I tried to apply this in my program but it didn't work. I would like to use each value given by the array as time and when this time is elapsed a change in the font of the screen to yellow appears during 1/2 sec and after 1.5 sec I would like that the next interval given by the array is selected. I would like the array runs for 10 or more trials, so that after 5 trials and all values are selected the array of boolean returns to 0 to  let select among all the values.

 

Here in the VI runs only for one value and stops even though I set the number of trials to 5. Thanks. I attached the code here 

Download All
0 Kudos
Message 20 of 57
(1,592 Views)