News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Tracking down Errors eg Missing Endif

Started by TimB, May 10, 2023, 08:03 PM

Previous topic - Next topic

TimB


The compiler is great. I love it! But missing "then" or endif really give it a hard time.

You get really random errors from a missing "then" So whe I get odd errors I know to look for them. However I'm stuck with an error saying an Endif is missing and pointing to a file that I do not touch. It is also half way through it and past many If endifs.

I checked over and over in the only routine I have been working on and cannot see a fault.

Any tips?

BTW this is the routine. I Know the error is in here as if I comment of the call to it every thing compiles ok

    Proc UpdateTempCalScnVal()


        Dim xOkToUpdate As Bit
        Dim cTempZMin as -5.0
        DIm cTempZMax as 5.0
        Dim cTempSMin as 100.0

        Dim cCalOutOfRnge As 0
        Dim cZeroAdjust As 1
        Dim cSpanAdjust As 2

            'RobotoMedium_14

        '----------T1 Adjust-----------------------------

        ' Work out if we are in range to update all

        bfOkToUpdat = cFalse

        If xT1_Fault = False Then                                               ' Check if there is no error with this channel

            ' Now check T1 for out of range

            bT1CalRange = cCalOutOfRnge
            If fPT100_T1 > cTempZMin Then
                If fPT100_T1 < cTempZMax Then
                    bT1CalRange = cZeroAdjust
                    bfOkToUpdate = cTrue
                EndIf
            EndIf

            If fPT100_T1 > cTempSMin Then
                bT1CalRange = cSpanAdjust
                xOkToUpdate = cTrue
            EndIf

            Print At 22,60, Dec2 fPT100_T1, "    "     ; Always update the real values

           ' Now check what to print for the range values

           If bfOkToUpdate = cTrue Then

                If xSettingsAdjustActive = cTrue Then

                    If bMenuSelectPoss = cCalibration_T1_Adjust Then
                        Print At 44,60, Dec2 fAdjustValue,
                    EndIf

                Else
                    Print At 44,60, Dec2 fPT100_T1,
                EndIf

            Else
                GLCD_Image(44, 60, 66, 2, CalTempError)
            EndIf



        Else  ' Yes there is an error so show the error message
            Print At 22,60, "-----",                                        ' Print the error message for the displayed message
            Print At 44,60, "-----",                                        ' Print the error message for the calibrate values
        EndIf

        GLCD_UpdateDisplay()                                                    ' Transfer the display RAM to the LCD

    EndProc

TimB


Ok as an update the error was nothing to do with Endif it was a comma at the end of a print statement (well actually 4 lines with commas but this was the offending line.

Print At 44,60, Dec2 fPT100_T1, <<<<<

normnet

#2
For future FineLineIDE with it's auto indent and brackets make it easy  to spot missing if's or endif's.

Stephen Moss

Quote from: TimB on May 10, 2023, 08:03 PMThe compiler is great. I love it! But missing "then" or endif really give it a hard time.
I don't know about FineLine but in Positron Studio if you have the code completion option selected when you type If it automatically inserts the Then and End If which make it harder for errors like that to creep into your code.
It also underlines in red some errors, like a missing Then or when an undeclared variable is used which would also help with that that type of problem.

TimB


I use Positron Studio and could see there was no endif missing.

It was a comma at the end of a print statement see post #2