Method is too long !

Yes. If you submit a private feedback report to Xojo it remains safe. You could also sanitize a copy of your application a bit. Take out some of the sensitive stuff and just submit what is needed to Xojo.

[quote=131585:@Syed Hassan]Please see what is the size of file “.xojo_window” of this Window1 and also how many lines are in this file.
[/quote]

The size of file “.xojo_window” is : 4,4 Mo
Number of lines in the file : 121707

Thats not a meaningful metric
Without submitting the report I can’t tell you WHY this would do this - it should’t

The dummy code used to get the same error had more than 40000 lines in a method in the main Window1 of the project. So most likley the reported problem is also caused by similar situation.

See the method name shown in the error message. That method must have too much code, more than the system limit.

Here is the VBA code used in Microsoft Excel 2010 (triggered by the comment “// Start dummy” in the “.xojo_window” file) to add as many lines of code as needed. In the same manner the other part of the code is triggered by the name of an existing TextField to add as many unique TextField objects in the Window1 as needed.

[code]Option Explicit

Public Function AddDummyCode()

Dim strLineIn As String
Dim strLineOut As String

Dim intFileIn As Integer
Dim intFileOut As Integer

Dim strFileInName As String
Dim strFileOutName As String

strFileInName = “C:\RBProjects\MethodTooLong\Window1.orig.xojo_window”
strFileOutName = “C:\RBProjects\MethodTooLong\Window1.xojo_window”

intFileIn = FreeFile
Open strFileInName For Input As #intFileIn

intFileOut = FreeFile
Open strFileOutName For Output As #intFileOut

Dim intLoop As Integer
Dim strLoop As String

Do While Not EOF(intFileIn)
Line Input #intFileIn, strLineIn
strLineOut = strLineIn

'
' Qualify on existing TextField object
'
If InStr(strLineOut, "Begin TextField tfCount") > 0 Then

    '
    ' Set the required number of TextField objects here
    '
    For intLoop = 1 To 0
            
        strLoop = Trim(Str(intLoop))
        If Len(strLoop) < 4 Then
            strLoop = String(4 - Len(strLoop), "0") & strLoop
        End If
        
        Print #intFileOut, "  Begin TextField tfCount" & strLoop
        Print #intFileOut, "     AcceptTabs      =   False"
        Print #intFileOut, "     Alignment       =   0"
        Print #intFileOut, "     AutoDeactivate  =   True"
        Print #intFileOut, "     AutomaticallyCheckSpelling=   False"
        Print #intFileOut, "     BackColor       =   &cFFFFFF00"
        Print #intFileOut, "     Bold            =   False"
        Print #intFileOut, "     Border          =   True"
        Print #intFileOut, "     CueText         =   " & Chr(34) & Chr(34)
        Print #intFileOut, "     DataField       =   " & Chr(34) & Chr(34)
        Print #intFileOut, "     DataSource      =   " & Chr(34) & Chr(34)
        Print #intFileOut, "     Enabled         =   True"
        Print #intFileOut, "     Format          =   " & Chr(34) & Chr(34)
        Print #intFileOut, "     Height          =   22"
        Print #intFileOut, "     HelpTag         =   " & Chr(34) & Chr(34)
        Print #intFileOut, "     Index           =   -2147483648"
        Print #intFileOut, "     Italic          =   False"
        Print #intFileOut, "     Left            =   96"
        Print #intFileOut, "     LimitText       =   0"
        Print #intFileOut, "     LockBottom      =   False"
        Print #intFileOut, "     LockedInPosition=   False"
        Print #intFileOut, "     LockLeft        =   True"
        Print #intFileOut, "     LockRight       =   False"
        Print #intFileOut, "     LockTop         =   True"
        Print #intFileOut, "     Mask            =   " & Chr(34) & Chr(34)
        Print #intFileOut, "     Password        =   False"
        Print #intFileOut, "     ReadOnly        =   False"
        Print #intFileOut, "     Scope           =   0"
        Print #intFileOut, "     TabIndex        =   1"
        Print #intFileOut, "     TabPanelIndex   =   0"
        Print #intFileOut, "     TabStop         =   True"
        Print #intFileOut, "     Text            =   " & Chr(34) & Chr(34)
        Print #intFileOut, "     TextColor       =   &c00000000"
        Print #intFileOut, "     TextFont        =   " & Chr(34) & "System" & Chr(34)
        Print #intFileOut, "     TextSize        =   0.0"
        Print #intFileOut, "     TextUnit        =   0"
        Print #intFileOut, "     Top             =   42"
        Print #intFileOut, "     Underline       =   False"
        Print #intFileOut, "     UseFocusRing    =   True"
        Print #intFileOut, "     Visible         =   True"
        Print #intFileOut, "     Width           =   184"
        Print #intFileOut, "  End"
          
    Next
End If

If InStr(strLineOut, "// Start dummy") > 0 Then
    
    Print #intFileOut, ""
    Print #intFileOut, ""
    Print #intFileOut, ""
    Print #intFileOut, "Dim intNewVal As Int32"
    Print #intFileOut, "Dim intNewVal2 As Int32"
    Print #intFileOut, ""
    
    For intLoop = 1 To 20000

        Print #intFileOut, "intNewVal = " & Trim(Str(Int(Rnd() * 100)))
        Print #intFileOut, "intNewVal2 = " & Trim(Str(Int(Rnd() * 100)))
        
        Print #intFileOut, "If intNewVal > intNewVal2 Then"
        Print #intFileOut, " intNewVal = intNewVal2"
        Print #intFileOut, "End If"
        
    Next
    
    Print #intFileOut, ""
    Print #intFileOut, ""
    
End If

Print #intFileOut, strLineOut

Loop

Close #intFileIn
Close #intFileOut

End Function
[/code]

[quote=131791:@Syed Hassan]The dummy code used to get the same error had more than 40000 lines in a method in the main Window1 of the project. So most likley the reported problem is also caused by similar situation.

See the method name shown in the error message. That method must have too much code, more than the system limit.
[/quote]
Except the method is one the IDE generated from his layout - not one he wrote.
Hence why I keep asking for a copy of the window so I can see why the IDE would generate this - it never should.
Biut since I never get a copy I’ll quit asking

Norm, Is seeing the widow sufficient or do you need to see his whole app, you’ve asked for both at different times in this thread.

If the window is sufficient, he may feel more comfortable sending just that to you. So you may want to tell him how to extract just the window from his project in a way that’s useful to you.

[quote=132129:@Joe Huber]Norm, Is seeing the widow sufficient or do you need to see his whole app, you’ve asked for both at different times in this thread.

If the window is sufficient, he may feel more comfortable sending just that to you. So you may want to tell him how to extract just the window from his project in a way that’s useful to you.[/quote]

I sent my project to Norman via private Feedback. :slight_smile:

Well I can say its NOT what I supposed it might be
The thing I thought would be the problem isn’t - it does exactly as intended

What IS the problem seems to be a single class definition (for the Window) that is just plain far beyond what the compiler can handle (essentially a class definition that exceeds whats possible)

I’ll have Joe peek at this

[quote=132169:@Norman Palardy]Well I can say its NOT what I supposed it might be
The thing I thought would be the problem isn’t - it does exactly as intended

What IS the problem seems to be a single class definition (for the Window) that is just plain far beyond what the compiler can handle (essentially a class definition that exceeds whats possible)

I’ll have Joe peek at this[/quote]

So it was not a single control that overfilled the window ?

No
Not a single control as far as I can tell

I have the exact same problem with my main window when I add lines of code to a big calculation method.
Has this limit been addressed? I have already pealed code off to other subs to try to reduce the size… but when I add a few lines get the error again. Sigh.

Also do comments get stripped out BEFORE IDE determines the method is too long???

I have a few methods that were so long I could hardly stand to type in them that I’ve been slowly refactoring and I never got this error from them. You guys must be writing some impressive amounts of code in a single method!

well I think it’s time to have some refactoring of your methods …
thanks Xojo has some nice tools in the IDE for that !

I must agree, that if you have a method that is too long for the compiler, than it is probably too long to be easily maintained, and therefore should be refactored. You might also find that you have code that during refactoring could be reduced/reused and therefore make the overall foot print even smaller.

I come from the original programming school where you had to fit you entire program into 64k or less (where the first programs had to fit in 4k or less)… yes I said “K” not Meg, and decidedly not Gig. Obviously the world was a much “simpler” environment then, but it still took a lot of thought to get it right the first time

my first programs had to fit inside 512 bytes, and you programmed it with punched cards …
the “computer” was named “alphatronic” if I recall correctly.

Edit: bad recall the alphatronic had 64kb of programming space …

Just tried:

[code]Dim i as integer

i = i + 1
**above line 250,000 times

msgbox str(i)[/code]

in a method, the IDE crawled, but it ran and compiled just fine. Are you saying your single method is over 250,000 lines of code?

***IDE crashed after compile lol…but it built successfully.

I appreciate all of the sentiments to shorten the method. Really I do but it is a very long math algorithm to model retirement planning. Very complicated. There is not anything called multiple times that can be pulled out. I have already pealed out parts into other methods even.

How do I determine the number of lines?

I added a few lines today and got the error again. Moved those to one method I have to peal off some of the top of method code and another at the bottom just to split it up some. Very artificial way to split off code into other methods. Just moving it somewhere else to reduce code lines.

The issue isn’t with the number of lines of code. It’s the amount of local data in the stack frame, which includes all the intermediate result values the compiler creates in addition to your Dim’d local variables. That’s why there appears to be a correlation with line count, but it’s not consistent. Matthew’s example can get away with a lot of code because it doesn’t create many local variables (intermediate values).

I would recommend you move local variables to a module or class. That will also facilitate breaking up the code.