XXXX@XXXXX.COM wrote:
Quote
I got hold of a friend's game written in Turbo Pascal 7. Am trying to
convert it to C using:
www.garret.ru/~knizhnik/pascal.html
I am a C/C++ programmer and know nothing about Pascal. I got hold of
Turbo Pascal 7 for DOS. When I try to use the Pascal to C convertor I
keep on getting "can't include file dos.pas & crt.pas". I assume these
are standard Turbo Pascal library files? But searching in my Turbo
Pascal folders there are no such files. Closest is windos.pas??
Please can someone help. If you want, I can link in the source code to
the game.
For a start both Pascal & C are very closely related they are both
Wirthian languages. If you understand C pascal should be easy because
it is typed in a fuller way - it's like C without the shorthand.
In C you have the block structure {
}
In Pascal you have begin
end;
There are some important differences:
There are slight differences is variable types and how they are
declared and the order parameters are pushed and popped from a call
frame stack.
In C you have include libraries eg stdio.h. In pascal this is achieved
with units. These are separately compiled routines. The difference
between this and a C library is that units often only contain the
public headings for procedures and functions - the source can be
hidden. The Dos unit handles things like file I/O and calling dos
functions whereas Crt handles keyboard and basic text screen stuff . If
you look at the source directory of TP you will see Dos.inc & Crt.inc -
these are listings of the public part of the units which will at least
make clear what they are trying to do. Because they were written by
Borland the source is hidden unless you have BP and then as stated by
others it may not be useful. The actual compiled units end in .tpu or
.tpp (if protected mode) but you can't disassemble them. Obviously it
is not possible for a cross translator to show routines where the
source is hidden. By examining the .inc files you should be able to
chooses equivalent C commands.from your own include libraries.
I had a similar problem as you but in reverse - there is a lot of good
C code around and I wanted to writre pascal equivalents. With just a
little study and a crib sheet of symbols I can now rewrite most C
routines to Pascal. :)