Convert Borland Pascal to GUI 32 bit Windows

Posted on 2004-04-20
Last Modified: 2010-04-16
I have to convert a Borland Pascal App into a Windows GUI app. The resulting app has to be compatible with:

All operating systems Windows 98,2000 XP.
Current data and index files.

Has to provide a GUI interface to the use.

I need to know which development environment I would need. Any thing I should be aware of while convcerting the source.
Question by:Idarac
  • 4
  • 4

Expert Comment

ID: 10868412
Well, the easiest development environment to step up to would be Borland Delphi.  That way you wont have to rewrite your code in a whole new language, just maybe make a few changes here and there (some functions may have been renamed, for example Assign() is now AssignFile()).

One thing to be aware of though, you'll be going from 16bit to 32bit, which means some of your numeric data types will be changing size (Integer and Word become signed and unsigned 32bit respectively).  In most cases that isn't a big deal, but when you're working with binary files, it is a big deal (reading a single integer with BP will read 2 bytes, with Delphi it'll read 4).  So you'll have to take that into consideration when working with your data files.  If they are typed files and you have records, it's actually an easy fix.  For example:

{ BP Record }
type MyRecord = Record
  MyInt: Integer;
  MyWord: Word;

{ Delphi Equivalent }
type MyRecord = Packed Record
  MyInt: SmallInt;
  MyWord: SmallWord;

Also notice the keyword Packed in the type declaration.  BP used packed records by default, but to be more efficient (speed not size wise) Delphi uses record alignment by default.  This will also create problems reading typed files, so the Packed keyword solves that.

There are many other minor issues to consider (for example "set of" doesn't work the same, but isn't commonly used so might not be an issue for you), but I think the renamed functions and different data sizes are the main ones to be aware of.

Author Comment

ID: 10868806
A bit more about actual data files.

Is is safe to assume that any data files the Pascal can work with Delphi can also work with?

I believe there is a packing and reindexing routine with the existing app. What would that tell me about what type of data files I have to work with?

The dataset I was given has extensions of *.dta, *.kx and .xx.

A bitmore about the Pasal project.
I have never used Delphi before how do I get the Pascal source into Delphi?

Expert Comment

ID: 10869212
Yes, it is safe to assume that any data file BP could read, Delphi can also read.  As I said you just need to watch out for some of the differences, like datatype sizes.

With packing and reindexing, it sounds like they are probably some sort of typed files.  When records are deleted from typed files, the most efficient (speed wise) thing to do is to mark the record as deleted, but to actually leave it in the file.  Then when a new record is added it can just overwrite the old deleted record.  But if new records are rarely added, the file is like swiss cheese with holes everywhere after awhile.  Packing the file would mean moving the remaining good records to the front of the file, and then all the deleted records would be on the end and could be truncated (this is efficient, size wise).  Of course there are more interpretations of "packing and reindexing", so this may be way off base.

As for those extensions, they mean nothing to me.  If it's a proprietary application, they could have chosen anything so it doesn't really indicate much.

And as for getting the source into Delphi, it's probably going to be a lot of cutting and pasting.  In the BP program, for example, you may have had a block of code that ran when the 'R' key was pressed.  In your Delphi application you'll have a button on a form to perform the action that the 'R' keypress used to, and so you would paste the code into that button's onClick event handler.

Any code not associated with an event (such as helper functions) could still be kept in separate units, just like you would have done in BP.
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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


Author Comment

ID: 10872151
I just confirmed that the BP code is version 7.

I have Delphi 2.0 so I am going to try and bring in the version 7 code.

Does Delphi and BP both have a project persay where you load it based on the project?

I am going to install Delphi 2.0 on my computer and try and open the BP 7 project. Anything I should do before I try?

Expert Comment

ID: 10895450
I dont think BP had a project option, you just loaded up the main source file and hit compile.  I've never used anything as old as Delphi 2.0, but even if it does compile the BP code with no changes, it's not going to be a GUI program.  It's definitely going to take a bit of work to get that part done.

Author Comment

ID: 10898946
I have Delphi 2.0 here so I thought I would start with that.

So it seems I need a version of Delphi.

My last question to you is to help me make some sense of the Delphi versions. I see Delphi studio out there. Which version should I start with?

I will then close this question and start a new one when I actually start converting the program.

Accepted Solution

MannSoft earned 250 total points
ID: 10899187
Well I've never used Delphi 2.0, so I don't know what it is capable of, so it may indeed be good enough for you to do what you want.  I was just saying that you won't be able to recompile the BP program in Delphi, and have it become a GUI application without any changes.  No matter which version of Delphi you choose, you're going to have to manually create a GUI and add the code from your BP program behind the various events (mainly behind button clicks)

And about Delphi Studio, I think that is what they started calling versions 6 and 7 because they also came with the Linux equivalent of Delphi, called Kylix.  Unless you are interested in cross-platform development, you could probably save a few bucks by not getting a version with Kylix, because you won't need it.

Author Comment

ID: 10899368

Thanx for your help.

I will probably opening another question once I start the conversion.

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
help with delphi code 6 481
MAPI Error1: User cancelled request ? 7 1,176
Compare of Excelsheets 41 383
How do you get the IP address of a network? 12 282
Most MSPs worth their salt are already offering cybersecurity to their customers. But cybersecurity as a service is wide encompassing and can mean many things.  So where are MSPs falling in this spectrum?
This article describes how to reset your Windows 10 password when you've forgotten it.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

790 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