Announcement

Collapse
No announcement yet.

Error 402 - Statement too complex

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error 402 - Statement too complex

    After adding some simple lines of code, I started getting
    "Error 402 in ... Statement too complex". The compiler doesn't
    stop at any of the simple lines I added, but it stops at a
    line which says "End If". Part of that IF block is nested
    several levels deep, but it hasn't been a problem before. And
    commenting out that entire block of code makes the compiler stop
    somewhere else.

    Before spending a large amount of time narrowing it down, I
    decided to first search the message forums. I see that someone
    had reported Error 402, and Tech Support requested the code,
    and thanked him after receiving it and said that R&D would
    analyze it. Based on what R&D may have found are there any
    suggestions for avoiding this or tracking it down?

    I assumed that it could be related to the size of the project.
    But even when I arbitrarily remove large sections of code,
    Error 402 remains if I keep the offending line (a simple one-line
    IF statement). And on the other hand, when I comment out that
    line, it compiles fine, even if I add a bunch of other lines.

    I'm not using the THREAD keyword in my code like the other users
    who had this problem (although I see that I do have a constant
    named %Base_Thread; I don't know if that makes a difference).

    (This whole problem came about as I was manually adding lines
    throughout the code to trap an error. With a global error
    handler, I probably wouldn't have to do this).

    ------------------
    Daniel Corbier
    UCalc Fast Math Parser
    http://www.ucalc.com
    Daniel Corbier
    uCalc Fast Math Parser
    uCalc Language Builder
    sigpic

  • #2
    Hi Daniel,

    Without seeing your code, it is not possible to be sure this is the same problem, however I'll see what I can find out. First, can you please email the code that shows up the problem (along with a note about which statement is the apparent cause), and I'll take the matter up with R&D.

    Thanks!


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      I gradually stripped and modified the code until it became short
      and simple enough to post.

      Code:
      Function F1(txt As Asciiz) As Long
         If VarPtr(txt) = 0 Then Exit Function
      End Function
      
      Function F2(txt As Asciiz) As Long
         If VarPtr(txt) = 0 Then Exit Function
      End Function
      
      Function F3(txt As Asciiz) As Long
         If VarPtr(txt) = 0 Then Exit Function
      End Function
      
      Function F4(txt As Asciiz) As Ext
         If VarPtr(txt) = 0 Then Exit Function
      End Function
      
      Function F5(txt As Asciiz) As Double
         If VarPtr(txt) = 0 Then Exit Function
      End Function
      
      Function F6(txt As Asciiz) As String
         If VarPtr(txt) = 0 Then Exit Function
      End Function
      
      Function F7(txt As Asciiz) As Dword
         If VarPtr(txt) = 0 Then Exit Function
      End Function
      
      Sub DoSomething(ByVal x As Long)
         Dim AddressList(x) As Dword
         GoTo Dword AddressList(1)
      End Sub
      
      Function Before(ByVal x As Long, ByVal y As Long) As String
      
      End Function
      
      Function After(ByVal x As Long) As Dword
         MyText$ = Before(x, 1)
      End Function
      The compiler displays the error at the last "End Function" line.
      If you remove any of the lines, this error goes away. The newest
      lines of code that I had added to my were:

      If VarPtr(...) Then MsgBox ...

      I intended to add this throughout the project to all routines
      that took an ASCIIZ argument. So like something that happened
      before, manually adding my own error checking code gave me an
      extra problem to solve.

      This error is in PB/DLL. In PB/CC, a less simplified version
      of the same code produced "Error 480" right on the "If VarPtr()"
      line. I assume that the problem is related.

      ------------------
      Daniel Corbier
      UCalc Fast Math Parser
      http://www.ucalc.com
      Daniel Corbier
      uCalc Fast Math Parser
      uCalc Language Builder
      sigpic

      Comment


      • #4
        is this GoTo Dword AddressList(1) piece staying inside it's own sub?


        ------------------
        Scott
        Scott Turchin
        MCSE, MCP+I
        http://www.tngbbs.com
        ----------------------
        True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

        Comment


        • #5
          is this GoTo Dword AddressList(1) piece staying inside it's own sub?
          Yes. If you add these two lines before the GoTo DWORD line:

          Test:
          AddressList(1) = CodePtr(Test)

          You'll see that error 402 still pops up.

          ------------------
          Daniel Corbier
          UCalc Fast Math Parser
          http://www.ucalc.com
          Daniel Corbier
          uCalc Fast Math Parser
          uCalc Language Builder
          sigpic

          Comment


          • #6
            Thanks! I've passed it to R&D to investigate. I'll let you know what I can find out.

            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment


            • #7
              What's the latest news from R&D on this?

              ------------------
              Daniel Corbier
              UCalc Fast Math Parser
              http://www.ucalc.com
              Daniel Corbier
              uCalc Fast Math Parser
              uCalc Language Builder
              sigpic

              Comment


              • #8
                Daniel,

                just now I'm having this ERROR 402. I solved my problem simply adding a #REGISTER NONE metastatement to the program. I think an explanation is, may be the register variables are pushed and popped from the stack too many times (something goes to overflow?), whereas non-register variables have a fixed position on the stack.


                [added later]

                Only now I looked at the code you posted, and noticed there are not locals! I hope my post will help anyway

                ------------------

                [This message has been edited by Aldo Cavini (edited July 10, 2001).]
                Rgds, Aldo

                Comment


                • #9
                  Aldo, rather than making completely wild guesses as to the cause, can you please send the complete "offending" code to Tech Support so we can investigate it?

                  If we can't duplicate the problem for ourselves, we can't be 100% sure the problem will be fixed. For example, it is conceivable that there could be more than one problem that triggers an Error 402 incorrectly.

                  Thanks!


                  ------------------
                  Lance
                  PowerBASIC Support
                  mailto:[email protected][email protected]</A>
                  Lance
                  mailto:[email protected]

                  Comment


                  • #10
                    Ok, the problems mentioned here relate to just one issue in the compiler.

                    R&D are aware of it and it will be corrected in the next update to the compiler.

                    At this stage, I'm not able to point the finger at any specific part of the code that is causing the problem, but if I can find out, I'll post it here..

                    Thanks to Daniel and Aldo for their cooperation!

                    ------------------
                    Lance
                    PowerBASIC Support
                    mailto:[email protected][email protected]</A>
                    Lance
                    mailto:[email protected]

                    Comment

                    Working...
                    X