Results 1 to 13 of 13

Thread: Converteren van Delphi naar Lazarus

  1. #1

    Converteren van Delphi naar Lazarus

    Ik probeer een bestaande unit te converteren met de convert wizard in lazarus:
    Click image for larger version. 

Name:	macOS Sierra-2020-04-26-14-16-40.jpg 
Views:	139 
Size:	98.1 KB 
ID:	8079

    Maar ik krijg direct de melding dat deze is afgebroken, en als ik in het log kijk zie ik enkel "Fatal: Convertion Aborted". Dit krijg ik met elke unit die ik probeer te converteren, zelfs een simpele unit met enkel maar 1 Type die eigenlijk gewoon een TPanel is, blijf ik deze melding houden. Ik heb het al opgezocht, maar begrijp totaal niet wat er nu mis gaat. Ik heb nu een aantal components herschreven naar Lazarus omdat een aantal properties niet in Lazarus beschikbaar zijn (zoals de ShowCaption, BevelEdges) en die werken nu prima - maar de unit die ik probeer te converteren is nogal groot en uitgebreid, en die herschrijven gaat nogal een kluif zijn.

    Het is de bedoeling dat ik deze kan gebruiken voor compilatie voor MacOS en eventueel Linux. Kan iemand mij vertellen wat ik verkeerd doe? En of ik toch beter de hele unit herschrijf?

  2. #2
    Welke Lazarus versie?

    En heb je een simpel voorbeeld van een unit die niet te converteren is?

    Bart

  3. #3
    Lazarus 2.0.8
    voorbeeld unit:
    Delphi Code:
    1. unit untBottomPanel;
    2.  
    3. interface
    4.  
    5. uses
    6.   System.SysUtils, System.Classes, Vcl.Controls, Vcl.ExtCtrls, Vcl.Graphics,
    7.   Vcl.StdCtrls, untTranslation;
    8.  
    9. type
    10.   TBottomPanelType = (ptOkCancel, ptOkCancelApply, ptClose);
    11.  
    12.   TBottomPanel = class(TCustomPanel)
    13.   private
    14.     { Private declarations }
    15.     FOKButton: TButton;
    16.     FCancelButton: TButton;
    17.     FApplyButton: TButton;
    18.     FCloseButton: TButton;
    19.  
    20.     FPanelType: TBottomPanelType;
    21.     FTranslation: TTranslation;
    22.     procedure SetPanelType(const T: TBottomPanelType);
    23.     procedure SetTranslation(const ATranslation: TTranslation);
    24.   protected
    25.     { Protected declarations }
    26.   public
    27.     { Public declarations }
    28.     constructor Create(AOwner: TComponent); override;
    29.     destructor Destroy; override;
    30.  
    31.     procedure UpdateLanguage;
    32.   published
    33.     { Published declarations }
    34.     property PanelType: TBottomPanelType read FPanelType write SetPanelType default ptOkCancel;
    35.  
    36.     property OKButton: TButton read FOKButton;
    37.     property CancelButton: TButton read FCancelButton;
    38.     property ApplyButton: TButton read FApplyButton;
    39.     property CloseButton: TButton read FCloseButton;
    40.     property Translation: TTranslation read FTranslation write SetTranslation;
    41.   end;
    42.  
    43. procedure Register;
    44.  
    45. implementation
    46.  
    47. constructor TBottomPanel.Create(AOwner: TComponent);
    48. begin
    49.   inherited Create(AOwner);
    50.   { Create Panel }
    51.   Align       := alBottom;
    52.   BevelEdges  := [];
    53.   BevelOuter  := bvNone;
    54.   ShowCaption := False;
    55.   Height      := 33;
    56.   Font.Name   := 'Segoe UI';
    57.   { Panel Type }
    58.   FPanelType := ptOkCancel;
    59.   { OK Button }
    60.   FOKButton                       := TButton.Create(Self);
    61.   FOKButton.Caption               := 'OK';
    62.   FOKButton.Parent                := Self;
    63.   FOKButton.AlignWithMargins      := True;
    64.   FOKButton.Margins.Left          := 0;
    65.   FOKButton.Margins.Top           := 1;
    66.   FOKButton.Margins.Right         := 4;
    67.   FOKButton.Margins.Bottom        := 7;
    68.   FOKButton.Align                 := alRight;
    69.   FOKButton.ModalResult           := 1;
    70.   FOKButton.Width                 := 90;
    71.   FOKButton.Name                  := Format('%sOKButton', [Name]);
    72.   FOKButton.SetSubComponent(True);
    73.   FOKButton.Visible               := True;
    74.   { Cancel Button }
    75.   FCancelButton                   := TButton.Create(Self);
    76.   FCancelButton.Caption           := 'Cancel';
    77.   FCancelButton.Parent            := Self;
    78.   FCancelButton.AlignWithMargins  := True;
    79.   FCancelButton.Margins.Left      := 0;
    80.   FCancelButton.Margins.Top       := 1;
    81.   FCancelButton.Margins.Right     := 8;
    82.   FCancelButton.Margins.Bottom    := 7;
    83.   FCancelButton.Align             := alRight;
    84.   FCancelButton.ModalResult       := 2;
    85.   FCancelButton.Width             := 90;
    86.   FCancelButton.Name              := Format('%sCancelButton', [Name]);
    87.   FCancelButton.SetSubComponent(True);
    88.   FCancelButton.Visible           := True;
    89.   { Apply Button }
    90.   FApplyButton                    := TButton.Create(Self);
    91.   FApplyButton.Caption            := 'Apply';
    92.   FApplyButton.Parent             := Self;
    93.   FApplyButton.AlignWithMargins   := True;
    94.   FApplyButton.Margins.Left       := 0;
    95.   FApplyButton.Margins.Top        := 1;
    96.   FApplyButton.Margins.Right      := 8;
    97.   FApplyButton.Margins.Bottom     := 7;
    98.   FApplyButton.Align              := alRight;
    99.   FApplyButton.ModalResult        := 0;
    100.   FApplyButton.Width              := 90;
    101.   FApplyButton.Name               := Format('%sApplylButton', [Name]);
    102.   FApplyButton.SetSubComponent(True);
    103.   FApplyButton.Visible            := False;
    104.   { Apply Button }
    105.   FCloseButton                    := TButton.Create(Self);
    106.   FCloseButton.Caption            := 'Close';
    107.   FCloseButton.Parent             := Self;
    108.   FCloseButton.AlignWithMargins   := True;
    109.   FCloseButton.Margins.Left       := 0;
    110.   FCloseButton.Margins.Top        := 1;
    111.   FCloseButton.Margins.Right      := 8;
    112.   FCloseButton.Margins.Bottom     := 7;
    113.   FCloseButton.Align              := alRight;
    114.   FCloseButton.ModalResult        := 8;
    115.   FCloseButton.Width              := 90;
    116.   FCloseButton.Name               := Format('%sCloseButton', [Name]);
    117.   FCloseButton.SetSubComponent(True);
    118.   FCloseButton.Visible            := False;
    119. end;
    120.  
    121. procedure TBottomPanel.SetPanelType(const T: TBottomPanelType);
    122. begin
    123.   if (T <> FPanelType) then
    124.   begin
    125.     FPanelType := T;
    126.     case T of
    127.       ptOkCancel:
    128.       begin
    129.         FOKButton.Visible     := True;
    130.         FCancelButton.Visible := True;
    131.         FApplyButton.Visible  := False;
    132.         FCloseButton.Visible  := False;
    133.       end;
    134.  
    135.       ptOkCancelApply:
    136.       begin
    137.         FOKButton.Visible     := True;
    138.         FCancelButton.Visible := True;
    139.         FApplyButton.Visible  := True;
    140.         FCloseButton.Visible  := False;
    141.       end;
    142.  
    143.       ptClose:
    144.       begin
    145.         FOKButton.Visible     := False;
    146.         FCancelButton.Visible := False;
    147.         FApplyButton.Visible  := False;
    148.         FCloseButton.Visible  := True;
    149.       end;
    150.     end;
    151.   end;
    152. end;
    153.  
    154. procedure TBottomPanel.SetTranslation(const ATranslation: TTranslation);
    155. begin
    156.   FTranslation := ATranslation;
    157.   if Assigned(FTranslation) then UpdateLanguage;
    158. end;
    159.  
    160. procedure TBottomPanel.UpdateLanguage;
    161. begin
    162.   if Assigned(FTranslation) then
    163.   begin
    164.     FOKButton.Caption     := FTranslation.TextOfApplicationConstant('OK');
    165.     FCancelButton.Caption := FTranslation.TextOfApplicationConstant('Cancel');
    166.     FApplyButton.Caption  := FTranslation.TextOfApplicationConstant('Apply');
    167.     FCloseButton.Caption  := FTranslation.TextOfApplicationConstant('Close');
    168.   end;
    169. end;
    170.  
    171. destructor TBottomPanel.Destroy;
    172. begin
    173.   inherited Destroy;
    174. end;
    175.  
    176. procedure Register;
    177. begin
    178.   RegisterComponents('ERDesigns', [TBottomPanel]);
    179. end;
    180.  
    181. end.

  4. #4
    mov rax,marcov; push rax marcov's Avatar
    Join Date
    Apr 2004
    Location
    Ehv, Nl
    Posts
    10,357
    Begin eens met de namespaces te verwijderen.

  5. #5
    Die unit geeft geen foutmelding in Lazarus trunk.

    Code:
    Messages, Hints: 2
    delphiunit.pas(5,9) Note: Added MODE Delphi syntax modifier after unit name.
    Conversion Ready.
    Hint: This log was saved to C:\Users\Bart\LazarusProjecten\bugs\converter\AutomaticConversion.log
    De VCL namespace wordt overigens niet verwijderd.

    Bart
    Last edited by Bart B; 27-Apr-20 at 23:27. Reason: taal=NL

  6. #6
    Heel vreemd zal ik toch iets mis doen want bij mij lukt omzetten op OSX niet ..

  7. #7
    Nogmaals: welke Lazarus versie?
    Indien trunk: maak een bugreport en attach die unit erbij.
    Indien geen trunk: probeer met trunk.

    Bart

  8. #8
    Zoals hierboven al staat: Lazarus 2.0.8

  9. #9
    Quote Originally Posted by Reidinga View Post
    Zoals hierboven al staat: Lazarus 2.0.8
    Sorry, overheen gelezen.

    Dus: test met trunk.

    Bart

  10. #10
    Ga ik doen heb wel gemerkt dat de kleine units redelijk makkelijk te herschrijven zijn, mijn grootste zorg zat in dat ik voor sommige components Generics gebruik, gelukkig heeft Lazarus dit ook (TFPGObjectList<TMyObject>)

  11. #11
    John Kuiper
    Join Date
    Apr 2007
    Location
    Almere
    Posts
    8,747
    Ik heb begrepen dat er ook een generics package is voor lazarus, die in delphi ook wordt gebruikt. Maar ik vind package fgl een goede alternatief.
    Delphi is great. Lazarus is more powerfull

  12. #12
    In fpc >= 3.2: generic.collections.

    Bart

  13. #13
    mov rax,marcov; push rax marcov's Avatar
    Join Date
    Apr 2004
    Location
    Ehv, Nl
    Posts
    10,357
    en fcl-stl is er nog.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •