Board index » delphi » Pascal equivalent of 2 QBasic-functions.

Pascal equivalent of 2 QBasic-functions.

Hello,

I am using an application, written in TP, that uses data-files
in some compressed-binary format. I don't have the sourcecode.
The records in the data-files are 28 bytes long (7 x 4).
At the moment I can write and read numbers in the files using the
Qbasic-functions MKSMBF$ and CVSMBF as mentioned in the following code.
The records written to the file "test.dat" are fully compatible
with the application. So, what's the problem?
Well, for a longer time I have been looking for Pascal-functions that
will do these routines, so I can integrate them in my own Pascal-program
and don't need Qbasic anymore. I surely am not an expert on binary etc,
so your help will be appreciated indeed.

Thanks!
Bert Tingen.

CLS
TYPE inform
  datum AS STRING * 4
    opn AS STRING * 4
   hoog AS STRING * 4
   laag AS STRING * 4
   slot AS STRING * 4
  omzet AS STRING * 4
  inter AS STRING * 4
END TYPE
DIM tbireco AS inform

OPEN "test.dat" FOR RANDOM AS #1 LEN = 28
renum% = LOF(1) / 28

dat = 940103: frst = 215.25: high = 219.75: low = 214.5
krs = 217.55: omz = 555666: intop = 0

tbireco.datum = MKSMBF$(dat)
  tbireco.opn = MKSMBF$(frst)
 tbireco.hoog = MKSMBF$(high)
 tbireco.laag = MKSMBF$(low)
 tbireco.slot = MKSMBF$(krs)
tbireco.omzet = MKSMBF$(omz)
tbireco.inter = MKSMBF$(intop)

PUT #1, renum% + 1, tbireco

FOR i% = 1 TO renum% + 1

GET #1, i%, tbireco

PRINT CVSMBF(tbireco.datum);
PRINT USING "######.##"; CVSMBF(tbireco.opn);
PRINT USING "######.##"; CVSMBF(tbireco.hoog);
PRINT USING "######.##"; CVSMBF(tbireco.laag);
PRINT USING "######.##"; CVSMBF(tbireco.slot);
PRINT USING "#########"; CVSMBF(tbireco.omzet);
PRINT USING "####"; CVSMBF(tbireco.inter)

NEXT i%
CLOSE #1
END

 

Re:Pascal equivalent of 2 QBasic-functions.


Quote
tinge...@worldaccess.nl wrote:

> Hello,

> I am using an application, written in TP, that uses data-files
> in some compressed-binary format. I don't have the sourcecode.
> The records in the data-files are 28 bytes long (7 x 4).
> At the moment I can write and read numbers in the files using the
> Qbasic-functions MKSMBF$ and CVSMBF as mentioned in the following >
> code.

> The records written to the file "test.dat" are fully compatible
> with the application. So, what's the problem?
> Well, for a longer time I have been looking for Pascal-functions that
> will do these routines, so I can integrate them in my own
> Pascal-program and don't need Qbasic anymore. I surely am not an
> expert on binary etc, so your help will be appreciated indeed.

> Thanks!
> Bert Tingen.

> CLS
> TYPE inform
>   datum AS STRING * 4
>     opn AS STRING * 4
>    hoog AS STRING * 4
>    laag AS STRING * 4
>    slot AS STRING * 4
>   omzet AS STRING * 4
>   inter AS STRING * 4
> END TYPE
> DIM tbireco AS inform

> OPEN "test.dat" FOR RANDOM AS #1 LEN = 28
> renum% = LOF(1) / 28

> dat = 940103: frst = 215.25: high = 219.75: low = 214.5
> krs = 217.55: omz = 555666: intop = 0

> tbireco.datum = MKSMBF$(dat)
>   tbireco.opn = MKSMBF$(frst)
>  tbireco.hoog = MKSMBF$(high)
>  tbireco.laag = MKSMBF$(low)
>  tbireco.slot = MKSMBF$(krs)
> tbireco.omzet = MKSMBF$(omz)
> tbireco.inter = MKSMBF$(intop)

> PUT #1, renum% + 1, tbireco

> FOR i% = 1 TO renum% + 1

> GET #1, i%, tbireco

> PRINT CVSMBF(tbireco.datum);
> PRINT USING "######.##"; CVSMBF(tbireco.opn);
> PRINT USING "######.##"; CVSMBF(tbireco.hoog);
> PRINT USING "######.##"; CVSMBF(tbireco.laag);
> PRINT USING "######.##"; CVSMBF(tbireco.slot);
> PRINT USING "#########"; CVSMBF(tbireco.omzet);
> PRINT USING "####"; CVSMBF(tbireco.inter)

> NEXT i%
> CLOSE #1
> END

Well, Turbo Pascal does not support Microsoft format floating
point values, so your TP program must be using some conversion
routines (corresponding to QBasic CVSMBF).  Perhaps you could
find such routines at some FTP site like Garbo?

If I understand correctly, you want to write a TP program
with a better user interface for updating the file, while
keeping the original TP program for *using* the file.
You could do this by letting your new TP program generate
the file in IEEE format, and then running a QBasic
IEEE -> Microsoft conversion program automatically.

- Alf

Re:Pascal equivalent of 2 QBasic-functions.


Quote
tinge...@worldaccess.nl wrote:

>Hello,

>I am using an application, written in TP, that uses data-files
>in some compressed-binary format. I don't have the sourcecode.
>The records in the data-files are 28 bytes long (7 x 4).
>At the moment I can write and read numbers in the files using the
>Qbasic-functions MKSMBF$ and CVSMBF as mentioned in the following code.
>The records written to the file "test.dat" are fully compatible
>with the application. So, what's the problem?
>Well, for a longer time I have been looking for Pascal-functions that
>will do these routines, so I can integrate them in my own Pascal-program
>and don't need Qbasic anymore. I surely am not an expert on binary etc,
>so your help will be appreciated indeed.

The Pascal equivalent of
        1) MKS... is Str()
        2) CVS... is Val()

...MBF stand for single precision real type.
---
Roger Gariepy                            Be :-) even if you feel :-(
email: rgari...@rocler.qc.ca
Je parle Francais.

Other Threads