Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Converting Borland Turbo Pascal to C ?

Posted on 1997-09-27
15
Medium Priority
?
461 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Your business may be under attack from a silent enemy that is hard to detect. It works stealthily in the shadows to access and exploit your critical business information, sensitive confidential data and intellectual property, for commercial gain. T…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

926 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