WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-11-2005, 04:08 PM
shai shai is offline
Member
 
Join Date: Oct 2004
Posts: 29
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()
Reply With Quote
  #2  
Old 08-11-2005, 04:15 PM
shai shai is offline
Member
 
Join Date: Oct 2004
Posts: 29
by the way,

the two commands inside the while loop are indented with tabs...
(it just didn't post correctly onto the forum)
Reply With Quote
  #3  
Old 08-11-2005, 04:34 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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()
Let me know if this doesn't fix your problem
Reply With Quote
  #4  
Old 08-11-2005, 06:00 PM
dominic dominic is offline
Member
 
Join Date: Aug 2005
Posts: 8
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()
Reply With Quote
  #5  
Old 08-12-2005, 01:52 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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?
Reply With Quote
  #6  
Old 08-12-2005, 05:01 PM
dominic dominic is offline
Member
 
Join Date: Aug 2005
Posts: 8
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
Reply With Quote
  #7  
Old 08-15-2005, 11:51 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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')
Reply With Quote
Reply


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


All times are GMT -7. The time now is 12:24 PM.


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