2007. augusztus 13., hétfő

How to do a text search in a TMemoField


Problem/Question/Abstract:

How to do a text search in a TMemoField

Answer:

Here is an example of how to search a memo field. The field skills is a memo field:

procedure tdmdistbt.ANDFindSkills(SkillList, PeopleList: TStrings);
var
  I, h, foundcount: Integer;
  Skills: string;
begin
  peoplelist.clear;
  with tblTeamMember do
  begin
    first;
    for I := 1 to recordcount do
    begin
      foundcount := 0;
      Skills := uppercase(tblTeamMember.fieldbyname('Skills').asstring);
      for h := 0 to skilllist.count - 1 do
      begin
        if Pos(uppercase(Skilllist[h]), Skills) > 0 then
          inc(foundcount, 1);
      end;
      if foundcount = skilllist.count then
        PeopleList.add(tblTeamMemberFullName.value);
      next;
    end;
  end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése