I have a function within my program that calls itself again if a certain condition is not met. I basically need it to pick 1 of five total images and display it on the screen (then the user gives some input) then pick another image to display that is not the same as the previous one and so on. I don't want the program to repeat an image until all the other images have been displayed.
This is the code I have to accomplish this so far:
Code: Select all
on getRandom
put random(5) into arrayNumber
if trialBlockArray[arrayNumber] is 1 then // if the number has been used
getRandom
else
put 1 into trialBlockArray[arrayNumber] // tell the program that it has been used
set the filename of img "target" to targetArray[arrayNumber] // put the target img in the appropriate place
add 1 to getRandomComplete // used to reset the trailBlockArray so we can then restart after everything has been shown once
if getRandomComplete is 5 then
put 0 into getRandomComplete
put 0 into trialBlockArray[1-5]
end if
end if
end getRandom
Is there a way I can get around this or better logic I could be using?
Thanks!
Jeff