Autor Beitrag
RFZ
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 137

WinME, WinXP, Win2k*, Win98*, Win95*, Win3.11*, DOS* (*VMware)
D4 Prof
BeitragVerfasst: So 02.03.03 13:18 
Hoi,
ich würde gerne möglichst simpel die Unterordner eines festen Ordners auslesen, wie mach ich das?

cu RFZ
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: So 02.03.03 14:43 
vielleicht so?
Dir ist das Verzeichnis welches durchsucht werden soll.
Dir ohne Backslash, ansonsten prüfen

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure AlleVerzeichnisse(Dir:String);
var I:Integer;
    MyTSearchRec: TSearchRec;
begin
  findfirst(Dir+'\*.*',faDirectory,MyTSearchRec);
  while I=0 do begin
    //tuIrgentwasMitdemVerzeichnis
    // Vorsicht . und .. kommen hier auch als Ergebnis!!
    I:= FindNext(MyTSearchRec);
  end;
  FindClose(MyTSeachRec);
end;


Weitere Unterverzeichnisse ? Null Probleme, Rufe die Funktion Rekursiv mit gefundenen Werten aus sich selber wieder auf innerhalb der WhileSchleife.
Grüße
MSCH
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: So 02.03.03 14:44 
Titel: ups
:!: KLEINER FEHLER IM SCRIPT:

begin
I:= findfirst(Dir+'\*.*',faDirectory,MyTSearchRec);
..

ups
MSCH
RFZ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 137

WinME, WinXP, Win2k*, Win98*, Win95*, Win3.11*, DOS* (*VMware)
D4 Prof
BeitragVerfasst: So 02.03.03 14:53 
Hoi, danke :)
Hab den Fehler schon bemerkt und korrigiert.
Dangeschön :)

cu RFZ
RFZ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 137

WinME, WinXP, Win2k*, Win98*, Win95*, Win3.11*, DOS* (*VMware)
D4 Prof
BeitragVerfasst: So 02.03.03 15:07 
Hmmm, ich bekomme aber alle Dateien und Ordner, versteh ich jetzt nicht *g*
Wo kann das Problem liegen?

cu RFZ
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: So 02.03.03 15:09 
Hi,
versuchs mal damit:

Findfirst('*.*',faDirectory and not faAnyFile,MyTSearchRec);

Grüße
MSCH
RFZ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 137

WinME, WinXP, Win2k*, Win98*, Win95*, Win3.11*, DOS* (*VMware)
D4 Prof
BeitragVerfasst: So 02.03.03 15:13 
nö, das geht auch nicht :(
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: So 02.03.03 15:24 
Titel: ***GRÜBEL***
Nanu, :?:
habs ausprobiert - why not? Da scheint ein Bug rumzulungern.
Sei's drum: hier der Code der Funzt, habs grad probiert:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.Button1Click(Sender: TObject);
var SR: TSearchRec;
     I:Integer;
begin
  Memo1.Lines.clear;
  I:= FindFirst('C:\*.*',faAnyFile, SR);
  while I=0 do begin
    if SR.Attr and faDirectory= faDirectory then
      Memo1.Lines.add(SR.Name);
    I:= FindNext(SR);
  end;
  findClose(SR);
end;


CU
MSCH
RFZ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 137

WinME, WinXP, Win2k*, Win98*, Win95*, Win3.11*, DOS* (*VMware)
D4 Prof
BeitragVerfasst: So 02.03.03 15:43 
Dange, jetzt klappts.
Hab aber eine weitere Bildungslücke :)
Ich hab damit Dynamisch ein Items eines Popupmenus erstellt (TMenuItem) und ihnen die Prozedur "pmClick(Sender: TObject)" bei onClick zugewiesen.
Wie kann ich jetzt in dieser Prozedur wieder auf das MenuItem schliessen? Damit hab ich mich noch nie beschäftigt...

cu RFZ
mars
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 238

Debian Woody, Win 2000, Win XP
D7 Ent, Kylix 3
BeitragVerfasst: So 02.03.03 16:36 
Ich denke, du suchst nach Typecasting:
ausblenden Quelltext
1:
2:
3:
(Sender as TMenuItem)
oder
TMenuItem(Sender)
RFZ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 137

WinME, WinXP, Win2k*, Win98*, Win95*, Win3.11*, DOS* (*VMware)
D4 Prof
BeitragVerfasst: So 02.03.03 16:42 
ach, so einfach geh das :D

cu RFZ