Solved

Converting Borland Turbo Pascal to C ?

Posted on 1997-09-27
15
431 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Thead Pool or (only run last procedure called) 13 806
TEdit.SetFocus trouble 3 172
SHBrowseForFolder - Preselecting a folder 5 271
Wininet read php file from internet issue 6 91
SEO can be a real minefield to navigate, but there are three simple ways to up your SEO game just be re-assessing your content output.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 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