Icon View Incident Report

Serious Serious
Reported By: Stephen Brooks
Reported On: 5/31/2004
For: Version 4.07 Build 1
# 1742 FindFirst and FindNext Methods Not Working Properly

A table and a list view which is populated by interating over a FindFirst/FindNext loop.

It works fine on 4.05. On 4.07 the filter is having no effect.

To use it:

Set up the database directory to be whatever you fancy.

Run the program.

Leave the text edit empty for now.

Hit the Fill button. This will add some random words to the table.

Now enter something into the text edit (e.g. A* to find all words beginning
with "A") and click Filter.

const
    cNames: array[0..25] of String = (
        'Alpha', 'Bravo', 'Charlie', 'Delta',
        'Echo', 'Foxtrot', 'Gamma',
        'Hotel', 'India', 'Julliet',
        'Kilo', 'Lima', 'Mike', 'November',
        'Oscar', 'Papa', 'Quebec', 'Romeo',
        'Sierra', 'Tango', 'Uniform',
        'Victor', 'Whiskey', 'Xray', 'Yankee',
        'Zulu');

procedure TForm1.GenValues(ANumber: Integer);
var
    lIndex: Integer;
    i: Integer;
begin
    for i := 0 to ANumber - 1 do begin
        with tblTest do begin
            Append;
            try
                lIndex := Random(26);
                Fields.Fields[1].AsString := cNames[lIndex];
                Post;
            except
                Cancel;
                raise;
            end;
        end;
    end;
end;

procedure TForm1.UpdateLV;
var
    lNameFilter: String;
    lListItem: TListItem;
    lFound: Boolean;
begin
    LV.Items.BeginUpdate;
    try
        LV.Clear;
        lNameFilter := Trim(edNameFilter.Text);
        with tblTest do begin
            if (Length(lNameFilter) = 0) then begin
                First;
                while not Eof do begin
                    lListItem := LV.Items.Add;
                    lListItem.Caption :=
                      IntToStr(Fields.Fields[0].AsInteger);
                    lListItem.SubItems.Add(
                      Fields.Fields[1].AsString);
                    Next;
                end;
            end
            else begin
                Filter := 'Name = ' +
                          QuotedStr(edNameFilter.Text);
                FilterOptions := [foCaseInsensitive];
                lFound := FindFirst;
                while lFound do begin
                    lListItem := LV.Items.Add;
                    lListItem.Caption :=
                      IntToStr(Fields.Fields[0].AsInteger);
                    lListItem.SubItems.Add(
                      Fields.Fields[1].AsString);
                    lFound := FindNext;
                end;
            end;
        end;
    finally
        LV.Items.EndUpdate;
    end;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
    Randomize;
    if not tblTest.Exists then
        tblTest.CreateTable;
    tblTest.Open;
    UpdateLV;
end;

procedure TForm1.btnFillClick(Sender: TObject);
begin
    GenValues(20);
    UpdateLV;
end;

procedure TForm1.btnFilterClick(Sender: TObject);
begin
    UpdateLV;
end;



Resolution Resolution
Fixed Problem on 5/31/2004 in version 4.08 build 1
Image