[SOLVED] Convert Delphi package lazarus / 13-General ---------------------------------------------------------------------- julkas · 2019-10-26 09:15 How convert Delphi package to Lazarus? Any step by step mini How To. Thanks. ---------------------------------------------------------------------- JuhaManninen · 2019-10-26 09:37 Quote from: julkas on October 26, 2019, 11:15:54 amHow convert Delphi package to Lazarus? Any step by step mini How To. Please try the Delphi converter in Lazarus Tools menu. Package conversion is not tested as much as the unit and project conversion. Success also depends on the complexity of your code and usage of system API and dependencies etc. ---------------------------------------------------------------------- tr_escape · 2019-10-26 09:38 Also there is a pdf file: https://www.freepascal.org/~michael/articles/lazport1/lazport1.pdf ---------------------------------------------------------------------- Thaddy · 2019-10-26 09:44 It also helps if you tell us WHICH package. This is necessary to solve any incompatibilities. E.g. almost anything that supports Delphi 7 is OK with the above answers, anything from Delphi XE  may have issues and need manual intervention. (Currently the major issues are the use of anonymous methods - language wise, solvable - and anything FireMonkey - package wise - forget about that! ) ---------------------------------------------------------------------- julkas · 2019-10-26 10:02 Quote from: JuhaManninen on October 26, 2019, 11:37:50 amQuote from: julkas on October 26, 2019, 11:15:54 amHow convert Delphi package to Lazarus? Any step by step mini How To. Please try the Delphi converter in Lazarus Tools menu. Package conversion is not tested as much as the unit and project conversion. Success also depends on the complexity of your code and usage of system API and dependencies etc. After Tools -> Felphi Conversion -> Convert Delhi Package to Lazarus Package Screenshot - s1.JPG. After pressing Start conversion button - s2.JPG. And now ? Next steps ? May be it's very overcomplicated and difficult ? FastDBd7.dpk - Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i package FastDBd6; {$R *.res}{$ALIGN 8}{$ASSERTIONS ON}{$BOOLEVAL OFF}{$DEBUGINFO ON}{$EXTENDEDSYNTAX ON}{$IMPORTEDDATA ON}{$IOCHECKS ON}{$LOCALSYMBOLS ON}{$LONGSTRINGS ON}{$OPENSTRINGS ON}{$OPTIMIZATION ON}{$OVERFLOWCHECKS OFF}{$RANGECHECKS OFF}{$REFERENCEINFO ON}{$SAFEDIVIDE OFF}{$STACKFRAMES OFF}{$TYPEDADDRESS OFF}{$VARSTRINGCHECKS ON}{$WRITEABLECONST OFF}{$MINENUMSIZE 1}{$IMAGEBASE $400000}{$DESCRIPTION 'FastDB Components'}{$IMPLICITBUILD OFF} requires  rtl,  vcl,  dbrtl; contains  FastDbReg in 'FastDbReg.pas',  FastDbVar in 'FastDbVar.pas',  FastDbQuery in 'FastDbQuery.pas',  FastDbDataSet in 'FastDbDataSet.pas',  FastDbSession in 'FastDbSession.pas',  FastDbCLI in 'FastDbCLI.pas'; end. ---------------------------------------------------------------------- Thaddy · 2019-10-26 10:22 So you are trying to convert a Kylix 3 package? Although Kylix 3 is somewhat supported with legacy and deprecated, (in fpc) I don't even know if the Lazarus converter is able to handle that. Worse: Linux has evolved so much that real Kylix applications often do not work anymore. (some do). I expect you need to examine ALL code and find modern day alternatives. Kylix was really short-lived. Good idea, bad execution by focus on GUI instead of server and lack of funding and interest. The code can be valuable, though. It just may take some real effort to make it work again. The code is well written and most of the rtl/clx is GPL'd which is a problem with commercial applications. Since it is well written, it is also easy to re-use the code with sufficient knowledge. Note clx can be compiled in FPC, but the Lazarus ide does not support it. Everything needs to be done from code and in {$mode delphi}, no nice component tabs.... ---------------------------------------------------------------------- julkas · 2019-10-26 10:29 Quote from: Thaddy on October 26, 2019, 12:22:57 pmSo you are trying to convert a Kylix 3 package? Although Kylix 3 is somewhat supported with legacy and deprecated, (in fpc) I don't even know if the Lazarus converter is able to handle that. Worse: Linux has evolved so much that real Kylix applications often do not work anymore. (some do). I expect you need to examine ALL code and find modern day alternatives. Kylix was really short-lived. Good idea, bad execution by focus on GUI instead of server and lack of funding and interest. The code can be valuable, though. It just may take some real effort to make it work again. The code is well written and most of the rtl/clx is GPL'd which is a problem with commercial applications. Since it is well written, it is also easy to re-use the code with sufficient knowledge. My question is about Delphi package. ---------------------------------------------------------------------- Thaddy · 2019-10-26 10:30 No. See your own screenshots! < very grumpy now!!  > I am on the verge of calling you an idiot - which many who saw the screenshots will agree with - but I won't. Just... Show us all code. Or at least a link to an archive. ---------------------------------------------------------------------- julkas · 2019-10-26 10:38 Quote from: Thaddy on October 26, 2019, 12:30:37 pmNo. See your own screenshots! < very grumpy now!!  > Original project - Delphi 6/7 and Kylix. Leave your "philosophy" for others. And If you can't help, don't sell bullshit ---------------------------------------------------------------------- Thaddy · 2019-10-26 11:13 It is a clx project. Let's see what others think. Facts can not be opinions. Your reaction just shows an extreme amount of lack of knowledge. That is also a fact and not an opinion. CLX is a limited cross-platform VCL, based on a very old Linux and a very old KDE, just in case.' Just point to the code, stubborn. I am not insulting you, you are just plain stubborn. Changed my signature because of you.... I leave it up to the moderators if your postings and mine belong to a forum... I think factual information will prevail over baseless opinions. ---------------------------------------------------------------------- JuhaManninen · 2019-10-26 13:15 Quote from: julkas on October 26, 2019, 12:02:07 pmAfter pressing Start conversion button - s2.JPG. And now ? Next steps ? May be it's very overcomplicated and difficult ? FastDBd7.dpk - Ok, it produced an empty package. There was some fatal error during the conversion. The message window may show details. Now your only option is to convert unit by unit, either with the same Delphi converter or manually, and then add those units to a new Lazarus package. Good luck. ---------------------------------------------------------------------- julkas · 2019-10-26 13:29 Quote from: JuhaManninen on October 26, 2019, 03:15:58 pmQuote from: julkas on October 26, 2019, 12:02:07 pmAfter pressing Start conversion button - s2.JPG. And now ? Next steps ? May be it's very overcomplicated and difficult ? FastDBd7.dpk - Ok, it produced an empty package. There was some fatal error during the conversion. The message window may show details. Now your only option is to convert unit by unit, either with the same Delphi converter or manually, and then add those units to a new Lazarus package. Good luck. Thank you for clear reply. Is it general problem or @Aleynikov ? ---------------------------------------------------------------------- JuhaManninen · 2019-10-26 14:18 Quote from: julkas on October 26, 2019, 03:29:00 pmIs it general problem or @Aleynikov ? I tried to figure out what that means. I found an unjust legal case with name Aleynikov but I don't see any connection to Delphi converter. Hmmm... Anyway, the Delphi converter fails quite often unfortunately. A dependency to a Delphi unit which is not ported for Lazarus is a common problem. By converting unit by unit you can do the job gradually, mixing automatic and manual conversion sometimes. ---------------------------------------------------------------------- Thaddy · 2019-10-26 14:27 Still no code and I am patient. Without knowing the Delphi clx package this is impossible to solve. I am not as politically correct as others are, but I always help. period. ---------------------------------------------------------------------- julkas · 2019-10-26 15:26 Quote from: JuhaManninen on October 26, 2019, 04:18:20 pmQuote from: julkas on October 26, 2019, 03:29:00 pmIs it general problem or @Aleynikov ? I tried to figure out what that means. I found an unjust legal case with name Aleynikov but I don't see any connection to Delphi converter. Hmmm... Anyway, the Delphi converter fails quite often unfortunately. A dependency to a Delphi unit which is not ported for Lazarus is a common problem. By converting unit by unit you can do the job gradually, mixing automatic and manual conversion sometimes. Ok I can do it converting unit by unit or from underground. My question was about converting existing Delphi code. I want keep original old spirit. ---------------------------------------------------------------------- Thaddy · 2019-10-26 15:40 Quote from: julkas on October 26, 2019, 05:26:00 pmQuote from: JuhaManninen on October 26, 2019, 04:18:20 pmQuote from: julkas on October 26, 2019, 03:29:00 pmIs it general problem or @Aleynikov ? I tried to figure out what that means. I found an unjust legal case with name Aleynikov but I don't see any connection to Delphi converter. Hmmm... Anyway, the Delphi converter fails quite often unfortunately. A dependency to a Delphi unit which is not ported for Lazarus is a common problem. By converting unit by unit you can do the job gradually, mixing automatic and manual conversion sometimes. Ok I can do it converting unit by unit or from underground. My question was about converting existing Delphi code. No, converting Delphi clx code. Anyway: show us that code. Problem likely solved. The Lazarus converter can not convert Kylix code. Am I talking to a brick wall all day? ---------------------------------------------------------------------- julkas · 2019-10-26 15:58 Forget about my project. Give me general directions about converting Delphi package to Lazarus. ---------------------------------------------------------------------- Thaddy · 2019-10-26 16:05 Quote from: julkas on October 26, 2019, 05:58:15 pmForget about my project. Give me general directions about converting Delphi package to Lazarus. If it is not a Kylix project (clx) usually the converter does a good job on Delphi packages pre D2010. This takes minor changes in some case, but we can only help if we KNOW the the sourcecode. In case of a  clx(Kylix) package, simple GUI things can be adapted - by hand - rather easily. Again:  what is the package?, is it open source? Point us to it. You are not very helpful. ---------------------------------------------------------------------- marcov · 2019-10-26 16:12 Thaddy, why do you think it is CLX, I don't see any reference to clx in the screenshots ? ---------------------------------------------------------------------- wp · 2019-10-26 16:13 Quote from: julkas on October 26, 2019, 05:58:15 pmForget about my project. Give me general directions about converting Delphi package to Lazarus. (1) Use the Delphi converter provided by Lazarus (2) If it does not work do a manual conversion as described in https:/ /forum.lazarus.freepascal.org/index.php/topic,46477.msg331273.html#msg 331273 (3) If it does not work look at every unit of the package and fix the issues by finding the corresponding FPC/Lazarus procedures and techniques. Note that this can be a project of its own. It may be more efficient to replace the package by one which comes with Lazarus/FPC or is available as a well-tested library in the Online-Package- Manager. ---------------------------------------------------------------------- Thaddy · 2019-10-26 16:31 Quote from: marcov on October 26, 2019, 06:12:46 pmThaddy, why do you think it is CLX, I don't see any reference to clx in the screenshots ? You need glasses....     (and a little knowledge about Delphi for Linux, a.k.a. Kylix, with an rtl called clx,  which I believe you have?) ---------------------------------------------------------------------- Handoko · 2019-10-26 17:06 I do not know much about Kylix nor CLX. But I really saw "FastDbDelphi-v67-Kylix-v3" in the screenshot. ---------------------------------------------------------------------- wp · 2019-10-26 17:25 It probably means that it contains packages for Delphi 6&7 and for Kylix. This excerpt of the file list is from some Russian site which offers the units: QuoteFastDBd6.dpk    FastDBd7.dpk FastDBk3.dpk ---------------------------------------------------------------------- wp · 2019-10-26 17:55 I found another page which seems to be more trustworthy than the previous one: http://www.garret.ru/fastdb.html, looks like the author's site. I downloaded the sources and was able to create a Lazarus package without any severe issues: In Lazarus, go to "Package" > "New package". Give the new package the name "FastDB.lpk" and store the file in the same folder as the Delphi and Kylix packages.In the package editor, "Add" the FastDB*.pas files to the package.Click "Compile". Now the compiler will stop at a variety of issues, all of them (except for one) are related to the issue that the units are assumed to be for compiler mode objfcp. Therefore, whenever this happens, go to the head of each unit and add the line {$mode Delphi}.There is one final issue: In unit FastDBDataset compilation stops at the identifier TArrayField which is not found. This seems to be related to some particular field type. I don't know whether the FPC implementation of TDataset supports array fields... Hoping that this is not needed you can comment this block in the "case" instruction just to continue. With this change, the package compiles successfully.Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFastDbDataSet.SetFieldData(Field: TField; Buffer: Pointer);var  nCurRec : Integer;  i : Integer;begin  if Field.FieldNo >= 0 then    begin      nCurRec := PMdRecInfo(ActiveBuffer + FRecordSize)^.Bookmark;      FQuery.Skip(nCurRec - Integer(FQuery.RecNo));  // Position the record       if Assigned (Buffer) then        with FUpdateFields[Field.FieldNo-1] do          case DsFieldTypeOfCliType[FieldType] of            ftBytes:  SetValue(Buffer, TBytesField(Field).Size);            ftString: asString := PChar(Buffer);            (*********************** NOT CONVERTED ****************            ftArray : for i:=0 to TArrayField(Field).Size-1 do                        case FieldType of                          ctArrayOfOID,                          ctArrayOfInt4,                          ctArrayOfBool,                        ctArrayOfInt1,                          ctArrayOfInt2,                        ctArrayOfInt8:                            asArrayInt8[i]   := VarAsType(TArrayField(Field).FieldValues[i], varInt64);                          ctArrayOfReal4,                        ctArrayOfReal8:                            asArrayDouble[i] := VarAsType(TArrayField(Field).FieldValues[i], varDouble);                        ctArrayOfString:                            asArrayString[i] := VarAsType(TArrayField(Field).FieldValues[i], varString);                        else                          raise EFastDbError.Create(cli_unsupported_type, Format('Field[%s] %s', [Name, GetEnumName(TypeInfo(TCliVarType), Ord(FieldType))]));                      end;            *******************************************************)          else            SetValue(Buffer, FieldSize);          end;       DataEvent (deFieldChange, Longint(Field));    end;end;Open unit "FastDBReg" and check the box "Register Unit" in the package editorInstall the package. Done. The two components, TFastDBSession and TFastDBQuery, are on the "Data Access" palette. All this is for Windows, I did not try Linux. And I did not test the package at runtime, try yourself... I am attaching the modified files -- unzip to the FastDB folder (where the other pas and .dpk files are). ---------------------------------------------------------------------- julkas · 2019-10-26 18:13 @wp Thank you very much.