Page 1 of 1
If error
Posted: Thu Nov 18, 2004 11:25 pm
by CooperMan
Having just written a database for work I have encountered a problem when I try to make the file a stand alone .exe file...I keep getting a severe error telling me " Block If without End If "....How can I locate the area of the program that contains the error..I am running Win XP Pro
Posted: Fri Nov 19, 2004 1:36 am
by Dr_Davenstein
You can use ON ERROR...GOSUB to create a custom error trapping routine, but if you're mising an END IF... Well, the program will probably not work correctly. There are some utilities around that can help you find the problem. Goto
http://qbtk.com/main.php and click on the QBasic Code Indenter(small link at the top). Copy all of your code, paste it into the window and click submit. Search the output text for missing statement blocks. It will take some searching if it's a long program, but you will find the error if you look.
Another option is to create a custom error handler routine. It's not very reliable though becasue it stops at the line number, or line label directly before the error. If the nearest line label was 50 lines back... Well, you see my point? Also, if you look up "ON ERROR" in QB help, it provides a complete explanation. and an example.
Good luck.
If Error
Posted: Fri Nov 19, 2004 10:19 am
by CooperMan
Thanks For your help I will attempt it..
Posted: Sat Nov 20, 2004 12:51 am
by Buff
If you run it in the ide then if it truly is an if block error it should show you
where it's having a problem.
Indent all your block IF's, FOR's,WHILE/DO, etc. so you can see where
the routine ends and where you are missing something.
It could possibly have to do with a line that is too long in the source code.
Try to keep lines shorter than 100 characters if possible.
Here is an indentor program
Posted: Sun Dec 19, 2004 5:12 pm
by Mac
http://www.network54.com/Forum/message? ... 1100378316
It might find your problem.
But as someone said, if you can run in the IDE without immediately bombing out, then the problem is something like a stupid compiler bug.
In that case, I would try compiling half the program to see which half has the problem. If both halves compile ok, then it's REALLY going to be hard. Lots of Luck.
Mac
(Post on The QBasic Forum if you have further questions to me, I was just here looking for rel - someone trying to contact him there, but he rarely comes there.)
Posted: Sun Dec 19, 2004 8:55 pm
by Ralph
One more thing to be looking out for! I have found that, sometimes, I may have an incomplete loop nested inside a compete one, and the debugger points to the complete one! It takes a while to find problems of this nature. But, the best advice is that given previously: Make absolutely sure you indent ALL loops, DO, FOR. IF, WHILE, and I recommend you put a blank line at the begginning and at the end, also. This is a very good way of finding those pesky incomplete loops!
Let us know how you solved your problem! Or, copy your full code here, and somebody is sure to help you.