Recent

Author Topic: Access the next occurrence of an argument in a TStringList  (Read 2724 times)

TRon

  • Hero Member
  • *****
  • Posts: 2801
Re: Access the next occurrence of an argument in a TStringList
« Reply #15 on: June 09, 2024, 12:06:27 am »
Which seems to contradict FreePascal's documentation in this case:
According to Delphi's wiki documentation the indexof with offset neither exists for TStringlist nor TStrings :shrugs:

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1343
    • Lebeau Software
Re: Access the next occurrence of an argument in a TStringList
« Reply #16 on: June 09, 2024, 07:10:17 pm »
According to Delphi's wiki documentation the indexof with offset neither exists for TStringlist nor TStrings :shrugs:

That is correct, but that is not the issue.  I did a test in Delphi where a base class has public overloaded virtual methods, a derived class that overrides only 1 of them, and then call both overloads via a pointer to the derived class:

Code: Pascal  [Select][+][-]
  1. type
  2.   TTestBase = class
  3.   public
  4.     procedure DoIt(AValue: Integer); overload; virtual;
  5.     procedure DoIt(AValue1, AValue2: Integer); overload; virtual;
  6.   end;
  7.  
  8.   TTest = class(TTestBase)
  9.   public
  10.     procedure DoIt(AValue: Integer); override;
  11.   end;
  12.  
  13. ...
  14.  
  15. var
  16.   t: TTest;
  17.  
  18. t := TTest.Create;
  19. t.DoIt(1);
  20. t.DoIt(2, 2);
  21. t.Free;

It works fine in Delphi without needing to type-cast to the base class.

The same test should work in FreePascal as well (ie, calling both IndexOf() overloads on a TStringList object without type-casting to TStrings).  If it doesn't work, then it should be reported as a compiler bug.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

 

TinyPortal © 2005-2018