If this topic interests you (QB-like error handling), there are still some differences / bugs compared to QB7.1.
See:
http://www.freebasic.net/forum/viewtopi ... 09#p172909
#602 'On Local Error Goto ...' does not work as specified (+GCC)
2 Bugs I found
Re: 2 Bugs I found
In FB, the function version of OPEN returns directly the error code as an integer.
So compile with option '-ex' is not mandatory for the following:
So compile with option '-ex' is not mandatory for the following:
Code: Select all
REM FBCTest.bas
nErr = OPEN("crummy.txt" FOR INPUT AS #1)
IF nErr <> 0 Then
FOR eboxr = 13 TO 17
FOR eboxc = 15 TO 53
LOCATE eboxr, eboxc
COLOR 4: PRINT CHR$(219)
NEXT
NEXT
LOCATE 13, 16: COLOR 0, 4: PRINT STRING$(37, CHR$(196))
LOCATE 17, 16: COLOR 0, 4: PRINT STRING$(37, CHR$(196))
LOCATE 13, 15: PRINT CHR$(218): LOCATE 13, 53: PRINT CHR$(191)
LOCATE 17, 15: PRINT CHR$(192): LOCATE 17, 53: PRINT CHR$(217)
FOR evline = 14 TO 16
LOCATE evline, 15
PRINT CHR$(179)
LOCATE evline, 53
PRINT CHR$(179)
NEXT evline
LOCATE 15, 18: COLOR 13, 4: PRINT "Error"; nErr; " caught by error handler"
LOCATE 16, 18: COLOR 7, 4: PRINT "press any key to continue..."
SELECT CASE nErr
CASE 2
LOCATE 14, 25: COLOR 14, 4: PRINT "-File Not Found-"
END SELECT
DO: LOOP WHILE INKEY$ = ""
END IF
Re: 2 Bugs I found
Indeed QB-like error handling should only be used as a crutch to initially get QB code compiling and running in FB. FB is a different dialect than QB, and you'll have far more success using FB as FB. Besides that, the old-school "on error" handling doesn't fit very well with modern structured programming, object-oriented programming, etc. Especially when the error handler ends up jumping across stack boundaries and call scopes.
Re: 2 Bugs I found
The error handler still doesn't work in the large program I'm trying to get it to work in. I've followed exactly the example set forth in "Fbctest" above by FXM. However, I think my QB program is way to big... it's 2,376 lines of code just in the main module alone, if you add in all the SUBs, it's probably another 2,000 lines of code. And the file size is 194 Kb. Which is huge for QBasic.
QBasic 1.1 doesn't even run my program, it just says "Out of Memory." I've been using QB PDS 7.1 as my editor, but it's incapable of compiling an EXE without memory overflow errors. FreeBASIC is the only thing that can compile my program.
I think there must be a memory size limit that applies in regards to error handling.... at least for the Qb dialect, because it just ain't working.
Appreciate everyone's help though :-)
QBasic 1.1 doesn't even run my program, it just says "Out of Memory." I've been using QB PDS 7.1 as my editor, but it's incapable of compiling an EXE without memory overflow errors. FreeBASIC is the only thing that can compile my program.
I think there must be a memory size limit that applies in regards to error handling.... at least for the Qb dialect, because it just ain't working.
Appreciate everyone's help though :-)
Re: 2 Bugs I found
Aaronm82 wrote:The error handler still doesn't work in the large program I'm trying to get it to work in.
for QB but not FBI think my QB program is way to big
Which is very good.I've been using QB PDS 7.1
Same here.FreeBASIC is the only thing that can compile my program.
Never determined that.I think there must be a memory size limit that applies in regards to error handling
Many of my QB programs were in the 6000 lines of code size.it just ain't working.
PDS made it easier for the construction of modular code, BUT
PDS has many "features" that made it too easy to create less than
professional grade programs, but they WORK!
A big problem you will have to overcome:
In PDS you can easily jump across procedures and
GOTO specific lines in different routines.
I unrolled the jumps and had dozens of copies of the
same code in the different procedures to avoid
branching across other scoped variables.
The error handling problem was an annoying bee.
In converting from PDS to FB the use of this
helped more than initially expected:
#lang "QB"
Option Explicit
That helped eliminate the
DEF INT I-K in one module and
DEF DBL A-J in other modules.
I grouped the code into Macros, Functions & Subroutines and
limited the global variables to about a dozen.
Look at the "Error handling" explanations in FB help file.
In PDS I used the "ON LOCAL ERROR"
Re-arranging the code helped.
Once you the program will compile with #lang "QB" the next step is #lang "FB"
That may be of no exact help as I'm guessing what could cause
your error handling difficulties.
Without seeing the structure of your program, the methods/solutions that
worked for me, may not be applicable.
.
Re: 2 Bugs I found
I will research this "ON LOCAL ERROR" since I am not familiar with that.
When refering to my QuickBasic 4.0 Manuals, I don't see that particular command mentioned, however because QB 4.0 is rather old I may need to "upgrade" some of my error handling.
Thanks :-)
When refering to my QuickBasic 4.0 Manuals, I don't see that particular command mentioned, however because QB 4.0 is rather old I may need to "upgrade" some of my error handling.
Thanks :-)
Re: 2 Bugs I found
ON LOCAL ERROR appeared with QB7.1, but its use does not work as expected in FB:
fxm wrote:If this topic interests you (QB-like error handling), there are still some differences / bugs compared to QB7.1.
See:
http://www.freebasic.net/forum/viewtopi ... 09#p172909
#602 'On Local Error Goto ...' does not work as specified (+GCC)