ID:143942   May 21 2007, 9:55 am Code: ``` Volume() input("What do you want to find the volume of?","Volume")in list("Cube","Rectangle","Circle") if("Cube") usr << "What is the length of one side?(All sides must be equal to be a cube!)" var/a = input("Length of side","Lenght")as num var/b = a*a*a usr << "The volume of the cube is [b]!" if("Rectangle") usr << "What is the length of side C?" if("Circle") return ``` Problem description: Well, no matter what I pick in the list, it always does the Cube...
 <-> May 21 2007, 10:00 am Revojake wrote: Code: ``` Volume()> input("What do you want to find the volume of?","Volume")in list("Cube","Rectangle","Circle")> if("Cube")> usr << "What is the length of one side?(All sides must be equal to be a cube!)"> var/a = input("Length of side","Lenght")as num> var/b = a*a*a> usr << "The volume of the cube is [b]!"> if("Rectangle")> usr << "What is the length of side C?"> if("Circle")> return> ``` Problem description: Well, no matter what I pick in the list, it always does the Cube... What you're doing is only suitable in a switch() situation. like this. ``` switch(input("What do you want to find the volume of?","Volume")in list("Cube","Rectangle","Circle")) if("Cube") usr << "What is the length of one side?(All sides must be equal to be a cube!)" var/a = input("Length of side","Lenght")as num var/b = a*a*a usr << "The volume of the cube is [b]!" if("Rectangle") usr << "What is the length of side C?" if("Circle") return ``` if not you have to do this ( not recommended unless necessary) ``` var/A=input("What do you want to find the volume of?","Volume")in list("Cube","Rectangle","Circle") if(A=="Cube") usr << "What is the length of one side?(All sides must be equal to be a cube!)" var/a = input("Length of side","Lenght")as num var/b = a*a*a usr << "The volume of the cube is [b]!" if(A=="Rectangle") usr << "What is the length of side C?" if(A=="Circle") return ```
 <-> May 21 2007, 10:03 am In response to Kazekage Ah, I see. I just haven't used in list in awhile.
 <-> May 21 2007, 10:07 am What you're halfway to doing is using a switch() statement with an input, I suspect. Except, you're missing the switch. The below shows you two ways to do something similar to what you are doing: ```var/a = input("Test") as num // store value of question in 'a'switch(a) // Read value of 'a' if(1) // if 'a' is equal to 1 world << "Badaboom" if(2) world << "Allakhazam" else world << "Whizbang" ``` ```var/a = input("Test") as numif(a == 1) world << "Badaboom"else if(a == 2) world << "Allakhazam"else world << "Whizbang" ``` The two above are close to completely equivelant, as far as you should be concerned.
 <-> May 21 2007, 10:09 am In response to Kazekage Kazekage wrote: if not you have to do this ( not recommended unless necessary) ```> var/A=input("What do you want to find the volume of?","Volume")in list("Cube","Rectangle","Circle")> if(A=="Cube")> usr << "What is the length of one side?(All sides must be equal to be a cube!)"> var/a = input("Length of side","Lenght")as num> var/b = a*a*a> usr << "The volume of the cube is [b]!"> if(A=="Rectangle")> usr << "What is the length of side C?"> if(A=="Circle")> return> ``` That is not equivelant. The above code will test A three times, no matter what. The appropriate way to do the above would be using the second example I posted, using "else if" so that the second comparison is only done if the first fails. This might be unimportant here, but in cases where the value of what is being compared can change it is very important to understand.