2009. július 17., péntek

Find a word in an Array of String


Problem/Question/Abstract:

How to find a word in an Array of String

Answer:

{ ... }
const
  StringsToSearch: array[0..7] of string = ('hello', 'earth', 'why', 'this', '12',
    'people', 'how', 'what');
var
  Found: Boolean;
  i: Integer;
begin
  Found := False;
  for i := 0 to 7 do
    if Pos(StringsToSearch[i], ALongLongLongString) > 0 then
    begin
      Found := True;
      break;
    end;
  if Found then
    ShowMessage('At least one word was found')
  else
    ShowMessage('No words found');
end;

Nincsenek megjegyzések:

Megjegyzés küldése