Menu

Error "Missing Sub Definition or missing GoSub definition"

2025-03-11
2025-03-11
  • c-conversion

    c-conversion - 2025-03-11

    This is more a note to other users and to myself as a reminder.

    I had need to compile a program written about five years ago. This program was previously working without any noticeable issues. Today on compilation I got the error reported:

    Program.gcb (1172): Error: Missing Sub definition, or, missing GoSub definition
    

    Which pointed to this sub, specifically the 'End Sub' line:

    Sub ShowNameMessage
        Check_Switches
        If SwitchValue = SwUP Then
            Get_The_Values
            Print "Bon:    Gsw:    " 'Show the values
            Locate 0, 4
            Print (Acc_T_Value)
            Locate 0, 12
            Print (GSWin)
            Return
        End If
    
        '      0123456789012345
        Print " Super  Lottery " 'Show the splash screen
    End Sub
    

    Scratched my head for a while decoding this error and then decided to comment out the 'End Sub' line.
    The error then pointed to:

          Return
    

    I changed this to

          Exit Sub
    

    Then reinstated the 'End Sub'.

    This sub then compiled, but I had used 'Return' in another sub in the same way, preventing compilation at that point too.

    Changing the 'Return' there as well allowed the program to compile.

    I guess that at some point the compiler has been changed to not allow 'Return' to exit from a Subroutine, only to return from a GoSub.

    Confused me for a while though...

     
    • Anobium

      Anobium - 2025-03-11

      Your observations are correct.

      I tightened up the syntax EXIT SUB is now, correctly, associated with SUB.

      This change permits the syntax checking part of the compiler to ensure the source program are correctly structured.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.