Board index » off-topic » HELP: beginner to pascal

HELP: beginner to pascal


2006-08-25 07:27:26 PM
off-topic1
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.
 
 

Re:HELP: beginner to pascal

Hoi
You need to repost your message on the Borland news server to make
everybody see it and possibly answer your message.
How to post to Delphi newsgroups:
<delphi.wikia.com/wiki/Delphi_Newsgroups>
 

Re:HELP: beginner to pascal

Am new to Pascal and trying to compile an old Pascal DOS game. I tried many
compilers but keep on getting errors.
Can someone help me compile an old Pascal DOS game. I can upload to
somewhere if anyone is interested.
 

{smallsort}

Re:HELP: beginner to pascal

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. :)
 

Re:HELP: beginner to pascal

"HubbleBubble" < XXXX@XXXXX.COM >wrote in message
Quote
For a start both Pascal & C are very closely related they are both
Wirthian languages.
Nicolaus Wirth would be turning in his grave (if he wern't still alive), if
he heard you saying that C is Wirthian language!
Quote
If you understand C pascal should be easy [...]
True. Two other important differences are:
1). Pascal is strongly typed, like C++. This means that you can't generally
~implicitely~ cast apples into oranges. To do this you must ~explicitely~
tell the compiler that the cast is ok. E.g: P := Pointer(X);
2) There is a Boolean type explicitly defined in Pascal. This also ties in
to (1) in that you cannot implicitely cast an integer into a boolean like
you can in C. That means for example that all conditional branches ~must~
take an explicit boolean expression. Where in C you might have something
like:
int v;
{
.....
if (v)
{
....
}
}
This is not allowed in Pascal because "v" is not a boolean variable or a
boolean expression. Instead you need to explicitely generate a boolean
expression:
var v;
begin
.....
if v <>0 then
begin
......
end;
end;
Note that the parenthesis are ~not~ required in the Pascal version.
One other mistake that many Pascal programmers make is to explicitely test
for True in pascal conditionals:
if SomeBoolValueOrExpression = True then
....
This is bad because it compares SomeBoolValueOrExpression to the exact
ordinal value of 1, which you should never do because although Ord(True) =
1, Pascal will treat any non-zero value as True (ie not False). So the
correct code for the above is simply:
if SomeBoolValueOrExpression then
....
or if you want its converse:
if not SomeBoolValueOrExpression then
....
--
Jason Burgon. Author of Graphic Vision
homepage.ntlworld.com/gvision
 

Re:HELP: beginner to pascal

"Jason Burgon" < XXXX@XXXXX.COM >wrote in message
[...]
Quote
var v;
begin
.....
if v <>0 then
begin
......
end;
end;
Oops, I missed off declaring 'v's type. I should have written:
var v: Integer;
begin
.....
if v <>0 then
begin
......
end;
end;
--
Jason Burgon. Author of Graphic Vision
homepage.ntlworld.com/gvision
 

Re:HELP: beginner to pascal

Dhruba Bandopadhyay schrieb:
Quote
Am new to Pascal and trying to compile an old Pascal DOS game. I tried many
compilers but keep on getting errors.
Can someone help me compile an old Pascal DOS game. I can upload to
somewhere if anyone is interested.


Provide some more information:
- which compiler did you try?
- what is the beginning of the program? especially what is
in the uses clause?
- what errors are given by the compilers
Greetings
Markus
 

Re:HELP: beginner to pascal

Dhruba Bandopadhyay wrote:
Quote
Am new to Pascal and trying to compile an old Pascal DOS game. I
tried many compilers but keep on getting errors.
Can someone help me compile an old Pascal DOS game. I can upload to
somewhere if anyone is interested.
What compiler are you using TP7/BP7?
Is it a compiler error or is it a run-time error 200 you get?
You need to explain some more about what is going wrong, if you want
people to help you.
 

Re:HELP: beginner to pascal

On Tue, 29 Aug 2006 12:47:25 +0100, "Dhruba Bandopadhyay"
< XXXX@XXXXX.COM >wrote:
Quote
Am new to Pascal and trying to compile an old Pascal DOS game. I tried many
compilers but keep on getting errors.
Can someone help me compile an old Pascal DOS game. I can upload to
somewhere if anyone is interested.
What errors are you getting?
 

Re:HELP: beginner to pascal

Okay, here is the full source code.
members.lycos.co.uk/doom2d/downloads/LITE_SRC.ZIP
See if you can get it to compile and run. It was originally built in
TP7. I think I need to run TP7 in VirtualPC/VMWare to be in real-DOS
mode. I tried using FreePascal, but that's 32-bit and don't think it
worked.
If there are anyone who knows assembly and can convert the assembly to
equivalent C/Pascal then that would be excellent!
 

Re:HELP: beginner to pascal

Compiling this under native DOS TP7 I get:
Error 116: Must be in 8087 mode to compile this.
XXXX@XXXXX.COM wrote:
Quote
Okay, here is the full source code.

members.lycos.co.uk/doom2d/downloads/LITE_SRC.ZIP

See if you can get it to compile and run. It was originally built in
TP7. I think I need to run TP7 in VirtualPC/VMWare to be in real-DOS
mode. I tried using FreePascal, but that's 32-bit and don't think it
worked.

If there are anyone who knows assembly and can convert the assembly to
equivalent C/Pascal then that would be excellent!
 

Re:HELP: beginner to pascal

TP7 source code with embedded assembly:
members.lycos.co.uk/dhrubabandopadhyay/LITE_SRC.ZIP
Please see if you can get it to compile.
 

Re:HELP: beginner to pascal

In article < XXXX@XXXXX.COM >,
" XXXX@XXXXX.COM " < XXXX@XXXXX.COM >
wrote:
Quote
Compiling this under native DOS TP7 I get:

Error 116: Must be in 8087 mode to compile this.
Then turn on 8087/80287 mode in the compiler options.
Jonas
 

Re:HELP: beginner to pascal

Turbo Pascal 7, 16-bit.
members.lycos.co.uk/dhrubabandopadhyay/LITE_SRC.ZIP
"Loren Pechtel" < XXXX@XXXXX.COM >wrote in message
Quote
On Tue, 29 Aug 2006 12:47:25 +0100, "Dhruba Bandopadhyay"
< XXXX@XXXXX.COM >wrote:

>Am new to Pascal and trying to compile an old Pascal DOS game. I tried
>many
>compilers but keep on getting errors.
>Can someone help me compile an old Pascal DOS game. I can upload to
>somewhere if anyone is interested.

What errors are you getting?
 

Re:HELP: beginner to pascal

members.lycos.co.uk/dhrubabandopadhyay/LITE_SRC.ZIP
Excellent! It fully compiles and runs.
ml /c liteasm.asm
tpc /b lite2 /$N+
Though it looks frozen when the game starts. Am not sure whether that's a
game logic thing, or whether the liteasm.asm file was compiled with masm
32-bit.