Solved

Converting Borland Turbo Pascal to C ?

Posted on 1997-09-27
15
442 Views
Last Modified: 2008-03-17
I'm interested in seeing if there is a utility (either shareware or commercial) that performs conversion of Borland Turbo Pascal to C.  The pascal program was written in the mid eighties.  Any input is greatly appreciated.  Thanks
0
Comment
Question by:mikie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
15 Comments
 

Expert Comment

by:igork
ID: 1215986
I faced this problem some years ago and found that the simplest and most useful way is to rewrite all code myself (here I should justify that it was my own Pascal programs). You have an additional chance to improve your program and/or find some bugs. It is simple enough, just as translation from one human language to another - certainly if you  well know both.

As for ready-to-use utilities, my opinion is that even you find one of those you never could be sure in the result. E.g. you found  routine and applied it: You obtained C sourse, but it isn't compiled neither works. How and when will you find errors?

I don't want to say that is impossible. It is possible as any translator - but as any translator it should be written and tested professionally.

Regards,
IgorK.  
0
 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1215988
There is another solution.
You can compile your pascal source into library (such as DLL) that can be read by BC++.

If you are interested, comment me and I'll explain more detailed.

Fuzzy
0
 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1215990
Libraries are not limited to windows only.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1215991
Libraries are not limited to windows only.
0
 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1215992
Libraries are not limited to windows only.
0
 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1215993
Libraries are not limited to windows only.
0
 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1215994
Ignore the multiple comments...
0
 

Author Comment

by:mikie
ID: 1215995
Thank you for the great comments!!  I am especially intrigued by FuzzyLogic's suggestion.  I will "toss it around" a bit to get a better feel for your suggestion ... I'm a "unix type" and I'm afraid that my PC knowledge needs an upgrade.  Hopefully I can ask you an intelligent question concerning your suggestion ...

The pascal program is *large* with multiple files and it runs on DOS.  I have the option to run it on any machine once it is converted to C.  If you need any other information, I'll of course be more than happy to supply it.  Thanks
0
 

Author Comment

by:mikie
ID: 1215996
One more comment to add:

The original Pascal code was not written by me ... I have never worked with Pascal   :(

The authors of the original code have vanished from the face of the earth.  The application of this program is for controlling instrumentation with GPIB and datalogging results.  It controls some pretty sophisticated test equipment.
0
 

Expert Comment

by:dbetz
ID: 1215997
The DLL idea is good, but if you are using DOS you can use OBJs.  Here is what I do, I write the ASM and the C.  Then another person writes some Pascal stuff and compiles it to OBJ, then we link my OBJs with his OBJs to get either a big library, another OBJ, or the final EXE.
0
 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1215998
If you want to translate your pascal program becuase it is easier then to run it on any machine, the library solution won't work, since the library is compiled for a specific machine (80x86 in my case). You will have to translate it by hand into C... much work to do.
If you going to run your unit on PC, my solution is good for you.
What dbetz say is true, and for the computer it is almost the same as using library. However, you can still write lib for DOS.

0
 
LVL 1

Expert Comment

by:qed070297
ID: 1215999
I faced this problem once.  I wrote a bunch of find and replace
macros that did nothing more than change common Pascal constructs
such as :=, begin, and so on to =, { and so on.  I then went in
afterwards and completed the conversions by hand.  You might try
the same thing.

Keep in mind that a perfect solution is about as hard to
implement as a regular Pascal compiler.
0
 

Author Comment

by:mikie
ID: 1216000
After much input and thought, the *right* way to solve this problem is to have the code rewritten from scratch.  I will be working alongside a pascal expert to convert the code to ANSI C.  The new program will then be installed on a Sparc 10.

Thank you all for taking the time to give your feedback concerning this matter!  All your comments were very valuable!
0
 
LVL 1

Accepted Solution

by:
dark_wader earned 100 total points
ID: 1216001
It's time to give you some answers ey?

-In C it's easy to redefine some syntax matter (not much)..
  (i've seen this one somewhere)

-It's easy to make a word processor that converts {-> begin etc.
 It works pascal->C but not the other way...
  I think there is this thingy somewhere in Inet universe...
--------------------------------------
- It depends upon you if you choose to create convertor(.pas is     too large ) or just rewrite it...
     
(hope u give me nice grade :)))
:))
:))

0
 

Expert Comment

by:AllenC
ID: 1216002
AFAIK, there's a program called "TPTC" to convert some Pascal code to C. I tried it, although you may have to change a few thing yourself, but it works and say you sometime.

Anyway, the best way to convert Pascal to C is to learn both language yourself.

http://tcp.home.ml.org/
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question