News:

;) This forum is the property of Proton software developers

Main Menu

If without corresponding endif error

Started by rick.curl, Aug 01, 2021, 04:18 PM

Previous topic - Next topic

rick.curl

I'm revisiting some code I wrote back in 2013 so I can add a couple of items to a menu.  The code has always compiled fine, but when I added a menu routine near the top of my code, a subroutine several thousand lines away started throwing "If without corresponding endif" errors. As a test, if I rem out the offending line the same error now reappears on the next line.
Here's the routine that's giving trouble:
VoltReg:
        rt_a2d = rt_a2d /Div
        If rt_a2d < (set_dig - .1) And PWMVAL < 1023 Then Inc PWMVAL
        If rt_a2d > (set_dig + .2) And PWMVAL > 0 Then Dec PWMVAL
        If rt_a2d >= set_dig And lower = 0 Then timestart = 1
Set_Dig and RT_A2D are dim'ed as floats, PWMVAL is a word, and TimeStart is a bit.

I tried removing the code that I had just added at the top of the file, but the compile error remains- so I must have fat-fingered something somewhere. This compiled OK yesterday on the same version of the compiler.

Can anyone suggest a way to resolve this?  BTW- the PIC is an 18F4620.  I would post the entire code, but it's 1500 lines.

Thanks for any help on this!

-Rick

normnet

Take a look at FineLineIDE as it brackets and auto indents the If>EndIfs.  The first post has the latest version for download.


 

trastikata

Quote from: rick.curl on Aug 01, 2021, 04:18 PMCan anyone suggest a way to resolve this?  BTW- the PIC is an 18F4620.  I would post the entire code, but it's 1500 lines.

Sometimes the If-Then error message is not related to the comparison itself but to a miscellaneous error in the syntax. Thus don't look for If-Then problems, but something else. Look here, it was similar issue:

https://protoncompiler.com/index.php/topic,358.msg2220.html#msg2220

P.s. The code you posted, compiles with no trouble as it shlould.

rick.curl

Thanks guys-
Norm- FineLine spotted my error right away. Sorry I didn't think to be using that to start with.

All good now!

-Rick

TimB


Just to add that a missing "then" can really screw up a program with errors all over the place.

I learned to ignore the other messages and just hunt down the missing "Then"

keytapper

I rather rely on a good text editor that can spot on the conditional folding. So if I fold a conditional statement I'll see where it ends.
Using Notepad++ I still not able to make the rules doing right. But with Kate I'm rather certain that is working.
Ignorance comes with a cost

TimB


A method I now use is to write the then or EndProc etc just as I write the If etc

If this = that

Endif

This way I have avoided issues for months