home *** CD-ROM | disk | FTP | other *** search
- CONVERTING TURBO PASCAL DATA FILES FROM CP/M TO MS\PC-DOS
-
- by William Meacham 8/27/87
-
- This is for Turbo Pascal programmers who are moving from
- CP/M to DOS; I am one of them. One of the nifty things about
- Turbo Pascal is that it was so easy! My source code was almost
- completely transportable; I only had to change a couple of BDOS
- calls. (The transition the other way would not be so easy; you
- can do a lot of things on the IBM clones that you can't on a CP/M
- machine.) However, I had a bit more trouble transporting my data
- files. I could not just transfer the files to the DOS machine
- and use them.
-
- A CP/M Turbo Pascal data file (other than a text file)
- differs from its DOS equivalent in two important ways: (1) it is
- longer, and (2) it contains extra information. This means that
- you cannot simply read the CP/M file from a DOS program; you have
- to convert the file format.
-
- The CP/M file is longer than its DOS equivalent because it
- is rounded up to a 128-byte boundary. In CP/M the logical length
- of a file is different from its physical length. By "logical
- length" I mean the number of bytes in all the records in the file
- as defined in your Turbo Pascal program. By "physical length" I
- mean the file length recorded in the operating system directory.
- CP/M does not keep track of the logical length of a file. Every
- file is rounded up to the next 128-byte boundary (or 256 or 1K
- byte, depending on your BIOS). DOS, however, keeps the exact
- file length in its directory.
-
- The CP/M file contains four bytes at its beginning not found
- in the equivalent DOS file. These are two integers giving the
- number of records and the record length. They are used for the
- FileSize function, which works differently in CP/M from the way
- it works in DOS. The CP/M FileSize function reads the first four
- bytes of the file and computes its logical length. The DOS
- function finds out from the directory. It does not need the
- extra four bytes at the beginning, and the DOS data file does not
- contain them.
-
- This means you've got trouble when you transfer a CP/M file
- to DOS, whether by modem or direct serial transfer or by using
- a disk compatability program. If you recompile your source code
- and then run it against the CP/M data file you either bomb out or
- get erroneous results. Your Turbo program does not recognize the
- extra four bytes at the beginning of the file, so all your
- records are now four bytes off.
-
- I wrote the program CONVERTB.PAS to fix this problem. It
- will work on any CP/M data file that has been transferred to a
- DOS machine. What it does is read the first four bytes and
- compute the logical length of the file by multiplying the number
- of records times the record length. Then it reads that many
- bytes from the CP/M file and writes a new DOS file that many
- bytes long. When you are done, the DOS file's logical and
- physical length are the same.
-
- The program, in source and executable form, and some
- additional documentation are in the file CONVERTB.ARC on the
- Kaypro Club Bulletin Board, 258-8328. This is an MS-DOS Archive
- file, since the whole point of it is to run on MS-DOS computers.
- Those of you who have such, download and enjoy!
- µî«╙å2ì7ECM┐Ω8╔±!