If error

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
CooperMan
If error

Post by CooperMan » Thu Nov 18, 2004 11:25 pm

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

Dr_Davenstein
QBasic God
Posts:166
Joined:Tue Mar 25, 2003 12:45 am
Location:U.S.A.
Contact:

Post by Dr_Davenstein » Fri Nov 19, 2004 1:36 am

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. ;)
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!

CooperMan

If Error

Post by CooperMan » Fri Nov 19, 2004 10:19 am

Thanks For your help I will attempt it..

Buff
Jr. Member
Posts:22
Joined:Wed May 19, 2004 3:07 pm
Contact:

Post by Buff » Sat Nov 20, 2004 12:51 am

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.

Mac

Here is an indentor program

Post by Mac » Sun Dec 19, 2004 5:12 pm

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.)

Ralph
QBasic God
Posts:134
Joined:Sat Nov 06, 2004 2:27 am
Location:Katy, Texas

Post by Ralph » Sun Dec 19, 2004 8:55 pm

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.
Ralph. Running QuickBASIC Version 4.5, Windows XP Home Edition, Version 2002, Service Pack 2, and HP LaserJet 4L printer.

Post Reply