Sometimes I have a missing "endif" or "endwhile" statement.
This may not be flagged until the end of program and it can be very hard to figure out where the problem is.
Is there an option to flag the error as soon as it's detected, like at the end of a Subroutine?
The if and while statements don't extend past an EndSub statement.
If there is a counter keeping track of open if statements, it should be back to zero when the EndSub statement is encountered.
Thanks.
-- Robert
Hi Robert,
Only the IF stack is checked at ENDSUB - it must be empty (currently).
I'll add more checks for the other x-endx blocks.
Check your sources if you used "else if" instead elseif.
Else If opens a new, child IF block, and does not close the current IF block.
This one
if(A)
else(A)
if(B)
endif(B)
endif(A)
is the same as
if(A)
else(A) if(B)
endif(B)
endif(A) ' additional close is required
But when using ELSEIF:
if
elseif
endif
Done, the new checks are added, and waiting for Larry to compile.
They will check for while, do, if, type, interface, class, for, select, try, catch, with, else.
Thanks very much, Sapero.
In version 1.73 of EBasic, the mismatched if-endif pairs appear to not be flagged until the end of the program. Several times I've had to do a binary search by patching in an extra endif to find the routine where the problem is.
It looks like it's time for me to upgrade :)
-- Robert
Old programmers (like me) usually just indent the code. Makes it easier to follow and document.
dir = FINDOPEN(Npath)
IF (dir)
DO
Cpath = FINDNEXT(dir,attrib)
IF Cpath <> ""
IF (attrib & @file_directory)
Opath = ""
ELSE
scntr++
Opath = "Pic_" + USING("0###",scntr) + ".jpg"
IF RENAME(Path + Cpath, Path + Opath)
PRINT Cpath, " Renamed to ", Opath
ELSE
PRINT Cpath, " NOT Renamed to ", Opath
ENDIF
ENDIF
ENDIF
UNTIL Cpath = ""
FINDCLOSE dir
ENDIF
Etc....
Bill
I'm with you, Bill, on the indenting.
I can't read/write code without indenting.
LarryMc
Hi,
As Larry knows, I hate the indenting! Seems like I set out my own style
of writing years ago, and anything else looks like a foreign language to me!
What you get used to, I guess
Brian
I dont care to much for indenting and i know for this error matching problem but i dont use this to serius.
I feel like Bill and Larry. I've programmed for over 30 years (I started young :)), it makes for much more readable code. I've been working on someones code that was not "properly indented" and it is a complete headache to follow his program flow logic.
Clint
The only thing worse than code without indenting is code with lots of GOTO's. (Bad style).
Bill
Quoteit makes for much more readable code
That's my opinion as well.