locked
Small Basic EndIf RRS feed

  • Question

  • I am trying to make a small program on small basic but for some reason it says EndIf not found but it is there can someone help me.

    TextWindow.Title="Questionare"
    TextWindow.WriteLine("What is your favourite colour?")
    Blue = TextWindow.Read()
    If Blue Then
      TextWindow.WriteLine(" You are a shy person, but have the potential to be great")
      Red = TextWindow.Read()
      If Red Then
        TextWindow.WriteLine(" You are a passionate person but can be agressive")
        Yellow = TextWindow.Read()
        If Yellow Then 
          TextWindow.WriteLine (" You are a happy person but your happiness can provoke other people")
          Green = TextWindow.Read()
          If Green Then
            TextWindow.WriteLine("You are a neutral a mix of all the above")
          Else
            TextWindow.WriteLine(" I cannot figure out what you are please pick another colour")
    EndIf

    Here is the error Message 

    Sorry, we found some errors...

    17,1 Exspected EndIf but could not find one in the right place.

    17,1 Exspected EndIf but could not find one in the right place.

    17,1 Exspected EndIf but could not find one in the right place.

    17,1 Exspected EndIf but could not find one in the right place.

    Thank you for reading, please help me me

    Wednesday, April 2, 2014 9:47 PM

Answers

  • Each and every If must have an EndIf

    Use the right click + Format Program to do auto indentation to help spot un-EndIfs.

    TextWindow.Title="Questionare"
    TextWindow.WriteLine("What is your favourite colour?")
    Blue = TextWindow.Read()
    If Blue Then
      TextWindow.WriteLine(" You are a shy person, but have the potential to be great")
      Red = TextWindow.Read()
      If Red Then
        TextWindow.WriteLine(" You are a passionate person but can be agressive")
        Yellow = TextWindow.Read()
        If Yellow Then 
          TextWindow.WriteLine (" You are a happy person but your happiness can provoke other people")
          Green = TextWindow.Read()
          If Green Then
            TextWindow.WriteLine("You are a neutral a mix of all the above")
          Else
            TextWindow.WriteLine(" I cannot figure out what you are please pick another colour")
          EndIf
        EndIf
      EndIf
    EndIf
    PS there are some other reasons why your code wont work as you expect, but when it compiles you will see these, perhaps work on them and ask further questions - good luck.
    • Edited by litdev Wednesday, April 2, 2014 9:56 PM
    • Proposed as answer by WhTurner33Editor Thursday, April 10, 2014 7:46 AM
    • Marked as answer by litdev Saturday, April 12, 2014 7:03 PM
    Wednesday, April 2, 2014 9:54 PM