|
#1
|
|||
|
|||
problem with input boxes
Hi,
I ran the following program on two different computers with input of 1 and on both Vizard 2.5 opened two input boxes instead of one. I thought that it might be an integer and string issue but after reading the help pages on viz.input ("The return value will be a string unless the value is a proper number, in which case a number will be returned. ") I realized that this cant be the problem. when running, enter as input 1 and then since 1 > 5 is not true it should never get into the while loop. any ideas what's going wrong? dominic Program: ----------- import viz viz.go() h = 1 h = viz.input("enter the number of human players: ") while (h>5): print "max of players is 5" h = viz.input("enter the number of human players: ") viz.quit() |
#2
|
|||
|
|||
by the way,
the two commands inside the while loop are indented with tabs... (it just didn't post correctly onto the forum) |
#3
|
|||
|
|||
Hi,
The following thread should help you with your problem: http://www.worldviz.com/forum/showth...=&threadid=277 Basically, you need to change your script to the following: Code:
import viz viz.go() if viz.running(): h = 1 h = viz.input("enter the number of human players: ") while (h>5): print "max of players is 5" h = viz.input("enter the number of human players: ") viz.quit() |
#4
|
|||
|
|||
Hmmm... I am not quite sure if I completely understand how this works with the two runs (one for error checking) since if I change the while statement to an if statement it wont print it twice anymore.
what makes the difference? dominic code: ------- import viz viz.go() h = 1 h = viz.input("enter the number of human players: ") if (h>5): print "max of players is 5" h = viz.input("enter the number of human players: ") viz.quit() |
#5
|
|||
|
|||
Hi,
When I ran your script it crashed Vizard, since the script will enter an infinite loop. After I changed it the input box kept appearing until I entered a number less then 6. I didn't get any print outs since the script was crashing. Are you not experiencing the crash with your version of the script? |
#6
|
|||
|
|||
Well, I guess you are responding to the first scrip since the second one only uses an if statement.
I am using version 2.5. If I enter: 1 1 then it doesnt crash if I enter: something bigger than 5 it will crash. Is that the thread of the error checking that just loops forever or why does it do it since it should just get out of the loop once something <= 5 is entered? dominic |
#7
|
|||
|
|||
Hi,
The problem is that the viz.input command does nothing during the first pass. It just returns an empty string. So you shouldn't be getting any input windows at all during the first pass. The while loop will loop forever since in python an empty string is greater than the number 5. It seems as though the input boxes are appearing during the first and main pass. Try running the following script. The input box should only appear once. If it appears twice then there is something wrong Code:
import viz viz.go() viz.input('Enter something') |
|
|