WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-20-2011, 08:50 AM
new_horizon new_horizon is offline
Member
 
Join Date: Apr 2010
Posts: 43
viz.input

Hi All,

I am trying to enter some code that will allow the experimenter to enter a filename for the test subject - I would like this file name to be the participant number, however, when I input 01 or 02 etc, the program does not run.

Is there a specific command for allowing number entry? I assume the command below only takes care of string?

filename = viz.input('What filename for dataout?')

Thanks
Reply With Quote
  #2  
Old 09-21-2011, 09:48 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can manually convert the string to an integer. Example:
Code:
strValue = viz.input('Enter a number:')
try:
	intValue = int(strValue)
	print intValue
except ValueError:
	print 'You did not enter a valid number'
Reply With Quote
  #3  
Old 09-26-2011, 04:44 AM
new_horizon new_horizon is offline
Member
 
Join Date: Apr 2010
Posts: 43
Thanks for the reply.

Am I correct in saying however, that you cannot combine an integer and a string to make a file name?

For example if choiceM[selectM] is a string and filename is an integer?

filename = filename + choiceM[selectM]

Thanks
Reply With Quote
  #4  
Old 09-27-2011, 10:59 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Yes, just convert the integer to a string and then you can concatenate it with another string:
Code:
filename = str(filename) + choiceM[selectM]
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
character limit in viz.input message moooh Vizard 3 04-15-2009 05:27 PM
Mouse and Viz.Input bjgold Vizard 4 04-20-2007 01:21 PM


All times are GMT -7. The time now is 03:35 AM.


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