none
And in the ElseIf statement wont work RRS feed

  • Question

  • Hi,

    Right at the bottom of the code it'll have 

    ElseIf name = "name" Or name = "Name" And color = "colour" Or color = "color" Or color = "Colour" Or color = "Color" Then
    
    

    It doesn't seem to work in

    If name = "name" Then
      TextWindow.WriteLine("Really :/")
      TextWindow.WriteLine("Your Name is name")
      TextWindow.WriteLine(" ")
    ElseIf name = "Name" Then
      TextWindow.WriteLine("Really :/")
      TextWindow.WriteLine("Your Name is Name")
      TextWindow.WriteLine(" ")
    ElseIf color = "colour" Or color = "color" Or color = "Color" Or color = "Colour" Then
      TextWindow.WriteLine("Really :/")
      TextWindow.WriteLine("*facepalm*")
      TextWindow.WriteLine(" ")
    ElseIf name = "name" Or name = "Name" And color = "colour" Or color = "color" Or color = "Colour" Or color = "Color" Then
      TextWindow.WriteLine("Really...")
      TextWindow.WriteLine("You disappoint me")
      TextWindow.WriteLine(" ")
    EndIf

    Here is the whole code for testing purposes

    Start:
    TextWindow.Clear()
    TextWindow.WriteLine("Please Enter Your Name:")
    name = TextWindow.Read()
    
    TextWindow.WriteLine("Please Enter Your Age")
    age = TextWindow.ReadNumber()
    
    TextWindow.WriteLine("Please Enter Your Favourite Colour")
    color = TextWindow.Read()
    
    TextWindow.WriteLine(" ")
    If name = "name" Then
      TextWindow.WriteLine("Really :/")
      TextWindow.WriteLine("Your Name is name")
      TextWindow.WriteLine(" ")
    ElseIf name = "Name" Then
      TextWindow.WriteLine("Really :/")
      TextWindow.WriteLine("Your Name is Name")
      TextWindow.WriteLine(" ")
    ElseIf color = "colour" Or color = "color" Or color = "Color" Or color = "Colour" Then
      TextWindow.WriteLine("Really :/")
      TextWindow.WriteLine("*facepalm*")
      TextWindow.WriteLine(" ")
    ElseIf name = "name" Or name = "Name" And color = "colour" Or color = "color" Or color = "Colour" Or color = "Color" Then
      TextWindow.WriteLine("Really...")
      TextWindow.WriteLine("You disappoint me")
      TextWindow.WriteLine(" ")
    EndIf
    If age = "1" Then
      TextWindow.WriteLine("Hi, my name is " + name + ". " + "I am " + age + " year old. " + "My favourite colour is " + color + "." )
    ElseIf age < "1" Then
      TextWindow.WriteLine("Hi, my name is " + name + ". " + "I am " + age + " years..... oh. " + "My favourite colour is " + color + "." )
    Else
      TextWindow.WriteLine("Hi, my name is " + name + ". " + "I am " + age + " years old. " + "My favourite colour is " + color + "." )
    EndIf
    TextWindow.WriteLine(" ")
    TextWindow.WriteLine("To Reset Program type (Reset)")
    TextWindow.WriteLine("To End Program type (End)")
    TextWindow.WriteLine(" ")
    user1 = TextWindow.Read()
    If user1 = "Reset" Or user1 = "reset" Then
      Goto Start
    ElseIf user1 = "End" or user1 = "end" Then
      Program.End()
    Else
      TextWindow.Clear()
      TextWindow.WriteLine("Input Is Not Recognized")
      TextWindow.WriteLine("Try Again")
      TextWindow.WriteLine(" ")
      TextWindow.WriteLine("Type (Reset) to Reset Program")
      TextWindow.WriteLine("Type (End) to End Program")
      TextWindow.WriteLine(" ")
      user2 = TextWindow.Read()
      If user2 = "Reset" Or user2 = "reset" Then
        Goto Start
      ElseIf user2 = "End" or user2 = "end" Then 
        Program.End()
      EndIf
    EndIf


    I love coding. This is signature is 100% Original. :)

    Friday, February 10, 2017 5:19 PM

Answers

  • If name="name" in your first published part, the last elseif will NEVER be executed. 

    If name="name" the three following lines will execute, and on reaching the ElseIf the program jumps to the Endif.

    You have to rethink your logic ;-)


    Jan [ WhTurner ] The Netherlands

    Friday, February 10, 2017 6:36 PM
    Answerer