Code:
//Inf=Delphi32 - PosEx or system.pos wiht position
Function Sho_PosInt(substr : ShortString;StartIndex:Integer;Const largeString : String;LimMax:Integer): Integer;
Var nlen,nth:Integer;
Begin Result:=RTCAN;
if (length(LargeString)<1) then exit;
Result:=RTREJ;
if (length(substr)<1) then exit;
if (StartIndex<1) then StartIndex:=1 else
if (StartIndex>length(LargeString)) then
StartIndex:=1;
if (LimMax<1) then LimMax:=kMaxInt;
nth:=pos(substr,copy(LargeString,StartIndex,LimMax));
result:=if_int(nth<1,0,StartIndex+nth);
End; |