On 6 mrt 2004, at 07:56, Jeff Pohlmeyer wrote:


function PosFrom( const needle:AnsiString; const haystack:AnsiString;
                  StartPt:LongInt):LongInt;
var
  p:pChar;
begin
  Result:=0;
  if (StartPt <= Length(haystack))
  then begin
    p:=StrPos(pChar(@haystack[StartPt]), pChar(needle));
    if ( p <> nil ) then Result:= ( p - @haystack[1] ) + 1;
  end
end;

Note that this indeed will only work with ansistrings, as shortstrings are not null-terminated (which strpos expects). Of course, you can pass shortstrings to this routine and they will be converted to ansistrings on the fly, but that will more than negate any possible speed gains you could expect over using the plain "pos" function.



Jonas



_______________________________________________ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to