2 Bugs I found
2 Bugs I found
When I compiled my QBasic programs using FreeBASIC (-lang qb switch), I found that my error handling subroutine didn't work as it should. Normally if I run my programs from QBasic I'd get a popup window, which I programmed, to appear telling me the ERR number and meaning of error, and then the user can return to the program by pressing any key. After compiling the program, my popup window that displays the ERR number doesn't even show up! The program doesn't crash, which is good, but I don't get to see what I programmed in my error handling routine. The ERR number, by the way, is 53 for "file not found."
Another issue I disovered is when I CHAIN to another program and then return to my program, when I exit to the DOS prompt the keyboard is all messed up. The letters are all uppercase despite caps lock beings off, and certain keys don't work, etc.
The only way I could reproduce this error was when I chained my program in Real-Mode DOS. When I used the command line to run my program in Windows ME it worked fine. It was only when I CHAINED in Real-Mode DOS (using CWSDPMI) that I experienced any problems.
So, these are my two big glitches with FreeBASIC:
(1) My error handling routine is completely ignored by FreeBasic, even though it's supposed to display a message box with the ERR number and an explanation. It works fine in QBasic though.
(2) When CHAINING in real-mode DOS (via CWSDPMI) I get a messed up keyboard which requires me to restart my computer.
I'm not sure if these are actual "errors" of if FB is not entirely compatible with QBasic statements. Or else it #2 could be a bug with CWSDPMI. Not sure. Any help would be appreciated though.
Another issue I disovered is when I CHAIN to another program and then return to my program, when I exit to the DOS prompt the keyboard is all messed up. The letters are all uppercase despite caps lock beings off, and certain keys don't work, etc.
The only way I could reproduce this error was when I chained my program in Real-Mode DOS. When I used the command line to run my program in Windows ME it worked fine. It was only when I CHAINED in Real-Mode DOS (using CWSDPMI) that I experienced any problems.
So, these are my two big glitches with FreeBASIC:
(1) My error handling routine is completely ignored by FreeBasic, even though it's supposed to display a message box with the ERR number and an explanation. It works fine in QBasic though.
(2) When CHAINING in real-mode DOS (via CWSDPMI) I get a messed up keyboard which requires me to restart my computer.
I'm not sure if these are actual "errors" of if FB is not entirely compatible with QBasic statements. Or else it #2 could be a bug with CWSDPMI. Not sure. Any help would be appreciated though.
Re: 2 Bugs I found
Do you compile with option '-ex'?
Re: 2 Bugs I found
No, didn't compile with option "-ex."
I should also mention, I meant QBasic PDS 7.1, rather than QBasic 1.1
I didn't know about the "Resume Support" option using "-ex".... I will now re-compile program to see if that solves problem. Thanks.
I should also mention, I meant QBasic PDS 7.1, rather than QBasic 1.1
I didn't know about the "Resume Support" option using "-ex".... I will now re-compile program to see if that solves problem. Thanks.
Re: 2 Bugs I found
Look at Error Handling in documentation.
Re: 2 Bugs I found
(1) My program runs 100% correct in QBasic PDS 7.1 (or QuickBasic Extended)
(2) My .bas file compiles with FreeBASIC, despite the fact my "On Error" subroutine seems to be partially ignored. The compiled program doesn't halt, or crash, it just does "Resume Next" without bothering with the 23 lines between my Line Lable (Ehandle:) and the Resume Next statement at bottom of my Handler subroutine. This is all in the main module.
(3) I have tried jiggering with it. Change it from just plain "Resume" to "Resume Line Label" and of course "Resume Next" but none of them made a difference, it still skipped over 23 lines of error handling code.
tried using switch "FBC -ex -lang qb myfile.bas" but no difference.
(2) My .bas file compiles with FreeBASIC, despite the fact my "On Error" subroutine seems to be partially ignored. The compiled program doesn't halt, or crash, it just does "Resume Next" without bothering with the 23 lines between my Line Lable (Ehandle:) and the Resume Next statement at bottom of my Handler subroutine. This is all in the main module.
(3) I have tried jiggering with it. Change it from just plain "Resume" to "Resume Line Label" and of course "Resume Next" but none of them made a difference, it still skipped over 23 lines of error handling code.
tried using switch "FBC -ex -lang qb myfile.bas" but no difference.
Last edited by Aaronm82 on Oct 20, 2014 0:01, edited 2 times in total.
Re: 2 Bugs I found
Here's part of my code which makes a popup window with an error message for "file not found." Works fine in QBX. After creating .exe with FBC it doesn't appear.
The On Error statement is at the top of my main module:
The On Error statement is at the top of my main module:
ON ERROR GOTO ehandle
....
ehandle:
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 "; ERR; "caught by error handler"
LOCATE 16, 18: COLOR 7, 4: PRINT "press any key to continue..."
SELECT CASE ERR
CASE 53
LOCATE 14, 25: COLOR 14, 4: PRINT "-File Not Found-"
END SELECT
DO: LOOP WHILE INKEY$ = ""
RESUME NEXT
Re: 2 Bugs I found
I created a tiny program called "FBCtest.bas" with the entire code posted below. It tests the error handler for file not found. And when the file isn't found, a popup window displays the message. This works correctly in QBasic 1.1, QBX, and QB 4.5
I compiled it into a stand-alone .EXE file with QuickBasic 4.5 which also worked. Test it yourself. The only problem is, it doesn't work in FBC.
I compiled it into a stand-alone .EXE file with QuickBasic 4.5 which also worked. Test it yourself. The only problem is, it doesn't work in FBC.
REM FBCTest.bas
ON ERROR GOTO ehandle
OPEN "crummy.txt" FOR INPUT AS #1
END
ehandle:
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 "; ERR; "caught by error handler"
LOCATE 16, 18: COLOR 7, 4: PRINT "press any key to continue..."
SELECT CASE ERR
CASE 53
LOCATE 14, 25: COLOR 14, 4: PRINT "-File Not Found-"
END SELECT
DO: LOOP WHILE INKEY$ = ""
RESUME NEXT
Re: 2 Bugs I found
I compiled your test program in your last post in both DOS and Linux using the "-ex -lang qb" command line and it appears to work fine. Don't see any bug. The program does what you describe it should: prints a red popup error box on both DOS and Linux.
Re: 2 Bugs I found
Yes, I confirm.
It well works on Windows (XP) with compiler option '-lang qb' and '-ex'.
(In that case of error handler, the instruction END is mandatory before the label 'ehandle:')
It well works on Windows (XP) with compiler option '-lang qb' and '-ex'.
(In that case of error handler, the instruction END is mandatory before the label 'ehandle:')
Re: 2 Bugs I found
I tried it again, and now it works! Thanks you guys.
I don't know why I couldn't get it to work before. The "-ex" switch makes the difference.
Good news is my red popup box appears!!
But now it says "Err 0", not "Err 53" for file not found.
Are the FreeBASIC error codes different than QBasic error codes?
By the way I'm using FBC version 0.90.1 for DOS.
I don't know why I couldn't get it to work before. The "-ex" switch makes the difference.
Good news is my red popup box appears!!
But now it says "Err 0", not "Err 53" for file not found.
Are the FreeBASIC error codes different than QBasic error codes?
By the way I'm using FBC version 0.90.1 for DOS.
Re: 2 Bugs I found
See the paragraph 'note' at KeyPgErr page:
The error code must be stored at the beginning of the error handler!
The runtime error codes are different in FreeBASIC:
TblRuntimeErrors
Your program so modified:
The error code must be stored at the beginning of the error handler!
The runtime error codes are different in FreeBASIC:
TblRuntimeErrors
Your program so modified:
Code: Select all
REM FBCTest.bas
ON ERROR GOTO ehandle
OPEN "crummy.txt" FOR INPUT AS #1
END
ehandle:
nErr = ERR
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$ = ""
RESUME NEXT
Re: 2 Bugs I found
I guess getting the ERR code isn't too big a deal... I just want my popup box to display, so at least I'll know if there was an error.
Thanks for suggesting the "-ex" switch. Every little bit helps my understanding.
Thanks for suggesting the "-ex" switch. Every little bit helps my understanding.
Re: 2 Bugs I found
Thanks FXM!! This works perfectly. You have solved my problem!! :-)
Appreciate all your guys help. I will definitely print out a copy of those FREEBASIC error codes!
Appreciate all your guys help. I will definitely print out a copy of those FREEBASIC error codes!
Code: Select all
REM FBCTest.bas
ON ERROR GOTO ehandle
OPEN "crummy.txt" FOR INPUT AS #1
END
ehandle:
nErr = ERR
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$ = ""
RESUME NEXT
Re: 2 Bugs I found
For encapsulate your code, use rather 'Code' button instead of 'Quote' button.
(as I did)
(as I did)
Re: 2 Bugs I found
Okay, thanks :-)