Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-10

Code conversion

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sven Ruin

Hi,

Although I'm a Lazarus beginner, I hope the following can be of use for others who want to convert code and for the improvement of the converter in Lazarus.

After having converted my Delphi 4 project with Lazarus 0.9.28.2 beta, Lazarus could build a working executable, but an error message about duplicate resource would show up when I ran my .exe file. The text below, which I found on
http://wiki.lazarus.freepascal.org/Code_Conversion_Guide#Converting_Delphi_p rojects.2Fforms.2Funits_to_Lazarus, was helpful to solve the problem. I manually edited the converted files according to the parts highlighted with yellow below (hope that the yellow will be visible to all readers) and deleted one of the two lines with {$i unitname.lrs} near the end of the .pas file. Then I could build again and now my new .exe file runs without the error message.

In the beginning, it was also a bit confusing that I could not see the unit and form of the converted project, but had to click View.

Sven

Another method to convert a Delphi or Kylix project to Lazarus

* Rename or copy all .dfm or .xfm files to .lfm (Early Delphi versions do not produce a text-based .dfm file. The convert utility, if present in the \bin folder can be used to covert the .dfm first))
* Rename or copy .dpr file to .lpr
* Make necessary changes to .lpr file:

1. Add {$mode delphi}{$H+} or {$mode objfpc}{H+} directives
2. Add 'Interfaces' to uses clause
3. Comment out or delete {$R *.res} or directive

* Make necessary changes to all .pas unit files:

1. Add {$mode delphi}{$H+} or {$mode objfpc}{H+} directives
2. Add 'LResources', and if the form has buttons, add 'Buttons' to uses clause
3. Comment out or delete {$R *.dfm} or {$R *.xfm} directive
4. Add 'Initialization' section at the end of each unit file, and add {$I unitname.lrs} directive in it

* Select Project->New Project from file
* Select the .lpr file
* At 'Create a new project' window, choose 'Application'
* Build project and make further necessary corrections to get proper compilation, at this point the .lpi file is generated automaticaly. You may also get 'Error reading Form' messages, click on 'Continue Loading' if you do.
* Save all, and you have a Lazarus project :-)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20101015/3aa408cf/attachment-0001.html>

Reply by email

Juha Manninen gmail
to Sven Ruin
Sven Ruin wrote
Although I'm a Lazarus beginner, I hope the following can be of use for others who want to convert code and for the improvement of the converter in Lazarus.

Sven, I am sorry to tell you but you have wasted your time by converting manually. Delphi converter in the Lazarus trunk version has improved vastly. It does everything you did manually and much more. Besides, .lrs resource files are not needed any more. New versions of FPC and Lazarus can use Delphi style resources.

More information here:
http://wiki.lazarus.freepascal.org/Delphi_Converter_in_Lazarus and here:
http://lazarus-dev.blogspot.com/

I updated the original wiki conversion page with a link to the new page.

Now Lazarus developers, a new release policy is needed. A released version is some kind of recommendation for users, like: "Use this if you want solid and stable operation". Now it doesn't work. Many (most?) developers must use the development version because it is so much better the the released version. I will write another mail about it.

Regards,
Juha

Reply by email