Auf der Suche nach Text in irgendeinem Teil eines Feldes
Eine Funktion zum Text teilweise von Feldinhalten jedes Dataset durchsuchen
Auf der Suche nach Text in irgendeinem Teil eines Feldes
Die folgende Funktion sucht Text in irgendeinem Teil eines Feldes alle Datasets (es kann z.B. sein, nachrüstbar, TQuery, TADOTable, TADOQuery, TIBTable, TIBQuery, etc..)
type
TLocateStrOption = (loCaseSensitive, loContinue);
TLocateStrOptions = set of TLocateStrOption;
function LocateStr(Dataset: TDataset; Field: TField; Str: String;
LocateOptions: TLocateStrOptions): boolean;
// Searches text in any part of a dataset field. The search can be
// case sensitive (option loCaseSensitive) and can start from the
// beginning or from the current record (option loContinue).
//
// Returns True if the string was found (the dataset is positioned
// in that record) and False otherwise (the dataset is left in EOF)
var
ControlsDisabled: boolean;
begin
ControlsDisabled := Dataset.ControlsDisabled;
if not ControlsDisabled then Dataset.DisableControls;
try
if loContinue in LocateOptions then begin
if not Dataset.Eof then Dataset.Next;
end else
Dataset.First; // Start from the beginning
if not (loCaseSensitive in LocateOptions) then
Str := UpperCase(Str);
while not Dataset.Eof do begin
if loCaseSensitive in LocateOptions then begin
if Pos(Str, Field.AsString) <> 0 then break;
end else begin
if Pos(Str, UpperCase(Field.AsString)) <> 0 then break;
end;
Dataset.Next;
end;
Result := Dataset.Eof;
finally
if not ControlsDisabled then Dataset.EnableControls;
end;
end;
Auf der Suche nach Text in irgendeinem Teil eines Feldes
Auf der Suche nach Text in irgendeinem Teil eines Feldes : Mehreren tausend Tipps, um Ihr Leben einfacher machen.
Eine Funktion zum Text teilweise von Feldinhalten jedes Dataset durchsuchen
Auf der Suche nach Text in irgendeinem Teil eines Feldes
Die folgende Funktion sucht Text in irgendeinem Teil eines Feldes alle Datasets (es kann z.B. sein, nachrüstbar, TQuery, TADOTable, TADOQuery, TIBTable, TIBQuery, etc..)
type
TLocateStrOption = (loCaseSensitive, loContinue);
TLocateStrOptions = set of TLocateStrOption;
function LocateStr(Dataset: TDataset; Field: TField; Str: String;
LocateOptions: TLocateStrOptions): boolean;
// Searches text in any part of a dataset field. The search can be
// case sensitive (option loCaseSensitive) and can start from the
// beginning or from the current record (option loContinue).
//
// Returns True if the string was found (the dataset is positioned
// in that record) and False otherwise (the dataset is left in EOF)
var
ControlsDisabled: boolean;
begin
ControlsDisabled := Dataset.ControlsDisabled;
if not ControlsDisabled then Dataset.DisableControls;
try
if loContinue in LocateOptions then begin
if not Dataset.Eof then Dataset.Next;
end else
Dataset.First; // Start from the beginning
if not (loCaseSensitive in LocateOptions) then
Str := UpperCase(Str);
while not Dataset.Eof do begin
if loCaseSensitive in LocateOptions then begin
if Pos(Str, Field.AsString) <> 0 then break;
end else begin
if Pos(Str, UpperCase(Field.AsString)) <> 0 then break;
end;
Dataset.Next;
end;
Result := Dataset.Eof;
finally
if not ControlsDisabled then Dataset.EnableControls;
end;
end;
Auf der Suche nach Text in irgendeinem Teil eines Feldes
By Wiezutun
Auf der Suche nach Text in irgendeinem Teil eines Feldes : Mehreren tausend Tipps, um Ihr Leben einfacher machen.