2 Bugs I found

DOS specific questions.
Aaronm82
Posts: 25
Joined: Sep 19, 2014 23:29

2 Bugs I found

Postby Aaronm82 » Oct 19, 2014 21:16

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.
fxm
Posts: 9620
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: 2 Bugs I found

Postby fxm » Oct 19, 2014 21:34

Do you compile with option '-ex'?
Aaronm82
Posts: 25
Joined: Sep 19, 2014 23:29

Re: 2 Bugs I found

Postby Aaronm82 » Oct 19, 2014 21:45

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.
fxm
Posts: 9620
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: 2 Bugs I found

Postby fxm » Oct 19, 2014 21:53

Look at Error Handling in documentation.
Aaronm82
Posts: 25
Joined: Sep 19, 2014 23:29

Re: 2 Bugs I found

Postby Aaronm82 » Oct 19, 2014 23:46

(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.
Last edited by Aaronm82 on Oct 20, 2014 0:01, edited 2 times in total.
Aaronm82
Posts: 25
Joined: Sep 19, 2014 23:29

Re: 2 Bugs I found

Postby Aaronm82 » Oct 19, 2014 23:52

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:

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
Aaronm82
Posts: 25
Joined: Sep 19, 2014 23:29

Re: 2 Bugs I found

Postby Aaronm82 » Oct 20, 2014 0:11

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.

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
caseih
Posts: 1503
Joined: Feb 26, 2007 5:32

Re: 2 Bugs I found

Postby caseih » Oct 20, 2014 5:13

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.
fxm
Posts: 9620
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: 2 Bugs I found

Postby fxm » Oct 20, 2014 7:15

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:')
Aaronm82
Posts: 25
Joined: Sep 19, 2014 23:29

Re: 2 Bugs I found

Postby Aaronm82 » Oct 20, 2014 8:56

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.
fxm
Posts: 9620
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: 2 Bugs I found

Postby fxm » Oct 20, 2014 9:15

See the paragraph 'note' at /wiki/KeyPgErr page:
The error code must be stored at the beginning of the error handler!

The runtime error codes are different in FreeBASIC:
/wiki/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
Aaronm82
Posts: 25
Joined: Sep 19, 2014 23:29

Re: 2 Bugs I found

Postby Aaronm82 » Oct 20, 2014 9:17

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.
Aaronm82
Posts: 25
Joined: Sep 19, 2014 23:29

Re: 2 Bugs I found

Postby Aaronm82 » Oct 20, 2014 9:20

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!

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
     
fxm
Posts: 9620
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: 2 Bugs I found

Postby fxm » Oct 20, 2014 9:26

For encapsulate your code, use rather 'Code' button instead of 'Quote' button.
(as I did)
Aaronm82
Posts: 25
Joined: Sep 19, 2014 23:29

Re: 2 Bugs I found

Postby Aaronm82 » Oct 20, 2014 9:29

Okay, thanks :-)

Return to “DOS”

Who is online

Users browsing this forum: No registered users and 1 guest