Results 1 to 11 of 11

Thread: Procedure is too large.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Procedure is too large.

    Anybody knows why vb6 can compile/run code with too large code inside a SUB/Function, but if you want to depure it step by step or so, it trows 'procedure too large'?. I had to divide a large procedure in 5 parts to avoid that error (with the nasty added overhead).

  2. #2
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Procedure is too large.

    VB.Net has no such subroutine code size limitation as it's modern recently to compare. . .

    Just kidding of course :-))

    I've heard the 64k lines per module limit being hit but this IDE (debugger?) limit sounds like something else might be at play.

    Do you use

    If Not Not MyArray Then

    . . . hack to test for empty arrays perhaps?

    cheers,
    </wqw>

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: Procedure is too large.

    Quote Originally Posted by wqweto View Post
    VB.Net has no such subroutine code size limitation as it's modern recently to compare. . .

    Just kidding of course :-))

    I've heard the 64k lines per module limit being hit but this IDE (debugger?) limit sounds like something else might be at play.

    Do you use

    If Not Not MyArray Then

    . . . hack to test for empty arrays perhaps?

    cheers,
    </wqw>
    nah, it is just the main command interpreter sub, it has a kilometer huge SELECT CASE CommandID .... and then like 400+ "CASE IS =" CommandConstantID

    and the problem yesterday was that I had to simulate the server in debug mode to run with the database from a customer and see what the hell was happening right there (an emergency technical support session). I failed to understand quickly because the code was full of several "procedure too large" everywhere that prevent to simulate the server in debug mode. The customer wasn't happy, as he wasn't unable to run his business all the morning.

  4. #4
    Fanatic Member
    Join Date
    Jan 2015
    Posts
    596

    Re: Procedure is too large.

    I had exactly the same problem.

    So I split the Select case in several sub function called :
    Select Case
    Case 1
    ...
    Case Else
    Call Sub1

    End Select

    etc...

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: Procedure is too large.

    Quote Originally Posted by Thierry69 View Post
    I had exactly the same problem.

    So I split the Select case in several sub function called :
    Select Case
    Case 1
    ...
    Case Else
    Call Sub1

    End Select

    etc...
    yes, I did the same, so, right now it is prepared. But hell, I had to split it in 5 parts., 4 parts wasn't enough.

    So, wondered how can be that it has a limit!.

  6. #6
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Procedure is too large.

    This generates code that compiles and can be debugged ok:

    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Dim sCode As String
        Dim lIdx As Long
        
        sCode = sCode & "Private Sub Test(ByVal lParam As Long)" & vbCrLf
        sCode = sCode & "    Select Case lParam" & vbCrLf
        For lIdx = 1 To 1000
            sCode = sCode & "    Case Is = " & lIdx & vbCrLf
            sCode = sCode & "        Debug.Print " & lIdx & vbCrLf
        Next
        sCode = sCode & "    End Select" & vbCrLf
        sCode = sCode & "End Sub" & vbCrLf
        Clipboard.Clear
        Clipboard.SetText sCode
        MsgBox "Sub Test() generated to clipboard", vbExclamation
    End Sub
    cheers,
    </wqw>

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: Procedure is too large.

    Quote Originally Posted by wqweto View Post
    This generates code that compiles and can be debugged ok:

    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Dim sCode As String
        Dim lIdx As Long
        
        sCode = sCode & "Private Sub Test(ByVal lParam As Long)" & vbCrLf
        sCode = sCode & "    Select Case lParam" & vbCrLf
        For lIdx = 1 To 1000
            sCode = sCode & "    Case Is = " & lIdx & vbCrLf
            sCode = sCode & "        Debug.Print " & lIdx & vbCrLf
        Next
        sCode = sCode & "    End Select" & vbCrLf
        sCode = sCode & "End Sub" & vbCrLf
        Clipboard.Clear
        Clipboard.SetText sCode
        MsgBox "Sub Test() generated to clipboard", vbExclamation
    End Sub
    cheers,
    </wqw>
    I don't think it has to do with lines-count, maybe the compiler inside the IDE has a primitive limit about space in RAM for each procedure. Or maybe it is the same that in compile mode, but in debug mode the code INFLATES inserting breaks allowing the step by step. What I can tell is that running the program in the IDE (F5) it performs way slower than the compiled EXE. Anyway, what a hasle!.

  8. #8
    Fanatic Member
    Join Date
    Jan 2015
    Posts
    596

    Re: Procedure is too large.

    I think Flyguille is right.

    For example, in my source, I add automatic line number and remove them if needed (automatic qith VBIDEUtils), (this is for the error handling)

    When I faced this problem, when I had the line numbers, and if I removed them, it was working (untill a certain time)

  9. #9
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Procedure is too large.

    A select case with hundreds of cases, which all have to be evaluated can be handled a little bit smarter using ranges
    If the ID is 233 then 233 compares have to be done
    Code:
    Select Case ID
      Case 1
      Case 2
      ..
      Case 100
      ..
      Case 200
      ..
      Case 233
      ..
    End Select
    Using this method a maximum of 100+3 case have to be done
    Code:
    Select Case ID
      Case 1 to 99:    SubSelect000(ID)
      Case 100 To 199: SubSelect100(ID)
      Case 200 To 299: SubSelect200(ID)
    End Select

  10. #10

  11. #11
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Procedure is too large.

    I had this problem with M2000 Interpreter. The solution is simple. Just create some subs and just call them instead using inline code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width