Mit etwas Source sieht's so aus:
Statische Suche nach bestimmten Strings
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| Function IsStringListed(AStr:String): Boolean; Var SL: TStringList; begin SL := TStringList.Create; try SL.Text := 'String 1'#13#10'String 2'#13#10'Was anderes'#13#10'Noch was'#13#10'...'; Result := SL.IndexOf(AStr) <> -1; finally FreeAndNil(SL); end; end; |
Mit dynamik sähe das ganze dann z.B. so aus:
Dynamische Suche nach bestimmten Strings
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| Function IsStringListed(AStr, AList:String): Boolean; Var SL: TStringList; begin SL := TStringList.Create; try SL.Text := AList; Result := SL.IndexOf(AStr) <> -1; finally FreeAndNil(SL); end; end; |
@Source 1: Die markierte Stelle ist die eigentliche Abfrage. Das andere ist nur Vorgeplänkel ...
@Source 2: Die dynamische Zuweisung. Format für AList ist genauso, wie in der ersten Variante.
//Edit: Syntaxfehler in Delphi-Blöcken korrigiert.
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.