Hi,
How can i add to a string at the end of the string a extra a word
the code
cr=num2char(13)
lf=num2char(10)
sss="test"
string="aaaaaaaaaaaaaaa%cr%%lf%
aaaaaaaaaaaaaaaa%cr%%lf%
aaaaaaaaaaaaaaaa%cr%%lf%"
sss=strcat(" ","- ",sss," "," ",@CRLF)
record1 = StrReplace(record1,@CRLF,sss)
the output:
test
aaaaaaaaaaaaa test
aaaaaaaaaaaaa test
but the output must be:
aaaaaaaaaaaaa test
aaaaaaaaaaaaa test
What I am doing wrong.
The most obvious answer would be that you have a leading carriage-return plus line-feed in your "record1" variable. If this is the case, you need to do something like the following before you perform a your StrReplace:
while 1
record1 = StrTrim(record1, 1)
nPos = StrScan(record1, @Crlf, 1, @Fwdscan)
if nPos == 1 then record1 = StrSub(record1, 3, -1)
else break
endwhile
Of course, it could also be that you have an extra carriage-return plus line-feed at the end of a record. If that is the case, you may be better off simply removing all duplicate carriage-return plus line-feeds. It would depend on your goals.
thx
that was the trick