[SOLVED] Using FindFirst() in Windows 64 with FPC 3.3.1 lazarus / 67-Windows ---------------------------------------------------------------------- AxBen · 2024-02-27 18:42 Hi. I'm trying to use FindFirst() (et al.) in the console. Compiling my source (I'm pretty new to FPC), ppcrossx64 gives me: >>> Error: Call by var for arg no. 1 has to match exactly: Got "UnicodeString" expected "TRawbyteSearchRec" The code snippet looks like this: 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 {$Mode DelphiUnicode}var   dir: UnicodeString;   search_rec: TUnicodeSearchRec;begin   if FindFirst(dir + '/*', faAnyFile, search_rec) <> -1 then      ...  The docs (3.2.2) state: Quote76.15.118 FindFirst Declaration: function FindFirst(const Path: UnicodeString; Attr: LongInt; out Rslt: TUnicodeSearchRec) : LongInt function FindFirst(const Path: RawByteString; Attr: LongInt; out Rslt: TRawbyteSearchRec) : LongIn so I should normally be good to go. What am I doing wrong? ---------------------------------------------------------------------- Bart · 2024-02-27 18:54 Works for me. fpc 3.3.1-3157-g728be94328 (win32 crosscompiling to win64). Bart ---------------------------------------------------------------------- cdbc · 2024-02-27 19:07 Hi you could try this: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 {$Mode objfpc}{$H+} // objpascal + long stringsvar   dir: String;   search_rec: TSearchRec;begin   if FindFirst(dir + '/*', faAnyFile, search_rec) = 0 then     // do something   ...Don't forget 'FindClose;' when you're done... It seemed to pick the wrong overload  Regards Benny ---------------------------------------------------------------------- TRon · 2024-02-27 19:11 From the manual: Quote DelphiUnicode     Delphi compatibility mode. All object-pascal extensions are enabled, and additionally the String keyword refers to a unicode string. That implies that there is no need to be explicit. ---------------------------------------------------------------------- Bart · 2024-02-27 19:12 Tested with fpc main as of today (fpc 3.3.1-3996-g6a28ac53da): compiles both in $mode objfpc and $mode delphiunicode, both 32-bit and x-compiled to win64. Bart ---------------------------------------------------------------------- AxBen · 2024-02-27 19:33 @TRon, cdbc QuoteThat implies that there is no need to be explicit. This is correct. Replaced UnicodeString with String, but sadly the error remains. I guess this might be a compiler installation problem on my side. I will probably need to get that straight first (cmp https://forum.lazarus.freepascal.org/index.php/topic,66404.0.html)... On another note: is there an alternative to FindFirst()? I think Delphi/Lazarus(?) know sth. like System.IoUtils.TDirectory... ---------------------------------------------------------------------- TRon · 2024-02-27 19:45 Quote from: AxBen on February 27, 2024, 08:33:18 pmI guess this might be a compiler installation problem on my side. Could be, though the error message itself is strange if it would to be the case. Better get that sorted first  QuoteOn another note: is there an alternative to FindFirst()? I think Delphi/Lazarus(?) know sth. like System.IoUtils.TDirectory... The VCL compatible classes are in the making (you need trunk compiler for that and not everything is implemented (yet)) Lazarus does have a findallfiles function that does the hard work for you but not sure if that is something you had in mind. ---------------------------------------------------------------------- KodeZwerg · 2024-02-27 20:11 Quote from: AxBen on February 27, 2024, 08:33:18 pm@TRon, cdbc QuoteThat implies that there is no need to be explicit. This is correct. Replaced UnicodeString with String, but sadly the error remains. I guess this might be a compiler installation problem on my side. I will probably need to get that straight first (cmp https://forum.lazarus.freepascal.org/index.php/topic,66404.0.html)... On another note: is there an alternative to FindFirst()? I think Delphi/Lazarus(?) know sth. like System.IoUtils.TDirectory... Try if your version has unit "FileUtil" or "FileUtils" available, in there are some methods for different things. I am not aware about FPC highter than stable. ---------------------------------------------------------------------- AxBen · 2024-02-28 16:10 Meanwhile I managed to compile fpx/ppcrossx64 3.3.1 and now the source compiles w/o. errors. Thx for your support!