Announcement

Collapse
No announcement yet.

A terrible error that the compiler does not find.

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

  • A terrible error that the compiler does not find.

    Do you find the error in this code snippet? You do not need to understand Swedish to find the fault. The compiler didn't find the error and I spent at least an hour finding it. It was frustrated when the code didn't work as it should. Now I will put a check in the program that pre-processes my code before it goes to the compiler.

    Maybe the error is known since earlier among more experienced PB developers?
    Code:
    .
    .
    .
    ' KOLUMN 1
    CONTROL ADD LABEL, HD, -1, "Ordernr", KOL( 2), RAD( 3), BREDD(12), HOJD(0.9)
    CONTROL ADD TEXTBOX, HD, %ORDERNR, "", KOL(15), RAD( 3), BREDD(10), HOJD(0.9), CALL ORDERNR_IN
    CALL SATT_FARG_OPPEN (HD, %ORDERNR)
    
    CONTROL ADD LABEL, HD, -1, "Posnr", KOL( 2), RAD( 4), BREDD(12), HOJD(0.9)
    CONTROL ADD TEXTBOX, HD, %POSNR, "", KOL(15), RAD( 4), BREDD(10), HOJD(0.9), CALL POSNR_IN
    CALL SATT_FARG_OPPEN (HD, %POSNR)
    
    CONTROL ADD LABEL, HD, -1, "Serienr 1", KOL( 2), RAD( 5), BREDD(12), HOJD(0.9)
    CONTROL ADD TEXTBOX, HD, %SERIENR-01, "", KOL(15), RAD( 5), BREDD(10), HOJD(0.9), CALL SERIENR_01_IN
    CALL SATT_FARG_OPPEN (HD, %SERIENR-01)
    
    CONTROL ADD LABEL, HD, -1, "Kvantitet", KOL( 2), RAD( 6), BREDD(12), HOJD(0.9)
    CONTROL ADD TEXTBOX, HD, %LEV_KVANT, ", KOL(15), RAD( 6), BREDD(10), HOJD(0.9), CALL LEV_KVANT_IN
    CALL SATT_FARG_OPPEN (HD, %LEV_KVANT)
    .
    .
    .
    Fim W.
    Fim Wästberg

  • #2
    Non-integer array index for height. (oops not an error if HOJD() is a function that returns an integer (LONG, DWORD, INT, etc ))

    Single $DQ in last textbox.

    **edited**
    Dale

    Comment


    • #3
      Labelhd
      "Not my circus, not my monkeys."

      Comment


      • #4
        Eric, the missing comma you found (to be missing) is more serious.

        Fim, two and counting.
        Dale

        Comment


        • #5
          I fixed an error that occurred when I copied the text CONTROL ADD LABELHD. It should say CONTROL ADD LABEL, HD.
          However, that error should be found by the compiler.
          /Fim W.
          Fim Wästberg

          Comment


          • #6
            %SERIENR-01 ?

            But Compiler finds fault with that..
            Rgds, Dave

            Comment


            • #7
              Dave thats right.
              But the compiler accept it.
              Correct is %SERIENR_01


              Is this a known bug?
              Fim Wästberg

              Comment


              • #8
                Correct is %SERIENR_01
                %SERIENR_01 must be defined though.

                If you have an Equate defined as %SERIENR the compiler will not know that %SERIENR-01 is invalid.
                <Otherwise you will get an Undefined Equate error>

                If HOJD() is an array, it is odd that you don't get an Out of Bounds error for HOJD(0.9)...
                Rgds, Dave

                Comment


                • #9
                  Do you have an constant in your program for %SERIENR (without the "_01")? If so then it did exactly what you asked it to do. Take the value of a constant and subtract 1 from it. Now if you don't have %SERIENR in your program then it should of flagged it as a Error 460, Undefined Equate.

                  Comment


                  • #10
                    Did you try compiling with #DEBUG ERROR ON ?

                    Comment


                    • #11
                      Hmm Seems that HOJD(0.9) looks like HOJD(1) as far as Bound testing is concerned.

                      #Debug Display On flags an error if Array is dimmed (2 To 9) but not if Dimmed (0 or 1 To 9)
                      Rgds, Dave

                      Comment


                      • #12
                        Börje,
                        Yes I have #DEBUG ERROR ON

                        and this
                        ENUM NR SINGULAR
                        DUMMY = 200
                        SERIENR_01
                        SERIENR_02
                        .
                        .


                        Fim Wästberg

                        Comment


                        • #13
                          Dave,
                          It is a function
                          Code:
                          FUNCTION HOJD(ANTAL_RADER AS SINGLE) AS LONG ' Måste ligga här, använder globala variabler
                          '=========================================
                          '
                          HOJD = ROUND(ANTAL_RADER * KOM.TECKEN_HOJD * KOM.BILD_PROCENT / 100, 0)
                          END FUNCTION
                          Fim Wästberg

                          Comment


                          • #14
                            Becomes a guessing game without compileable, failing code example. A nasty one that's hit me a couple of times is division with a variable that in some cases could end up being 0, so have learned to always check division variables, IF lVar THEN..
                            I like to use MSGBOX stops and/or rem out stuff to trace where faulty code may be.

                            Comment


                            • #15
                              > %SERIENR-01

                              > But the compiler accept it.
                              > Correct is %SERIENR_01


                              I can't get the compiler to accept %SERIENR-01 unless I have %SERIENR defined as a equate.
                              If it is defined, the compiler correctly subtracts one from it.



                              Comment

                              Working...
                              X