DEF SEG + PEEK/POKE hack

Post your FreeBASIC tips and tricks here. Please don’t post your code without including an explanation.
Antoni
Posts: 1393
Joined: May 27, 2005 15:40
Location: Barcelona, Spain

Postby Antoni » Jan 06, 2008 12:06

Gfxlib had a problem many moons ago with using screenunlock too many times. I recall suggesting lillo using a counter to avoid problems, I guess my suggestion was of help...

And having -lang qb not complaining about DEF SEG would be great! People requiring this kind of feature don't give feedback, just try to compile a QB source and if there are too many errors they go back to network54 or PB forums and deprecate FB...
BasicJan
Posts: 46
Joined: Aug 30, 2005 20:09
Location: Netherlands

Request for VAR SEG at -qb

Postby BasicJan » Jan 18, 2008 12:41

I would like to be the first to ask for the VAR SEG-addition at the -qb version of FreeBasic.

I still have problems to compile my QBasic-programs without modifying the source.
Other unsolved un-compatibilities are:
= lachk of CURRENCY-type (DOUBLE is less accurate!).
= errortrap handling (FB: label with code should be inside the SUB or FUNCTION, QB: label with code should be outside the SUB or FUNCTION).
= system error codes returned in case of a file-handling-error.

But I am where enthousiastic about FreeBasic so far!!
Kot
Posts: 336
Joined: Dec 28, 2006 10:34

Re: Request for VAR SEG at -qb

Postby Kot » Jan 18, 2008 15:45

BasicJan wrote:<CUT!>
= system error codes returned in case of a file-handling-error.

Yeah, the errors because of that can be amazing.
KristopherWindsor
Posts: 2428
Joined: Jul 19, 2006 19:17
Location: Sunnyvale, CA
Contact:

Postby KristopherWindsor » Feb 22, 2008 1:48

Will this be added for -lang qb soon?
Why develop a solution and not add it? ;-)
notthecheatr
Posts: 1759
Joined: May 23, 2007 21:52
Location: Cut Bank, MT
Contact:

Re: Request for VAR SEG at -qb

Postby notthecheatr » Feb 22, 2008 18:37

BasicJan wrote:= system error codes returned in case of a file-handling-error.


Here's a simple solution - it ain't perfect, but if you replace all the occurrences of "ERR" in a QB program with "ERRQB" and include this then you should have less work to do converting.

Code: Select all

'Note:  Do not expect this to be perfect!  Make sure you understand that
'in some cases, QBasic defines a bunch of error codes where FB only
'defines one general code to take care of them all.  This is especially
'the case with File I/O.  In these cases I simply use the most general,
'most probable, and most relevant choice.

'Because the error codes simply aren't the same, you should know what
'is going on here and in some cases you may want to disable conversion
'of some of the codes simply because they're too iffy.

'This is not the be-all and end-all solution to QBasic error code
'compatibility.  Very likely you'll still have to go through your code and
'change a few things.  Hopefully this will make some things a bit easier,
'however.

Function errFBtoQB (fberrno As Integer) As Integer
  Select Case fberrno
  Case 0
    errFBtoQB = 0
  Case 1
    errFBtoQB = 5
  Case 2
    errFBtoQB = 53
  Case 3
    'In this case there is no precise match, but Device I/O error is probably the closest.
    errFBtoQB = 57
  Case 4
    errFBtoQB = 7
  Case 5
    'Another uncertain one, but RESUME without error seems closest.
    errFBtoQB = 20
  Case 6
    errFBtoQB = 9
  Case 7
    'QB doesn't have pointers, but there is an error for null indexes, so we'll use that one
    errFBtoQB = 87
  Case 8
    'Permission denied is close enough
    errFBtoQB = 70
  Case Else
    'Everything else returns -1 or Not 0
    errFBtoQB = -1
  End Select
End Function

Function errQB As Integer
  errQB = errFBtoQB(Err)
End Function

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 7 guests