Autor Beitrag
pascalsv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133

Win XP Prof. SP2 / Windows 7
Visual Studio 2008 / Silverlight 3 / Silverlight 4 Beta
BeitragVerfasst: Sa 05.08.06 14:38 
Hallo zusammen,

ich habe hier folgenden Such-Thread, bei dessen Kompilierung der Fehler: "Tatsächliche und formale Var-Parameter müssen überein stimmen" auftaucht. Ich weiß aber nicht, warum und was ich ändern muss.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
unit uSuchThread;

...

implementation


procedure TSuchThread.execute;
begin
 while not Terminated do begin
  FileSearch('C:\Dokumente und Einstellungen\Pascal\Desktop\ABBA\''*.mp3');
 end;

end;

procedure TSuchThread.FileSearch(const Path, FileName : string);
var Rec  : TSearchRec;
begin
  if FindFirst (Path + FileName, faAnyFile - faDirectory, Rec) = 0 then  //hier tritt der Fehler auf!!!
    try
      repeat
        mp3Liste.Items.Add(Path + Rec.Name);
      until FindNext(Rec) <> 0;
    finally
      FindClose(Rec);
      bStartButton.Enabled := true;
    end;
end;

end.


Weiß jemand Rat, bitte?

Danke & Gruß,

Pascal


Moderiert von user profile iconGausi: Topic aus Sonstiges (Delphi) verschoben am Sa 05.08.2006 um 14:57
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Sa 05.08.06 14:44 
Versuchs mal mit:
ausblenden Delphi-Quelltext
1:
2:
pfad := Path + FileName;
if FindFirst ( pfad, ...

_________________
Markus Kinzler.
pascalsv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133

Win XP Prof. SP2 / Windows 7
Visual Studio 2008 / Silverlight 3 / Silverlight 4 Beta
BeitragVerfasst: Sa 05.08.06 14:47 
Hallo mKinzler, leider nicht, das hatte ich auch schon probiert. Habe sogar das "- faDirectory" versuchshalber weggelassen...

:(

Pascal
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Sa 05.08.06 14:52 
Ich würde mal sagen, Der Compiler nimmt das FindFirst aus Windows.pas. Gib mal explizit SysUtils.Findfrst(...) an.

Du könntest auch mal deine Uses-Klausel sortieren. Windows sollte vor SysUtils stehen, da ja von hinten abgearbeitet wird.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Sa 05.08.06 14:55 
Komisch, sollte eigentlich funktionieren.

BTW. es müßte faAnyFile + faDirectory heißen.

_________________
Markus Kinzler.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8549
Erhaltene Danke: 478

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 05.08.06 14:56 
FindFirst hat als ersten Parameter ein PChar, keinen String. Wenn man nur etwas wie 'meinstring' hat, dann akzeptiert der Compiler das meistens, aber sobald man mit Variablen und + arbeitet, muss man explizit eine Typumwandlung angeben:
ausblenden Delphi-Quelltext
1:
FindFirst (Pchar(Path + FileName), faAnyFile - faDirectory, Rec) = 0					

_________________
We are, we were and will not be.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Sa 05.08.06 15:01 
Bei mir nicht
Delphi-Hilfe hat folgendes geschrieben:
function FindFirst(const Path: string; Attr: Integer; var F: TSearchRec): Integer;

[Edit es gibt 2 verschiedene Implementation von diese Funktion, wie Martok schon erwähnt hat, eine in Windows und eine in SysUtils. Es scheint so als ob Borland die 2. eingeführt hat, um das manuelle Casten nach PChar zu umgehen.

_________________
Markus Kinzler.
pascalsv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133

Win XP Prof. SP2 / Windows 7
Visual Studio 2008 / Silverlight 3 / Silverlight 4 Beta
BeitragVerfasst: Sa 05.08.06 15:38 
Hallo zusammen,

ist das kompliziert...

Ich habe das Problem gefunden. Es lag an meiner Definition von TSearchRec. Ich hatte diese Definition vor implementation eingefügt, aber das geht wohl nicht so...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
type
TSearchRec = record
  Time: Integer;
  Size: Integer;
  Attr: Integer;
  Name: TFileName;
  ExcludeAttr: Integer;
  FindHandle: THandle;
  FindData: TWin32FindData;
end;

implementation


Pascal


Zuletzt bearbeitet von pascalsv am Sa 05.08.06 15:55, insgesamt 1-mal bearbeitet
Grenzgaenger
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 05.08.06 15:54 
nicht getestet, aber schreib doch mal "faAnyFile - [faDirectory]", so weit ich mich erinnere ist dies eine mengenoperation, hab aber damit schon ewig nichts mehr gemacht.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Sa 05.08.06 15:58 
user profile iconGrenzgaenger hat folgendes geschrieben:
nicht getestet, aber schreib doch mal "faAnyFile - [faDirectory]", so weit ich mich erinnere ist dies eine mengenoperation, hab aber damit schon ewig nichts mehr gemacht.
Nein es ist ein Integer und deshlab muß die muß man die Konstanten addieren addieren. Aber user profile iconpascalsv hat seinen Fehler ja jetzt gefunden ;-)

_________________
Markus Kinzler.
pascalsv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133

Win XP Prof. SP2 / Windows 7
Visual Studio 2008 / Silverlight 3 / Silverlight 4 Beta
BeitragVerfasst: Sa 05.08.06 16:05 
Hallo zusammen.

Vielen Dank für Eure Hilfe!! Da programmiert man für einige Jahre nicht und schon ist das alte Wissen weg... :roll:

Pascal