WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   problem with input boxes (https://forum.worldviz.com/showthread.php?t=391)

shai 08-11-2005 03:08 PM

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()

shai 08-11-2005 03:15 PM

by the way,

the two commands inside the while loop are indented with tabs...
(it just didn't post correctly onto the forum)

farshizzo 08-11-2005 03:34 PM

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

dominic 08-11-2005 05:00 PM

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()

farshizzo 08-12-2005 12:52 PM

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?

dominic 08-12-2005 04:01 PM

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

farshizzo 08-15-2005 10:51 AM

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')



All times are GMT -7. The time now is 02:14 PM.

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