WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-18-2012, 08:17 AM
new_horizon new_horizon is offline
Member
 
Join Date: Apr 2010
Posts: 43
Simple Programming Question

Hi All,

Forgive my ignorance, but I am writing a program where I have a set of commands that occur for a given number of trials (for in in range (0, No_trials)).

I wish to have another event that only occurs every three trials (i.e. when i is 3, 6, 9 etc) - can anyone tell me how I would express this in Python?

Many thanks

Mark
Reply With Quote
  #2  
Old 04-18-2012, 09:57 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Are you using the viztask module to run your trials? Either way, here is some code that shows how you can detect every third trial:
Code:
import viz
import viztask
viz.go()

NUM_TRIALS = 10

def runTrial():

	yield viztask.waitTime(1.0)



def runExperiment():

	for i in range(NUM_TRIALS):

		if i % 3 == 2:
			print 'Special event for every third trial'

		yield runTrial()

		print 'Finished trial',i+1

viztask.schedule( runExperiment() )
Reply With Quote
Reply

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
simple question drawing to screen Kaminski Vizard 2 03-02-2011 11:03 AM
Simple Joystick Question 4711 Vizard 2 06-07-2010 07:06 AM
simple VRPN question mjabon Precision Position Tracker (PPT) 2 08-25-2009 10:12 PM
Python Programming Question jaylocco Vizard 2 07-21-2009 02:23 AM
simple question? Boombay Vizard 1 07-06-2009 10:51 AM


All times are GMT -7. The time now is 11:16 PM.


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