Solved

Converting Borland Turbo Pascal to C ?

Posted on 1997-09-27
15
418 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
15 Comments
 

Expert Comment

by:igork
Comment Utility
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
Comment Utility
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
Comment Utility
Libraries are not limited to windows only.
0
 
LVL 1

Expert Comment

by:FuzzyLogic
Comment Utility
Libraries are not limited to windows only.
0
 
LVL 1

Expert Comment

by:FuzzyLogic
Comment Utility
Libraries are not limited to windows only.
0
 
LVL 1

Expert Comment

by:FuzzyLogic
Comment Utility
Libraries are not limited to windows only.
0
 
LVL 1

Expert Comment

by:FuzzyLogic
Comment Utility
Ignore the multiple comments...
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:mikie
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now