<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=WINDOWS-1250">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [fpc-pascal]problem with POS in ansistrings</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>I think you have to define variables in function as ansistrings too...</FONT>
</P>
<P><FONT SIZE=2>function string_replace(co,za_co,kde:ansistring):ansistring;</FONT>
<BR><FONT SIZE=2>var s,co1:ansistring;</FONT>
<BR><FONT SIZE=2> .</FONT>
<BR><FONT SIZE=2> .</FONT>
<BR><FONT SIZE=2> .</FONT>
</P>
<P><FONT SIZE=2>regards, Pavel Kanzelsberger</FONT>
</P>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Martin Hankovec [<A HREF="mailto:Martin.Hankovec@oku-st.cz">mailto:Martin.Hankovec@oku-st.cz</A>]</FONT>
<BR><FONT SIZE=2>Sent: Tuesday, July 03, 2001 2:01 PM</FONT>
<BR><FONT SIZE=2>To: fpc-pascal@lists.freepascal.org</FONT>
<BR><FONT SIZE=2>Subject: [fpc-pascal]problem with POS in ansistrings</FONT>
</P>
<BR>
<P><FONT SIZE=2>Hello all,</FONT>
<BR><FONT SIZE=2>I have the problem:</FONT>
<BR><FONT SIZE=2>if I use the function POS in ansistring, it finds the substring in first</FONT>
<BR><FONT SIZE=2>255 characters. The others occurences (after 255) cannot be found.</FONT>
<BR><FONT SIZE=2>Compiler version 1.0.2, 1.0.4 works in the same manner.</FONT>
</P>
<P><FONT SIZE=2>Can anybody give an idea how to search in the whole ansistring?</FONT>
</P>
<P><FONT SIZE=2>------</FONT>
<BR><FONT SIZE=2>Example - function for replacing string "co" in string "kde" (simply search</FONT>
<BR><FONT SIZE=2>for strin and replaces it with other):</FONT>
</P>
<P><FONT SIZE=2>function string_replace(co,za_co,kde:string):string;</FONT>
<BR><FONT SIZE=2>var i,delka:longint;</FONT>
<BR><FONT SIZE=2> s,co1:string;</FONT>
<BR><FONT SIZE=2>begin</FONT>
<BR><FONT SIZE=2> s:=kde;</FONT>
<BR><FONT SIZE=2> co1:=upcase(co);</FONT>
<BR><FONT SIZE=2> delka:=length(co);</FONT>
<BR><FONT SIZE=2> i:=pos(co1,upcase(s));</FONT>
<BR><FONT SIZE=2> while i>0 do begin</FONT>
<BR><FONT SIZE=2> delete(s,i,delka);</FONT>
<BR><FONT SIZE=2> insert(za_co,s,i);</FONT>
<BR><FONT SIZE=2> i:=pos(co1,upcase(s));</FONT>
<BR><FONT SIZE=2> end;</FONT>
<BR><FONT SIZE=2> string_replace:=s;</FONT>
<BR><FONT SIZE=2>end;</FONT>
</P>
<P><FONT SIZE=2>All strings are of course previously defined as ansistrings.</FONT>
<BR><FONT SIZE=2>If I call this function to replace in long ansistring (1800 chars), only</FONT>
<BR><FONT SIZE=2>occurences to 255 character will be replaced.</FONT>
</P>
<P><FONT SIZE=2>Thanks for advice.</FONT>
</P>
<P><FONT SIZE=2>Martin H.</FONT>
</P>
<BR>
<P><FONT SIZE=2>_______________________________________________</FONT>
<BR><FONT SIZE=2>fpc-pascal maillist - fpc-pascal@lists.freepascal.org</FONT>
<BR><FONT SIZE=2><A HREF="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" TARGET="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</A></FONT>
</P>
</BODY>
</HTML>