[fpc-pascal]problem with POS in ansistrings

Kanzelsberger Pavel kanzelsberger at rekt.umb.sk
Tue Jul 3 15:57:38 CEST 2001


I think you have to define variables in function as ansistrings too...

function string_replace(co,za_co,kde:ansistring):ansistring;
var s,co1:ansistring;
 .
 .
 .

regards, Pavel Kanzelsberger

-----Original Message-----
From: Martin Hankovec [mailto:Martin.Hankovec at oku-st.cz]
Sent: Tuesday, July 03, 2001 2:01 PM
To: fpc-pascal at lists.freepascal.org
Subject: [fpc-pascal]problem with POS in ansistrings


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.


_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20010703/056ff016/attachment.html>


More information about the fpc-pascal mailing list