Computer Science Canada

Multiple If's

Author:  Namis [ Wed Sep 24, 2003 11:24 pm ]
Post subject:  Multiple If's

Heres my code ;o

code:
put " Would you like some music while you answer my 20 questions? <Yes> or <No> "
if yes = "yes" or yes = "Yes" or yes = "YES" or yes = "YeS" or yes = "yES" or yes = "YEs" or yes = "yeS" or yes = "yEs"
        then
    put " Cool! Which band would you like to listen to? "
    delay (2000)
    put " <tool> or <malicemizer> or <aperfectcircle> "
    get music
    if music = "tool" or music = "Tool" or music = "TOOL" or music = "ToOl" or music = "TOol" or music = "tOOl" or music = "TOOl" or music = "ToOL"
            then
        put " Great Choice, Tool - Schism, will now play "
        delay (1000)
    %testing
Music.PlayFile ("C:\\Documents and Settings\Andrew\Desktop\Music\Tool\Lateralus.mp3")
end if


now for the other bands, ( and more songs after i figure out how this works ) do i keep it all under 1 if statement? or do i use multiple if statements? or do i j ust change the command line to

if music = "malicemizer" or
if music = "aperfectcircle" etc?
Something like this?
tool/malicemizer/aperfectcircle being different bands.

Author:  Namis [ Wed Sep 24, 2003 11:24 pm ]
Post subject: 

code:
put " Would you like some music while you answer my 20 questions? <Yes> or <No> "
if yes = "yes" or yes = "Yes" or yes = "YES" or yes = "YeS" or yes = "yES" or yes = "YEs" or yes = "yeS" or yes = "yEs"
        then
    put " Cool! Which band would you like to listen to? "
    delay (2000)
    put " <tool> or <malicemizer> or <aperfectcircle> "
    get music
    if music = "tool" or music = "Tool" or music = "TOOL" or music = "ToOl" or music = "TOol" or music = "tOOl" or music = "TOOl" or music = "ToOL"
           then
        put " Great Choice, Tool - Schism, will now play "
        delay (1000)
    %testing
Music.PlayFile ("C:\\Documents and Settings\Andrew\Desktop\Music\Tool\Lateralus.mp3")
end if
    if music = "malicemizer"
           then
        put " Great Choice, Malice Mizer - Baroque, will now play "
        delay (1000)
    %testing
Music.PlayFile ("C:\Documents and Settings\Andrew\Desktop\Music\Malice Mizer\CD4MEPLZ\Baroque.mp3")
end if
    if music = "aperfectcircle"
     then
        put " Great Choice, A Perfect Circle - Three Libras, will now play "
        delay (1000)
    %testing
Music.PlayFile ("C:\Documents and Settings\Andrew\Desktop\Music\A Perfect Circle\Three Libras.mp3")
end if

Author:  Tony [ Wed Sep 24, 2003 11:29 pm ]
Post subject: 

come on, there's a tutorial on elsif's right here

I know you know its there because you even replied to that some time ago. Confused

Anyways, you need to make your program more organized. There're way to many ifs inside other ifs.

Also you should use a function that changes string to all caps (or all small) so that you dont write out two lines of possible input. Someone already wrote it, was probly even a re to one of your previous topics.

Author:  Namis [ Wed Sep 24, 2003 11:30 pm ]
Post subject: 

Yeah im a retard, stab me in the face.

and if you think that is unorganized you should see the rest of my code, i get lost just looking at it Surprised

Author:  Tony [ Wed Sep 24, 2003 11:33 pm ]
Post subject: 

Namis wrote:
Yeah im a retard, stab me in the face


*Tony stabs Namis in his face Twisted Evil *

Author:  Amailer [ Wed Sep 24, 2003 11:55 pm ]
Post subject: 

tony wrote:
Namis wrote:
Yeah im a retard, stab me in the face


*Tony stabs Namis in his face Twisted Evil *


how evil lol

Author:  Blade [ Thu Sep 25, 2003 5:18 pm ]
Post subject: 

tony wrote:
Namis wrote:
Yeah im a retard, stab me in the face


*Tony stabs Namis in his face Twisted Evil *



ROCK ON MAN!!!! i wanted to stab him in the face but i didnt get here till later Sad

Author:  krishon [ Thu Sep 25, 2003 5:55 pm ]
Post subject: 

even tho there are lots of ifs...some times...u hafta put some ifs inside others...especially in games. You must write the code for every single possiblilty (which is sometimes an ass)

Author:  PaddyLong [ Thu Sep 25, 2003 10:04 pm ]
Post subject: 

man... you would be so better off writing some function to compare whether some variable is equal (case insensitive) to some word...

something like this...

code:

function wordsEqual (input, actualString : string) : boolean
    if length (input) not= length (actualString) then
        result false
    end if

    for i : 1 .. length (input)
        if ord (actualString (i)) >= 65 and ord (actualString (i)) <= 90 then
            if ord (input (i)) not= ord (actualString (i)) and
                    ord (input (i)) not= ord (actualString (i)) + 32 then
                result false
            end if
        elsif ord (actualString (i)) >= 97 and ord (actualString (i)) <= 122
                then
            if ord (input (i)) not= ord (actualString (i)) and
                    ord (input (i)) not= ord (actualString (i)) - 32 then
                result false
            end if
        else
            if ord (input (i)) not= ord (actualString (i)) then
                result false
            end if
        end if
    end for

    result true
end wordsEqual


then use it like this...

if wordsEqual (someInput, "yes") = true then
do whatever it is you do if they entered yes
end if


: