Weil es lustig aussieht und ich zu so späten Stunde noch logische Gedanken fassen kann:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
a, b, c, d, x: string;
r: Boolean;
begin
x := '1234';
a := '1';
b := '2';
c := '3';
d := '4';
r := True;
r := r and ((Length(a) = 0) or ((Length(a) > 0) and (Pos(a, x) > 0)));
r := r and ((Length(b) = 0) or ((Length(b) > 0) and (Pos(b, x) > 0)));
r := r and ((Length(c) = 0) or ((Length(c) > 0) and (Pos(c, x) > 0)));
r := r and ((Length(d) = 0) or ((Length(d) > 0) and (Pos(d, x) > 0)));
i := 0;
if Length(a) > 0 then Inc(i);
if Length(b) > 0 then Inc(i);
if Length(c) > 0 then Inc(i);
if Length(d) > 0 then Inc(i);
r := r and (i > 0);
ShowMessage(BoolToStr(r));
Edit:
Zwar nicht wichtig, aber da oben ist einiges doppelt gemoppelt. Geht auch kürzer:
Delphi-Quellcode:
r := True;
r := r and ((Length(a) = 0) or (Pos(a, x) > 0));
r := r and ((Length(b) = 0) or (Pos(b, x) > 0));
r := r and ((Length(c) = 0) or (Pos(c, x) > 0));
r := r and ((Length(d) = 0) or (Pos(d, x) > 0));