none
EXPECTED ENDIF BUT COULD NOT FIND ONE IN THE RIGHT PLACE RRS feed

  • Question

  • What is quickest way to get rid of the error message EXPECTED ENDIF BUT COULD NOT FIND ONE IN THE RIGHT PLACE. I was making them go away fairly easy in my Code until I started getting into the hundreds of IF statements and I have tried but cannot find where my IF statements are missing an ENDIF.
    Saturday, March 9, 2013 7:17 PM

Answers

  • Try publishing it and post the 6 character ID.
    • Marked as answer by Baegos Daegos Saturday, March 9, 2013 11:07 PM
    Saturday, March 9, 2013 9:24 PM
    Moderator
  • In the Small Basic interface

    1] Load you problem file

    2] Hit 'Publish' button in the ribbon (top bar of the SB interface) in the "Web" section

    3] Post the 6 digit code it gives you here

    • Marked as answer by Baegos Daegos Saturday, March 9, 2013 11:07 PM
    Saturday, March 9, 2013 10:00 PM
    Moderator
  • Can you try to copy and paste sections of your IF code into another smaller file, tweek the variables and test.

    Good luck. You reminded of something in an article i read by litDev. This maybe helpful. http://social.technet.microsoft.com/wiki/contents/articles/15081.small-basic-programming-tips.aspx#Goto

    "Try to think of a program structure at the start,
    then create the main subroutines and variables/arrays and gradually add the
    detail. Test detail in small prototype programs first, then add to the main
    program.<o:p></o:p>

    The temptation is to add all the fine detail of a
    program at the start and then build a structure around this, but this will
    often lead to code that is hard to develop and debug."<o:p></o:p>


    • Marked as answer by Baegos Daegos Saturday, March 9, 2013 11:07 PM
    Saturday, March 9, 2013 10:22 PM
    Moderator
  • I think it's better to keep random number in a variable.

    rand = Math.GetRandomNumber(12)

    If rand = 1 Then

    ...


    Nonki Takahashi

    • Marked as answer by Baegos Daegos Thursday, March 14, 2013 12:01 AM
    Wednesday, March 13, 2013 4:46 AM
    Moderator

All replies

  • Inside Small Basic IDE, you can right-click on your code's sub-window and choose 'Format Program'.

    It will help you out tremendously to spot where an EndIf may be missing and many other types of errors!  ;-)


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Saturday, March 9, 2013 7:39 PM
    Answerer
  • I would have thought when I clicked FORMAT that I would be able to tell where the problem is, but I had no success.

    I tried to post an edited copy of my Code for you to see, but this stupid Forum hits me with a 60000 character limit which I AM WELL UNDER!!!!!

    Saturday, March 9, 2013 8:39 PM
  • split up your code over multiple posts, that should help
    Always Think Big

    Saturday, March 9, 2013 8:45 PM
  • doesnt help because the stupid Forum wont accept anything I post that is Code.
    Saturday, March 9, 2013 8:58 PM
  • Try publishing it and post the 6 character ID.
    • Marked as answer by Baegos Daegos Saturday, March 9, 2013 11:07 PM
    Saturday, March 9, 2013 9:24 PM
    Moderator
  • ho w do I find the 6 character ID so that I can include it in the post? I dont know how this works.
    Saturday, March 9, 2013 9:26 PM
  • In the Small Basic interface

    1] Load you problem file

    2] Hit 'Publish' button in the ribbon (top bar of the SB interface) in the "Web" section

    3] Post the 6 digit code it gives you here

    • Marked as answer by Baegos Daegos Saturday, March 9, 2013 11:07 PM
    Saturday, March 9, 2013 10:00 PM
    Moderator
  • Can you try to copy and paste sections of your IF code into another smaller file, tweek the variables and test.

    Good luck. You reminded of something in an article i read by litDev. This maybe helpful. http://social.technet.microsoft.com/wiki/contents/articles/15081.small-basic-programming-tips.aspx#Goto

    "Try to think of a program structure at the start,
    then create the main subroutines and variables/arrays and gradually add the
    detail. Test detail in small prototype programs first, then add to the main
    program.<o:p></o:p>

    The temptation is to add all the fine detail of a
    program at the start and then build a structure around this, but this will
    often lead to code that is hard to develop and debug."<o:p></o:p>


    • Marked as answer by Baegos Daegos Saturday, March 9, 2013 11:07 PM
    Saturday, March 9, 2013 10:22 PM
    Moderator
  • I think I have cleared up that problem, but now it doesnt recognize Y from this part of the Code..

    If DOWN = 4 Then

                  TextWindow.WriteLine ("Go for it on 4th down? Y or N")
                                                                                          Decision = TextWindow.Read()
                                                                                        Else
                                                                                          goto A
                                                                                        EndIf

                                                                                        If Decision = Y then

    Goto A

                                                                                       
    Saturday, March 9, 2013 11:03 PM
  • Its running now and I did it myself lol
    Saturday, March 9, 2013 11:08 PM
  • Its still got problems but I was able to publish. here it is:

    ZBX445

    Sunday, March 10, 2013 12:26 AM
  • Its still got problems but I was able to publish. here it is:

    ZBX445

    Sunday, March 10, 2013 12:27 AM
  • Select all source (with Ctrl+A) and click mouse right button and select "Format Program".

    I think you need four more EndIf.


    Nonki Takahashi

    Sunday, March 10, 2013 7:18 AM
    Moderator
  • As Nonki says there are several endifs missing at the end, should be:

              EndIf
            EndIf
          EndIf
        EndIf
      EndIf
    EndSub  
    
    However, the complexity of the program is part of the problem - perhaps consider using more subroutines for some of the logic.

    Sunday, March 10, 2013 10:48 AM
    Moderator
  • Baegos Daegos,

    I didnt fully examine your code, but found a part which doesn't do what you want !

    The part "YARDS GAINED" after line 549 in ZBX445 contains Math.GetRandomNumber(12) without putting the result in a variable, this is unnessesary. Then you have a if Random(12)=1

    elseif GetRandom(12)=2 . Each call of Math.GetRandomNumber(12) gets a NEW randomnumber. I think this not what you want.


    Jan [ WhTurner ] The Netherlands

    Sunday, March 10, 2013 6:15 PM
    Answerer
  • Can you tell me what I should have used instead to capture the result of Math.GetRandomNumber(12)
    Wednesday, March 13, 2013 2:27 AM
  • It is very common to functions to return a value.

    Math.GetRandomNumber() returns a random number. If you don't do anything with it, what's the purpose to call it in the 1st place?

    Any variable will do to store the value returned!

    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Wednesday, March 13, 2013 3:28 AM
    Answerer
  • I think it's better to keep random number in a variable.

    rand = Math.GetRandomNumber(12)

    If rand = 1 Then

    ...


    Nonki Takahashi

    • Marked as answer by Baegos Daegos Thursday, March 14, 2013 12:01 AM
    Wednesday, March 13, 2013 4:46 AM
    Moderator
  • I recommend you to use subroutines like follows:

    Sub action
      Path= Program.Directory +"\football.txt" 
      If (Controls.LastClickedButton = Submit1) Then
        DoSubmit1()
      ElseIf (Controls.LastClickedButton = Submit2) Then
        DoSubmit2()
      ElseIf (Controls.LastClickedButton = cointoss) Then
        DoCointoss()
      ElseIf (Controls.LastClickedButton = kickoff) Then
        DoKickoff()
      ElseIf (Controls.LastClickedButton = Exit) Then
        Program.End()
      Else
        GraphicsWindow.ShowMessage ("Invalid Operation", "Invalid Operation")
      EndIf
    EndSub
    
    Sub DoSubmit1
      counter = Controls.GetTextBoxText(hometeamnum)+1
      x = counter 
      TextWindow.Write(x)
      Data[x]=file.ReadLine(path,x)' 
      'Array.SetValue("Array",x,data)
      TextWindow.WriteLine(" Name.."+Data[x]["Team Name"]+" QB1.."+Data[x]["QB1 Rating"]+" QB2.."+Data[x]["QB2 Rating"]+" HB1.."+Data[x]["HB1 Rating"]+ " HB2.."+Data[x]["HB2 Rating"]+" FB1.."+Data[x]["FB1 Rating"]+ " FB2.."+Data[x]["FB2 Rating"]+" WRA1.."+Data[x]["WRA1 Rating"]+ " WRA2.."+Data[x]["WRA2 Rating"]+ " TE1.."+Data[x]["TE1 Rating"]+ " TE2.."+Data[x]["TE2 Rating"]+ " WRB1.."+Data[x]["WRB1 Rating"]+ " WRB2.."+Data[x]["WRB2 Rating"]+ " WRC1.."+Data[x]["WRC1 Rating"]+ " WRC2.."+Data[x]["WRC2 Rating"]+ " OTA1.."+Data[x]["OTA1 Rating"]+ " OTA2.."+Data[x]["OTA2 Rating"]+ " OTB1.."+Data[x]["OTB1 Rating"]+ " OTB2.."+Data[x]["OTB2 Rating"]+ " OGA1.."+Data[x]["OGA1 Rating"]+ " OGA2.."+Data[x]["OGA2 Rating"]+ " OGB1.."+Data[x]["OGB1 Rating"]+ " OGB2.."+Data[x]["OGB2 Rating"]+ " DTA1.."+Data[x]["DTA1 Rating"]+ " DTA2.."+Data[x]["DTA2 Rating"]+ " DTB1.."+Data[x]["DTB1 Rating"]+ " DTB2.."+Data[x]["DTB2 Rating"]+ " DEA1.."+Data[x]["DEA1 Rating"]+ " DEA2.."+Data[x]["DEA2 Rating"]+ " DEB1.."+Data[x]["DEB1 Rating"]+ " DEB2.."+Data[x]["DEB2 Rating"]+" LBA1.."+Data[x]["LBA1 Rating"]+" LBA2.."+Data[x]["LBA2 Rating"]+" LBB1.."+Data[x]["LBB1 Rating"]+" LBB2.."+Data[x]["LBB2 Rating"]+" LBC1.."+Data[x]["LBC1 Rating"]+" LBC2.."+Data[x]["LBC2 Rating"]+" CBA1.."+Data[x]["CBA1 Rating"]+" CBA2.."+Data[x]["CBA2 Rating"]+" CBB1.."+Data[x]["CBB1 Rating"]+" CBB2.."+Data[x]["CBB2 Rating"]+" CBC1.."+Data[x]["CBC1 Rating"]+" CBC2.."+Data[x]["CBC2 Rating"]+" S1.."+Data[x]["S1 Rating"]+" S2.."+Data[x]["S2 Rating"]+" KT.."+Data[x]["Kicking Team Rating"])   
      
      SUMHOMEOFFENSE= Data[x]["QB1 Rating"]+ Data[x]["HB1 Rating"] + Data[x]["FB1 Rating"] + Data[x]["WRA1 Rating"] + Data[x]["TE1 Rating"] + Data[x]["WRB1 Rating"] + Data[x]["WRC1 Rating"] + Data[x]["OTA1 Rating"] + Data[x]["OTB1 Rating"] + Data[x]["OGA1 Rating"] + Data[x]["OGB1 Rating"] 
      TextWindow.Write(SUMHOMEOFFENSE) 
      HOMETEAM = Data[x]["Team Name"]
      TextWindow.Write(HOMETEAM)
      SUMHOMEDEFENSE= Data[x]["DTA1 Rating"]+ Data[x]["DTB1 Rating"] + Data[x]["DEA1 Rating"] + Data[x]["DEB1 Rating"] + Data[x]["LBA1 Rating"] + Data[x]["LBB1 Rating"] + Data[x]["LBC1 Rating"] + Data[x]["CBA1 Rating"] + Data[x]["CBB1 Rating"] + Data[x]["CBC1 Rating"] + Data[x]["S1 Rating"] 
      TextWindow.Write(SUMHOMEDEFENSE)
      SUMHOMERUN = Data[x]["QB1 Rating"]+ Data[x]["HB1 Rating"]+ Data[x]["FB1 Rating"]+ Data[x]["OGA1 Rating"]+ Data[x]["OGB1 Rating"]+ Data[x]["OTA1 Rating"]+ Data[x]["OTA1 Rating"]
      SUMHOMEPASS = Data[x]["QB1 Rating"]+ Data[x]["TE1 Rating"]+Data[x]["WRA1 Rating"]+Data[x]["WRAB1 Rating"]+Data[x]["WRC1 Rating"]
      
      HOMEKICKING= Data[x]["Kicking Team Rating"]
    EndSub
    


    Nonki Takahashi

    Wednesday, March 13, 2013 4:52 AM
    Moderator