2 Bugs I found

DOS specific questions.
fxm
Posts: 9695
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: 2 Bugs I found

Postby fxm » Oct 20, 2014 10:51

If this topic interests you (QB-like error handling), there are still some differences / bugs compared to QB7.1.
See:
viewtopic.php?p=172909#p172909
#602 'On Local Error Goto ...' does not work as specified (+GCC)
fxm
Posts: 9695
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: 2 Bugs I found

Postby fxm » Oct 20, 2014 12:59

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:

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

Re: 2 Bugs I found

Postby caseih » Oct 20, 2014 14:21

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

Re: 2 Bugs I found

Postby Aaronm82 » Oct 20, 2014 22:37

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 :-)
integer
Posts: 390
Joined: Feb 01, 2007 16:54
Location: usa

Re: 2 Bugs I found

Postby integer » Oct 21, 2014 13:40

Aaronm82 wrote:The error handler still doesn't work in the large program I'm trying to get it to work in.

I think my QB program is way to big
for QB but not FB

I've been using QB PDS 7.1
Which is very good.

FreeBASIC is the only thing that can compile my program.
Same here.

I think there must be a memory size limit that applies in regards to error handling
Never determined that.

it just ain't working.


Many of my QB programs were in the 6000 lines of code size.
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.

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

Re: 2 Bugs I found

Postby Aaronm82 » Oct 24, 2014 10:45

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

Re: 2 Bugs I found

Postby fxm » Oct 24, 2014 11:05

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:
viewtopic.php?p=172909#p172909
#602 'On Local Error Goto ...' does not work as specified (+GCC)

Return to “DOS”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 3 guests