Writing a 'Short' using QB mode

DOS specific questions.
Post Reply
muguk
Posts: 8
Joined: Jul 20, 2008 19:55
Location: Stockport (Cheshire), UK
Contact:

Writing a 'Short' using QB mode

Post by muguk »

I've been working on a simple shell piece of code to update my 22-year old DOS-game saved game hacks. The days of people knowing how to use Norton's Disk Editor is probably a lot slimmer these days compared to 1994 when I was writing these quick hacks. I never did send them in to PC Format, hence why I'm releasing them to work under DOSBox.

I can compile the code as a Windows Commandline .EXE without any problems, but when I try to do so as a QB command line, the compiler complains about my usage of the Short variable type. It seems that I can only use Integers in QB mode.

What's the solution to write two bytes (containing the current value of a team's money pot) into a binary file so that it's QB compliant? Or do I ignore it and use the Windows Command Line output? I'm only going to run the program under DOSBox as that's where the games run from too.
St_W
Posts: 1626
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Writing a 'Short' using QB mode

Post by St_W »

If you need "short" you can use it by using "__short" instead (prepend two underscores). see http://freebasic.net/wiki/wikka.php?wakka=KeyPgShort (section "Dialect Differences")

That naming scheme make many features of FreeBasic available in the old QB dialect.
muguk
Posts: 8
Joined: Jul 20, 2008 19:55
Location: Stockport (Cheshire), UK
Contact:

Re: Writing a 'Short' using QB mode

Post by muguk »

OK, many thanks. I will give that a try later on tonight.
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Writing a 'Short' using QB mode

Post by dkl »

In FreeBASIC's QB dialect (#lang "qb" or -lang qb), Integer is only 2 bytes, for QB-compatibility. So in that case it's the same as __Short.
muguk
Posts: 8
Joined: Jul 20, 2008 19:55
Location: Stockport (Cheshire), UK
Contact:

Re: Writing a 'Short' using QB mode

Post by muguk »

dkl wrote:In FreeBASIC's QB dialect (#lang "qb" or -lang qb), Integer is only 2 bytes, for QB-compatibility. So in that case it's the same as __Short.
Ah, so when I read in the data from a binary file, it will read in both bytes?

I'm still too used to using GFA BASIC on the Atari ST, which allowed me to read in bytes, words (aka shorts) and longs with ease.
St_W
Posts: 1626
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Writing a 'Short' using QB mode

Post by St_W »

muguk wrote:[...], which allowed me to read in bytes, words (aka shorts) and longs with ease.
I don't see why vou're considering it harder in FB: you can simple PUT bytes, shorts (= integer in lang qb) and longs and they will be stored accordingly (a byte as a byte, a short as a short and a long as a long).
see http://freebasic.net/wiki/wikka.php?wak ... gPutfileio
Post Reply