Recent

Author Topic: [SOLVED] Lazerus Trunk 4.99 and ECControls 0.9.58  (Read 792 times)

madref

  • Hero Member
  • *****
  • Posts: 1102
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
[SOLVED] Lazerus Trunk 4.99 and ECControls 0.9.58
« on: February 25, 2025, 12:44:32 pm »
I finally got Trunk 4.99 to install.
But now I am adding my packages and ECControl will not install because I get an error in ECSwitch.
Code: Pascal  [Select][+][-]
  1. rocedure TCustomECSwitch.SetState(AValue: TCheckBoxState);
  2. begin
  3.   if FState = AValue then exit;
  4.   FState := AValue;
  5.   if [csLoading, csDestroying, csDesigning]*ComponentState = [] then
  6.     begin
  7.       if assigned(OnChange) then OnChange(self);
  8.       { execute only when Action.Checked is changed }
  9.       if not CheckFromAction then
  10.         begin
  11.           if assigned(OnClick) and not (assigned(Action) and
  12.               CompareMethods(TMethod(Action.OnExecute), TMethod(OnClick)))
  13.             then OnClick(self);
  14.           if (Action is TCustomAction) and (TCustomAction(Action).Checked <> (AValue = cbChecked))
  15.             then ActionLink.Execute(self);
  16.         end;
  17.     end;
  18.   Redraw;
  19. end;
The error: ecswitch.pas(1083,15) Error: Identifier not found "CompareMethods"


Has this been changed in 4.99?
« Last Edit: February 25, 2025, 02:45:51 pm by madref »
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Main Platform:
--------------
Mac OS X Sonoma 14.7.4
Lazarus 4.99 (rev main_4_99-1378-ga4855f6fa5) FPC 3.3.1 x86_64-darwin-cocoa

Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)

paweld

  • Hero Member
  • *****
  • Posts: 1355
Re: Lazerus Trunk 4.99 and ECControls 0.9.58
« Reply #1 on: February 25, 2025, 01:30:56 pm »
The deprecated methods were removed at the end of January.
Instead of CompareMethods use the SameMethod function.
That is, the quoted code should look as follows:
Code: Pascal  [Select][+][-]
  1. p    rocedure TCustomECSwitch.SetState(AValue: TCheckBoxState);
  2.     begin
  3.       if FState = AValue then exit;
  4.       FState := AValue;
  5.       if [csLoading, csDestroying, csDesigning]*ComponentState = [] then
  6.         begin
  7.           if assigned(OnChange) then OnChange(self);
  8.           { execute only when Action.Checked is changed }
  9.           if not CheckFromAction then
  10.             begin
  11.               if assigned(OnClick) and not (assigned(Action) and
  12.                   SameMethod(TMethod(Action.OnExecute), TMethod(OnClick)))
  13.                 then OnClick(self);
  14.               if (Action is TCustomAction) and (TCustomAction(Action).Checked <> (AValue = cbChecked))
  15.                 then ActionLink.Execute(self);
  16.             end;
  17.         end;
  18.       Redraw;
  19.     end;
Best regards / Pozdrawiam
paweld

madref

  • Hero Member
  • *****
  • Posts: 1102
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Lazerus Trunk 4.99 and ECControls 0.9.58
« Reply #2 on: February 25, 2025, 02:45:36 pm »
Thanks
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Main Platform:
--------------
Mac OS X Sonoma 14.7.4
Lazarus 4.99 (rev main_4_99-1378-ga4855f6fa5) FPC 3.3.1 x86_64-darwin-cocoa

Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)

Zvoni

  • Hero Member
  • *****
  • Posts: 2961
Re: Lazerus Trunk 4.99 and ECControls 0.9.58
« Reply #3 on: February 25, 2025, 03:08:33 pm »
The deprecated methods were removed at the end of January.
Instead of CompareMethods use the SameMethod function.
That is, the quoted code should look as follows:
Code: Pascal  [Select][+][-]
  1. p    rocedure TCustomECSwitch.SetState(AValue: TCheckBoxState);
  2.     begin
  3.       if FState = AValue then exit;
  4.       FState := AValue;
  5.       if [csLoading, csDestroying, csDesigning]*ComponentState = [] then
  6.         begin
  7.           if assigned(OnChange) then OnChange(self);
  8.           { execute only when Action.Checked is changed }
  9.           if not CheckFromAction then
  10.             begin
  11.               if assigned(OnClick) and not (assigned(Action) and
  12.                   SameMethod(TMethod(Action.OnExecute), TMethod(OnClick)))
  13.                 then OnClick(self);
  14.               if (Action is TCustomAction) and (TCustomAction(Action).Checked <> (AValue = cbChecked))
  15.                 then ActionLink.Execute(self);
  16.             end;
  17.         end;
  18.       Redraw;
  19.     end;
Pawel, wouldn't a conditional make more sense?
something like
Code: Pascal  [Select][+][-]
  1. {$if (lcl_fullversion > 4000000)} SameMethod {$ELSE} CompareMethods {$IFEND}
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

paweld

  • Hero Member
  • *****
  • Posts: 1355
Re: [SOLVED] Lazerus Trunk 4.99 and ECControls 0.9.58
« Reply #4 on: February 25, 2025, 05:23:07 pm »
Is a very good idea to condition the code on the lazarus version (although the SameMethods function was introduced in version 2.3), but for your own purposes you can take shortcuts.

It is worth reporting the fix to the component author: Blaazen https://forum.lazarus.freepascal.org/index.php?action=profile;u=39483
Best regards / Pozdrawiam
paweld

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4568
  • I like bugs.
Re: [SOLVED] Lazerus Trunk 4.99 and ECControls 0.9.58
« Reply #5 on: February 25, 2025, 05:51:30 pm »
... although the SameMethods function was introduced in version 2.3
Yes. How old versions of Lazarus people plan to use? Generally speaking a new version is better than old versions.
This is from the fixes_3_0 branch, unit LazMethodList.
Code: Pascal  [Select][+][-]
  1. function SameMethod(const m1, m2: TMethod): boolean; inline;
  2. function CompareMethods(const m1, m2: TMethod): boolean; inline;
  3.     deprecated 'Use SameMethod instead.'; // In 2.3 October 2021. Remove in 2.5.

CompareMethods was deprecated in 2021. Now it is 2025. Moral of the story: read the "deprecated" messages!
The reason for the change: By convention CompareXXX() functions return an integer, like "function CompareText(const S1, S2: string): Integer;"
SameXXX() functions return a Boolean, like "function SameText(const s1,s2: String): Boolean;"
CompareMethods() returning a Boolean was confusing.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

wp

  • Hero Member
  • *****
  • Posts: 12761
Re: [SOLVED] Lazerus Trunk 4.99 and ECControls 0.9.58
« Reply #6 on: February 25, 2025, 06:21:06 pm »
Juha, you are right, of course. But this will happen as long as some Linux distributions are ultra-conservative and provide only ancient versions in their repositories. I just had to install a Debian 12 Stable into a VM recently, and it offers me Lazarus v2.2.6 in its package manager. And there are many users here who unfortunately refrain from installing the currently released packages.
« Last Edit: February 25, 2025, 06:23:00 pm by wp »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4568
  • I like bugs.
Re: [SOLVED] Lazerus Trunk 4.99 and ECControls 0.9.58
« Reply #7 on: February 25, 2025, 07:21:02 pm »
OK, Lazarus v2.2.6 is quite old. In some situations an IFDEF may be necessary after all.

And there are many users here who unfortunately refrain from installing the currently released packages.
CompareMethods will be gone in a release version 5.0 which will take some time. 2026 maybe?
Only component developers who support the development branch "main" must replace CompareMethods.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Zvoni

  • Hero Member
  • *****
  • Posts: 2961
Re: [SOLVED] Lazerus Trunk 4.99 and ECControls 0.9.58
« Reply #8 on: February 26, 2025, 08:24:37 am »
Is a very good idea to condition the code on the lazarus version (although the SameMethods function was introduced in version 2.3), but for your own purposes you can take shortcuts.

It is worth reporting the fix to the component author: Blaazen https://forum.lazarus.freepascal.org/index.php?action=profile;u=39483
I've sent a PM to Blaazen
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

madref

  • Hero Member
  • *****
  • Posts: 1102
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: [SOLVED] Lazerus Trunk 4.99 and ECControls 0.9.58
« Reply #9 on: February 26, 2025, 09:45:42 am »
But the ECControl was installed using the OnlinePackageManager.
There you have the most recent packages (at least you think)
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Main Platform:
--------------
Mac OS X Sonoma 14.7.4
Lazarus 4.99 (rev main_4_99-1378-ga4855f6fa5) FPC 3.3.1 x86_64-darwin-cocoa

Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)

paweld

  • Hero Member
  • *****
  • Posts: 1355
Re: [SOLVED] Lazerus Trunk 4.99 and ECControls 0.9.58
« Reply #10 on: February 26, 2025, 10:30:37 am »
@madref: In OPM is the latest (newest) reported version. If there is a newer version of the component then someone (preferably it should be the developer / maintainer of the component) must report it to email: opm (at) lazarus-ide (dot) org
The latest version of ECC is 0.9.60 from May 2023, but this particular piece of code is the same.
Best regards / Pozdrawiam
paweld

madref

  • Hero Member
  • *****
  • Posts: 1102
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: [SOLVED] Lazerus Trunk 4.99 and ECControls 0.9.58
« Reply #11 on: February 26, 2025, 05:46:47 pm »
Thanks again
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Main Platform:
--------------
Mac OS X Sonoma 14.7.4
Lazarus 4.99 (rev main_4_99-1378-ga4855f6fa5) FPC 3.3.1 x86_64-darwin-cocoa

Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)

 

TinyPortal © 2005-2018