Recent

Author Topic: Problem with convert from Delphi to Lazarus  (Read 2833 times)

teco

  • New Member
  • *
  • Posts: 27
Problem with convert from Delphi to Lazarus
« on: April 04, 2024, 02:17:22 pm »
Hi,
I have used the converter from Lazarus 3.2 to convert a Delphi Sourcecode to Lazarus.

The converter has finished, but when I try to compile I get a lot of errors.

Is there a Namespace Reference List available. The current source of the errors are the used namespaces.

Code: Pascal  [Select][+][-]
  1. uses
  2.   Winapi.Windows, Winapi.Messages,
  3.   System.SysUtils, System.StrUtils, System.DateUtils, System.IOUtils, System.Variants, System.Classes, System.Math, System.Win.Registry, System.Rtti,
  4.   Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.WinXCtrls, Vcl.CheckLst, Vcl.AppEvnts, Vcl.Clipbrd,
  5.   Windows.Foundation, Windows.System.WindowsProgramming, Windows.System.Power, Windows.System.Threading,
  6.   Windows.Devices.DeviceAndDriverInstallation, Windows.System.SystemServices, Windows.System.Shutdown, Windows.System.Recovery,
  7.   Windows.UI.WindowsAndMessaging, Vcl.Menus {, Windows.UI.Input.KeyboardAndMouse};
  8.  

Currently is stops because of IOUtils. What can be used instead.

Thank you.

rvk

  • Hero Member
  • *****
  • Posts: 6327
Re: Problem with convert from Delphi to Lazarus
« Reply #1 on: April 04, 2024, 02:26:59 pm »
Currently is stops because of IOUtils. What can be used instead.
With what error?

System.IOUtils should exists.
(at least if I add System.IOUtils to my uses clause it doesn't complain)

For IOUtils you could leave the System. in front (because it does really exist).
For the others you can just strip Vcl. and System. etc.

(It would be useful if the converter did that, if it doesn't already.)
« Last Edit: April 04, 2024, 02:31:09 pm by rvk »

teco

  • New Member
  • *
  • Posts: 27
Re: Problem with convert from Delphi to Lazarus
« Reply #2 on: April 04, 2024, 02:54:10 pm »
I am using Lazarus 2.2.6  64 Bit

Delphi Project converted with "Tools - Delphi Conversion  Convert Delphi Project to Lazarus Project"

Errormessages are  "Fatal: Cannot find IOUtils used by"  or "Fatal: Cannot find System.IOUtils used by"

The converter has shown only that "VCL.Forms" is not existing. I have changed this to "Forms" in the lpr file.

Complete source code attached. It is from the Delphi-Praxis Forum.

Any idea why it does not find System.IOUtils?

rvk

  • Hero Member
  • *****
  • Posts: 6327
Re: Problem with convert from Delphi to Lazarus
« Reply #3 on: April 04, 2024, 03:48:44 pm »
I am using Lazarus 2.2.6  64 Bit
Can't help you there. That's an old version.

I thought you said you were using Lazarus 3.2
I have used the converter from Lazarus 3.2 to convert a Delphi Sourcecode to Lazarus.

Any idea why it does not find System.IOUtils?
For FPC 3.2.2 (which should also be in Laz 2.2.6) it would be in fpc\packages\vcl-compat\src.

I don't have a Laz 2.2.6 installed so I can't check.

But if you used the converter from Lazarus 3.2, you should also use Lazarus 3.2 itself. Not go back with the converted project to 2.2.6.

teco

  • New Member
  • *
  • Posts: 27
Re: Problem with convert from Delphi to Lazarus
« Reply #4 on: April 04, 2024, 03:58:49 pm »
Sorry for confusion.
First I have used Lazarus 3.2. As it failed I have tried an old installation of Lazarus 2.2.6.

The folder  fpc\packages\vcl-compat\src has only the file "system.netencoding.pp"

Is the installation broken? I have only installed the 64 bit Windows version and the cross kit for 32bit

wp

  • Hero Member
  • *****
  • Posts: 12299
Re: Problem with convert from Delphi to Lazarus
« Reply #5 on: April 04, 2024, 04:00:35 pm »
System.IOUtils seems to be something added by FPC/main, FPC 3.2.2 does not find it. teco is right: packages/vcl-compat containt only the netencoding file, but FPC/main contains mainy more, among them system.ioutils. This unit itself contains a lot of code in which various functions scattered over various units are grouped into "modern" classes (TDirectory, TPath, TFile).

Comment this unit out in the uses clause of the converted project. Try to compile, and the compiler will tell you which function/procedure etc is missing now. Try to find them in the FPC files (do a "Search" > "Find In Files" for them in the FPC directory). Then you know the unit to be used instead. Or ask again here and tell us the missing functions. Maybe you are lucky, and the IOUtils unit can be removed without an effect because delphi very often adds standard units by default without needing them.
« Last Edit: April 04, 2024, 04:07:26 pm by wp »

rvk

  • Hero Member
  • *****
  • Posts: 6327
Re: Problem with convert from Delphi to Lazarus
« Reply #6 on: April 04, 2024, 04:05:52 pm »
Is the installation broken? I have only installed the 64 bit Windows version and the cross kit for 32bit
I'm not sure. I work with trunk (newest development) version.
There the system.ioutils.pp is added on 21-01-2023. I don't know if and when it was added to FPC stable.

But I can assure you, that's not the only problem you are going to encounter, translating that source.
After you remove all the Vcl. and System. from the uses clause, you will se some additional units are missing.
Like Vcl.WinXCtrls, Windows.Foundation, Windows.System.WindowsProgramming, Windows.System.Power, Windows.System.Threading, Windows.Devices.DeviceAndDriverInstallation, Windows.System.SystemServices, Windows.System.Shutdown, Windows.System.Recovery and Windows.UI.WindowsAndMessaging.

Just comment out the System.IOUtils and see where it ends up.

wp

  • Hero Member
  • *****
  • Posts: 12299
Re: Problem with convert from Delphi to Lazarus
« Reply #7 on: April 04, 2024, 04:27:49 pm »
I was not aware that you had attached the Delphi source in an earlier post. Now I loaded this code into Delphi 11.3 CE and noticed that even this version does not have all units. It's probably a Delphi 12 project, I don't know... Therefore I am very sure that FPC/main will not have all procedures/functions needed. One of those projects which cannot be converted...

teco

  • New Member
  • *
  • Posts: 27
Re: Problem with convert from Delphi to Lazarus
« Reply #8 on: April 04, 2024, 04:37:50 pm »
I was not aware that you had attached the Delphi source in an earlier post. Now I loaded this code into Delphi 11.3 CE and noticed that even this version does not have all units. It's probably a Delphi 12 project, I don't know... Therefore I am very sure that FPC/main will not have all procedures/functions needed. One of those projects which cannot be converted...

Oh,

Thank you for testing. I have seen this on Delphi Praxis and the compiled version. It has some functions to read out information from a Laptop battery. I have hoped to use this source code to get some how to's and to build my own battery analysis tool.

Haven't known that it is for Delphi 12.

rvk

  • Hero Member
  • *****
  • Posts: 6327
Re: Problem with convert from Delphi to Lazarus
« Reply #9 on: April 04, 2024, 04:46:00 pm »
Thank you for testing. I have seen this on Delphi Praxis and the compiled version. It has some functions to read out information from a Laptop battery. I have hoped to use this source code to get some how to's and to build my own battery analysis tool.
Your best bet would be to check out the functions you want to use and search for them here on the forum or internet.

For instance... I see that, for the battery, there is a function TDemoForm.DoIOCtrlBattery.
The first call there is SetupDiGetClassDevs(@GUID_DEVCLASS_BATTERY ....
Search for SetupDiGetClassDevs on this forum and the first hit is:

Problem with converting Delphi Source (Battery Monitoring)
https://forum.lazarus.freepascal.org/index.php/topic,64055.msg486106.html#msg486106

Hey, somebody was already working on that  :D
Check out the answer (by @wp  ;) ) and see if it get you any further.

wp

  • Hero Member
  • *****
  • Posts: 12299
Re: Problem with convert from Delphi to Lazarus
« Reply #10 on: April 04, 2024, 04:51:09 pm »
It has some functions to read out information from a Laptop battery.
Maybe this can help you... Or search the forum for "WMI" or similar.

Haven't known that it is for Delphi 12.
Or for the "Enterprise"/"Architect" or whatever of an older version which "normal people" cannot afford...

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4517
  • I like bugs.
Re: Problem with convert from Delphi to Lazarus
« Reply #11 on: April 05, 2024, 08:06:13 am »
First I have used Lazarus 3.2. As it failed I have tried an old installation of Lazarus 2.2.6.
How did Lazarus 3.2 fail? Was it also about the converter or some other problem? If there is a regression and 2.2.6 works better than 3.2, it should be reported and fixed.

[Edit] The Delphi converter in Lazarus is designed for old Delphi 7 style applications. Updating it to support new Delphi versions is challenging because the libraries in Delphi and FPC/Lazarus have diverged since then.
The dotted namespaces should be supported though.
« Last Edit: April 05, 2024, 09:08:31 am by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

teco

  • New Member
  • *
  • Posts: 27
Re: Problem with convert from Delphi to Lazarus
« Reply #12 on: April 05, 2024, 08:15:56 am »
Nothing specific to fix.

It lookl like that the Delphi Source has parts inside which are not supported by Lazarus/Free Pascal.


I was not aware that you had attached the Delphi source in an earlier post. Now I loaded this code into Delphi 11.3 CE and noticed that even this version does not have all units. It's probably a Delphi 12 project, I don't know... Therefore I am very sure that FPC/main will not have all procedures/functions needed. One of those projects which cannot be converted...

 

TinyPortal © 2005-2018