Hello Task,

Get this code, it's from my plugin ;-)

I have all the the checkings in one module.
I have translated the code, it could be one typo with some thing ;-)

Function IsSeparator(const txt: String; pos: Integer): Boolean;
const
  Separator  : Array [0..26] of Char = (' ', '.', ',', ':', '!', '�', #39, #34, '&', 
'%', '$', '/', '\', '*', '#', '?', '�', '(', ')', '{', '}', '[', ']', '<', '>', '_', 
'-');
var
  ret : Boolean;
  i   : Integer;
  
Begin
   ret:= False;

   If pos > Length(txt) Then
      ret:= True
   Else
   If pos <= 0 Then
      ret:= True
   Else
   Begin
       // Start of the vector
       i:= 0;

       // While I have separators and I don't found it
       While (i <= 26) And (ret = False) do
       Begin
          If Copy(txt, pos, 1) = Separator[i] Then
             ret:= True;

          inc(i);
       end;
   end;

   Result:= ret;
end;


// maymin -> case sensitive ?
// orig -> string to do the search (in original format)
// origUp -> string to do the search (in Uppercase)
// txt -> string to search
// num -> number to add if it's found

Function ContainsWord(const maymin: Boolean; const orig: String; const origUp: String;
                      const txt: String; const num: Integer): Integer;
var
   p : Integer;
Begin
   Result:= 0;
   if maymin then
   Begin
      p:= Pos(txt, orig);
      If p > 0 then
         If IsSeparator(orig, p-1) and ( Copy(orig, p, length(txt)) = txt )
                                  and IsSeparator(orig, p + length(txt) ) then
            Result:= num;
   end
   else
   Begin
      p:= Pos(UpperCase(txt), origUp);
      If p > 0 then
         If EsSeparator(orig, p-1) and ( Copy(orig, p, length(txt)) = UpperCase(txt) )
                                  and EsSeparator(orig, p + length(txt) ) then
         Result:= num;
   end;
end;

El jueves, 20 feb 2003 a las 23:29, escribiste:

>   well i have a question, i use a simple algorith to know if a word is
>   a  complete  word,  for example i search the complete word "lion" in
>   "animals: lion, cat, dog, mule"


-----------------------
   ........................
  /\    /
 /  \  /     \  /
/    \/ e t   \/ i c i o u s
   ........................

Using The Bat! 1.63 Beta/5 on Windows XP (5.1.2600 Service Pack 1)


________________________________________________
Current version is 1.62 | "Using TBDEV" information:
http://www.silverstones.com/thebat/TBUDLInfo.html

Reply via email to