Hello Everyone,
I need to be able to read and write to a binary cross reference that was created in QB4.5. The UDT consist of fixed length strings, intregers and singles.
Thanks,
BernyD
an old nooby
Reading a binary random search file created in QB4.5
Your old QB program should "almost" work with the addition of #lang "qb" at the start , if it was'nt for an old design flaw in FB .
The fixed lenght strings in UDT's loose their last char, as FB stubbornly uses it as an end of string marker and erases it .
So the only way to read correctly packed UDT's from a file is to change the string*x declarations to ubyte arrays and use special routines to copy the bytes to and from external fixed length string buffers before processing. Fixed length strings outside UDT's are working correctly.
The fixed lenght strings in UDT's loose their last char, as FB stubbornly uses it as an end of string marker and erases it .
So the only way to read correctly packed UDT's from a file is to change the string*x declarations to ubyte arrays and use special routines to copy the bytes to and from external fixed length string buffers before processing. Fixed length strings outside UDT's are working correctly.
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
-
- Posts: 1188
- Joined: May 08, 2006 21:58
- Location: Crewe, England
If reading QB-type fixed strings, change your UDT to ztrings of the same length, and use left(s,len(s)) to access the whole string.
To write back to a fixed string to be read by QB, format the content in a longer zstring, concatenating space(len(s)) to pad out with spaces, then use the memcpy function from the CRT library to move to target. See C Standard Library in the help files.
To write back to a fixed string to be read by QB, format the content in a longer zstring, concatenating space(len(s)) to pad out with spaces, then use the memcpy function from the CRT library to move to target. See C Standard Library in the help files.
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
IIRC, that method will read in the following memory up to the first null byte - if there is one.jevans4949 wrote:If reading QB-type fixed strings, change your UDT to ztrings of the same length, and use left(s,len(s)) to access the whole string.
Unfortunately there isn't a good way of doing it at the moment, and the safest pure-FB method is probably to use byte arrays and For-loops for conversion.
Thank you all for your replies.
As I read your replies I realized that the question I asked was not exactly what I meant.
The cross referance file will not need to be read by a QB program anymoreas it will be have to be abandended altogether. Actually finding FB is quite lucky (I wish it had happened years ago).
The programs I run have outgrown the IDE to the point that adding code or data cause it to crash.
Just before the holidays MIS upgraded my pc to a workstation and no one is old enough to remember how to install an extended DOS window on XP.
So, my goal is to move completely to FB. I have a text version of the crossref. Could it be read into FB loaded, parsed and output to a FB binary style file?
Alternately this information also exists in a MS Access 2003 database.
Thanks
BernyD
As I read your replies I realized that the question I asked was not exactly what I meant.
The cross referance file will not need to be read by a QB program anymoreas it will be have to be abandended altogether. Actually finding FB is quite lucky (I wish it had happened years ago).
The programs I run have outgrown the IDE to the point that adding code or data cause it to crash.
Just before the holidays MIS upgraded my pc to a workstation and no one is old enough to remember how to install an extended DOS window on XP.
So, my goal is to move completely to FB. I have a text version of the crossref. Could it be read into FB loaded, parsed and output to a FB binary style file?
Alternately this information also exists in a MS Access 2003 database.
Thanks
BernyD
-
- Posts: 1188
- Joined: May 08, 2006 21:58
- Location: Crewe, England
The answer is, basically, yes. All those data formats are available in FB. Note that
(1) fixed STRINGS are basically stored in in similar manner to ZSTRINGs, as discussed,
(2) the default INTEGER is 32-bit; for 16-bit use SHORT;
(3) Floating-point numbers are IEEE format; the original GW-Basic format is not supported.
(1) fixed STRINGS are basically stored in in similar manner to ZSTRINGs, as discussed,
(2) the default INTEGER is 32-bit; for 16-bit use SHORT;
(3) Floating-point numbers are IEEE format; the original GW-Basic format is not supported.