WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-13-2013, 06:58 AM
mape2k mape2k is offline
Member
 
Join Date: Mar 2013
Posts: 60
Breaking while loops with timers

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!

Code:
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
Reply With Quote
 

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Control of timers vizmaster Vizard 6 08-22-2008 10:36 AM
killing vizact timers cade_mccall Vizard 1 04-18-2007 10:20 AM
timers and director function Jerry Vizard 1 06-22-2006 10:47 AM
multiple timers paulpars Vizard 4 06-02-2006 11:12 AM


All times are GMT -7. The time now is 05:54 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC