Solved

Converting Borland Turbo Pascal to C ?

Posted on 1997-09-27
15
426 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

19 Experts available now in Live!

Get 1:1 Help Now