[fpc-pascal]problem with POS in ansistrings

Martin Hankovec Martin.Hankovec at oku-st.cz
Tue Jul 3 14:01:08 CEST 2001


Hello all,
I have the problem:
if I use the function POS in ansistring, it finds the substring in first
255 characters. The others occurences (after 255) cannot be found.
Compiler version 1.0.2, 1.0.4 works in the same manner.

Can anybody give an idea how to search in the whole ansistring?

------
Example - function for replacing string "co" in string "kde" (simply search
for strin and replaces it with other):

function string_replace(co,za_co,kde:string):string;
var i,delka:longint;
    s,co1:string;
begin
  s:=kde;
  co1:=upcase(co);
  delka:=length(co);
  i:=pos(co1,upcase(s));
  while i>0 do begin
    delete(s,i,delka);
    insert(za_co,s,i);
    i:=pos(co1,upcase(s));
  end;
  string_replace:=s;
end;

All strings are of course previously defined as ansistrings.
If I call this function to replace in long ansistring (1800 chars), only
occurences to 255 character will be replaced.

Thanks for advice.

Martin H.





More information about the fpc-pascal mailing list