
-----------------------------------
blankout
Wed Apr 01, 2009 4:48 pm

yes or no
-----------------------------------
is it possible to use an or statement for something like a yes or no answer like

 
if answer="yes" or "no"
then


is this possible or am i just being stupid?

-----------------------------------
Tony
Wed Apr 01, 2009 5:06 pm

RE:yes or no
-----------------------------------
[code]
if boolean_expression or boolean_expression then
   ...
[/code]

-----------------------------------
Insectoid
Wed Apr 01, 2009 5:14 pm

RE:yes or no
-----------------------------------
Tony, I think he means 'if A = b or C'

You have to type 'A' twice. 

So, it would look like so; 
[code]
if answer = "yes" or answer = "no" then 
    %whatever
end if
[/code]
However, it seems quite illogical to have yes or no in the same one I would split it out. 'elsif' is your friend here.
[code]
if answer = "yes" then
    %whatever
elsif answer = "no" then
    %whatever else
end if
[/code]

There is also the 'else' command. Basically, if it isn't any of those things, do this.
[code]
if answer = "yes" then
    %whatever
elsif answer = "no" then
    %whatever else
else
    put "this happens if answer doesn't equal yes or no"
end if
[/code]

-----------------------------------
Tony
Wed Apr 01, 2009 5:18 pm

RE:yes or no
-----------------------------------
the hint was that "no" is not a boolean expression.

-----------------------------------
Insectoid
Wed Apr 01, 2009 8:15 pm

RE:yes or no
-----------------------------------
perhaps he doesn't know even what a boolean expression is, Tony. You have to remember that these kids no almost nothing about programming or even things as obscurely related to it as boolean expressions.
