Computer Science Canada Problem - Is there a different command for or? |
Author: | Namis [ Mon Sep 22, 2003 1:52 pm ] |
Post subject: | Problem - Is there a different command for or? |
Im getting an error for this, whats wrong with it? if z = "Yes" or "yes" or "YES" or "yEs" or "yES" or "YeS" else exit end if |
Author: | Tony [ Mon Sep 22, 2003 3:43 pm ] | ||
Post subject: | |||
because you're not doing it right. The way OR (AND NOR, etc) acts, is that they compare two values around itself and produces a result. z = "Yes" produces true "yes" by itself doesnt produce a boolean value so you get an error because OR cant compare two sides. the proper way of doing it is:
|
Author: | Dan [ Mon Sep 22, 2003 4:10 pm ] | ||
Post subject: | |||
i think a case could be of help here (called a switch in most other languses) ex.
but i think there may be a fuction that checks to see if it is the same worad but in dif caps wich whould wrok better (or is that just in c/c++?) |
Author: | Tony [ Mon Sep 22, 2003 4:55 pm ] |
Post subject: | |
most languages have compareStringIgnoreCase function. Well atleast Java does ![]() Turing might have that too. If not, could someone write it and post it in Turing Submitions? Might be useful. |
Author: | krishon [ Mon Sep 22, 2003 4:55 pm ] |
Post subject: | |
i wuz gonna say use elsifs but it'll be a hastle |
Author: | Martin [ Mon Sep 22, 2003 6:51 pm ] | ||||
Post subject: | |||||
Here's the code for a toUpperCase function...haven't done turing in a while so this might be buggy
All you'd have to do then is say..
|
Author: | Blade [ Mon Sep 22, 2003 7:59 pm ] | ||||
Post subject: | |||||
umm.... in your code you dont have a 'then' after your if statement
is really what you had, this is what you want
|
Author: | Namis [ Wed Sep 24, 2003 9:22 pm ] | ||
Post subject: | Error | ||
|
Author: | Blade [ Wed Sep 24, 2003 9:39 pm ] | ||
Post subject: | |||
heh.... you need a colon equals ":=" |
Author: | Tony [ Wed Sep 24, 2003 10:03 pm ] | ||||
Post subject: | |||||
Blade wrote: heh.... you need a colon equals ":=" plz dont screw the poor kid up ![]() you do NOT use := in an if statment ![]()
as I said it before, you have to use separate conditional statments. the proper way:
|
Author: | Namis [ Wed Sep 24, 2003 10:03 pm ] |
Post subject: | |
:= doesnt work, anyway i guess i didnt have quotations around if yes : blah blah blah silly me thanks tony |
Author: | Namis [ Wed Sep 24, 2003 10:08 pm ] |
Post subject: | |
got it working, thanks :O |
Author: | krishon [ Thu Sep 25, 2003 6:01 pm ] |
Post subject: | |
lol, bout the to Uppercase function.........java does that automatically for u ![]() |