Autor Beitrag
hanibal
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 157

Win xp
d7 eterprise
BeitragVerfasst: Fr 01.12.06 15:39 
Wie kann ich meine suchfunktionen so Umändern, das mann "or", "and", "+", "-" und """(gänsefüß)" als parameter verwänden kann?

mein jetzliger such code:
ausblenden volle Höhe 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:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
Procedure FindFiles (aPath, aFindMask: String; aWithSub: Boolean; aResult: tStrings; bResult: tStrings);
Var
  FindRec: tSearchRec;
Begin
  // Wenn die Stringliste nil ist oder aPath oder aFind nicht angegeben ist
  // dann raus
  If (aPath = '') or (aFindMask = '') or Not Assigned (aResult) Then
    Exit;


  // Wenn am Ende der Pfadangabe noch kein \ steht, dieses hinzufügen
  If aPath[Length (aPath)] <> '\' Then
    aPath := aPath + '\';

 
  // Im aktuellen Verzeichnis nach der Datei suchen
  If FindFirst (aPath + aFindMask, faAnyFile, FindRec) = 0 Then
    Repeat
      If (FindRec.Name <> '.') and (FindRec.Name <> '..') Then  
        // ...Ergebnis in die Stringlist einfügen
        aResult.Add (FindRec.Name);
        bResult.Add(aPath);

    Until FindNext (FindRec) <> 0;


  FindClose (FindRec);  


  // Wenn nicht in Unterverzeichnissen gesucht werden soll dann raus
  If Not aWithSub Then  
    Exit;


  // In Unterverzeichnissen weiter suchen  
  If FindFirst (aPath + '*.*', faAnyFile, FindRec) = 0 Then
    Repeat
      If (FindRec.Name <> '.') and (FindRec.Name <> '..') Then
        // Feststellen, ob es sich um ein Verzeichnis handelt  
        If Boolean (FindRec.Attr and faDirectory) Then
          // Funktion erneut aufrufen, um Verzeichnis zu durchsuchen (Rekursion)
          FindFiles (aPath + FindRec.Name, aFindMask, aWithSub, aResult,bresult);
    Until FindNext (FindRec) <> 0;


   FindClose (FindRec);
End;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Fr 01.12.06 16:11 
Moin!

Mach mal ein Beispiel, was du da suchen willst... :gruebel: ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
hanibal Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 157

Win xp
d7 eterprise
BeitragVerfasst: Fr 01.12.06 21:13 
z.b. "interpret1 or interpret2 "tolles lied""

so intetwa solte ne such anfrage aussehen.
fidionael
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 232

Win XP SP2, Ubuntu 6.06
Delphi 7 PE, Delphi 3 Prof
BeitragVerfasst: Sa 02.12.06 01:28 
Was du beschreibst, umreißt im Wesentlichen das Problem des Parsings, d.h. des Interpretieren von Daten. Was du da mit wenigen Worten beschreibst und dir vermutlich sehr einfach vorstellst, kann beliebig komplex werden.

Deine Suchzeile muss, wenn du and und or und evtl. auch noch andere Begriffe verwenden willst, nach diesen Begriffen durchsucht werden und du musst dir merken, in welchem Zusammenhang der Kontext steht. Du solltest dir eine logische Struktur überlegen, nach welcher dein Text geparst wird.

Was dir in der Erarbeitungsphase auf jeden Fall hilfreich seien sollte, sind String-Such- und Modifizierungsbefehle, wie Pos('suchtext',buffer); oder auch Copy(buffer,start,ende);. Wenn konkrete Fragen beim Erstellen deines Parsers auftreten sollten, helfe ich dir gerne, aber da du dich anscheinend diesbezüglich im Moment noch in der Anfangsphase befindest, solltest du dich erstmal ein wenig in die Materie einarbeiten.

Ich kann auch empfehlen mal einen Blick in diesen Thread zu werfen: dort habe ich mit user profile iconecspooky einen Parser entwickelt (und dieser ist immer noch nicht zu 100% abgeschlossen) und die diversen Probleme und ihre Lösungen kommen recht gut zur Geltung.

Viel Erfolg!
hanibal Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 157

Win xp
d7 eterprise
BeitragVerfasst: Sa 02.12.06 14:09 
das hört sich ja sau komplizirt an, ich glaube das übersteigt meine delphi kenttnisse :oops:

gibt es da nicht irgend welche fertigen units?
Pepe
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 107

Win 98, Win 2000 Prof., Win XP Prof.
Delphi 2005 Prof.
BeitragVerfasst: So 03.12.06 13:38 
hanibal Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 157

Win xp
d7 eterprise
BeitragVerfasst: Di 05.12.06 22:52 
damit werden aber strings durucht, ich mss aber di festpladde durschuchen :-(
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 05.12.06 23:24 
Moin!

Dateinamen sind doch Strings... ? ;) Oder willst du den Dateiinhalt untersuchen?! :gruebel:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Pepe
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 107

Win 98, Win 2000 Prof., Win XP Prof.
Delphi 2005 Prof.
BeitragVerfasst: Mi 06.12.06 16:33 
und wenn, datei öffnen, in einen string/ eine stringlist umwandeln und die funktion darauf anwenden :)
coder62
Hält's aus hier
Beiträge: 29



BeitragVerfasst: Mi 06.12.06 17:06 
hanibal Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 157

Win xp
d7 eterprise
BeitragVerfasst: Fr 08.12.06 14:24 
wie kann ich diese string suche denn auf eine datei suche anwenden?

ps: ich will den inhalt nicht durchsuchen
hanibal Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 157

Win xp
d7 eterprise
BeitragVerfasst: So 10.12.06 21:00 
nach oben schieb
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 10.12.06 21:22 
1. fehlt in dem von dir geposteten Suchquelltext ein begin..end (das If (FindRec.Name <> '.') and (FindRec.Name <> '..') Then gilt nur für den direkt folgenden Befehl statt für die beiden nächsten.

2. kannst du dort ja den Dateinamen nur hinzufügen, wenn du deine Suchkriterien in diesem Dateinamen bestätigt findest.
hanibal Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 157

Win xp
d7 eterprise
BeitragVerfasst: Mo 11.12.06 17:01 
also sollte man nach "*" suchen, und dann die daraus ergebenden daten damit vergleichen?