Lazarus

Programming => General => Topic started by: julkas on July 14, 2020, 10:45:04 am

Title: [CLOSED] LoadFromFile() problem
Post by: julkas on July 14, 2020, 10:45:04 am
Following code (FPC 3.0.4) -
Code: Pascal  [Select][+][-]
  1.   ..
  2.   frDict := TStringList.Create();
  3.   frDict.LoadFromFile('enwiki-latest-all-titles-in-ns0', TEncoding.UTF8);
  4.   ..
  5.  

generates error -
Code: Bash  [Select][+][-]
  1. benchmark.lpr(193,73) Error: Wrong number of parameters specified for call to "LoadFromFile"
  2. Error: Found declaration: LoadFromFile(const AnsiString);
  3.  
Any hint ? (Delphi compiles without problem)
Title: Re: LoadFromFile() problem
Post by: Thaddy on July 14, 2020, 10:49:36 am
Use 3.2.0 or trunk (full program):
Code: Pascal  [Select][+][-]
  1. {$mode delphi}{$H+}
  2. uses classes, sysutils;
  3. var
  4.   frDict:TStrings;
  5. begin
  6.   frDict := TStringList.Create();
  7.   frDict.LoadFromFile('enwiki-latest-all-titles-in-ns0', TEncoding.UTF8);
  8.   frDict.Free;
  9. end.

Works like a charm... 3.0.4 is now eol. You are using a feature - TEncoding - that is not in 3.0.4....
Title: Re: LoadFromFile() problem
Post by: marcov on July 14, 2020, 12:38:45 pm
Hmm, delphi overloads it

http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Classes_TStrings_LoadFromFile@string.html
Title: Re: LoadFromFile() problem
Post by: Thaddy on July 14, 2020, 01:03:46 pm
Hmm, delphi overloads it

http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Classes_TStrings_LoadFromFile@string.html
We do too. (as per my demo, existing code will not break)
TinyPortal © 2005-2018