Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug in LastStringS?

2 views
Skip to first unread message

Eric Buescher

unread,
Dec 26, 2002, 3:02:52 PM12/26/02
to
Please take a look at your code for StStrS.LastStringS. I am using Systools
4.02.

Below is the code w/ the fixes I made.
TmpStr := S;
C := 0;
I := Pos(AString, TmpStr);
while (I > 0) do begin
// Inc(C, I + Length(AString));
Inc(C, I + Length(AString)-1); // <------- fixed by edb
// System.Delete(TmpStr, 1, I + Length(AString));
System.Delete(TmpStr, 1, I + Length(AString)-1); // <----- fixed by edb
I := Pos(AString, TmpStr);
end;
{Go back the length of AString since the while loop deletes the last
instance}
// Dec(C, Length(AString));
Dec(C, Length(AString)-1); // <----- fixed by edb
Position := C;
Result := True;

The problem surfaced when I was looking for a string of length 1. The
original code may have worked fine for strings longer than 1 character, but
I didn't test that.

Eric


0 new messages