mape2k
03-13-2013, 05:58 AM
Hello Vizard-Team!
I have a small problem: I want to break a while loop either with a button press (works fine) or after a certain amount of time has expired. So far, I have not been able to manage it with timer functions. Is there another way? The code below shows my current status. The timer function is called correctly and expires correctly after 10s, but the global testTrig variable is not parsed and the while loop does not break.
Any thoughts? Thank you!
def test():
global testTrig
for k in range(len(presentSeq)):
testTrig = 0
while testTrig is 0:
testTrig = viz.callback(viz.TIMER_EVENT,testExpired)
viz.starttimer(0,10) # start timer with 10s
yield viztask.waitAny([waitJoyButton]) # wait for joystick button
testTrig = 1
# do some more before next iteration...
def testExpired(num):
global testTrig
testTrig = 1
print 'Expired!'
return testTrig
I have a small problem: I want to break a while loop either with a button press (works fine) or after a certain amount of time has expired. So far, I have not been able to manage it with timer functions. Is there another way? The code below shows my current status. The timer function is called correctly and expires correctly after 10s, but the global testTrig variable is not parsed and the while loop does not break.
Any thoughts? Thank you!
def test():
global testTrig
for k in range(len(presentSeq)):
testTrig = 0
while testTrig is 0:
testTrig = viz.callback(viz.TIMER_EVENT,testExpired)
viz.starttimer(0,10) # start timer with 10s
yield viztask.waitAny([waitJoyButton]) # wait for joystick button
testTrig = 1
# do some more before next iteration...
def testExpired(num):
global testTrig
testTrig = 1
print 'Expired!'
return testTrig