BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

StringReplace?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop)
View previous topic :: View next topic  
Author Message
Thor Warberg
Guest





PostPosted: Mon Oct 27, 2003 3:13 pm    Post subject: StringReplace? Reply with quote



I want to writeLn a table's memofield with linebreaks <BR> into a
html-file.
Code below does not work.
Any suggestions?
Regards,
Thor

*****************
strng:=table21.fields[5].AsString;
try
if Length(strng) > 0 then
begin
for n := 0 to Length(strng)-1 do
StringReplace(strng[n], #10,'<BR>',[rfReplaceAll,rfIgnoreCase]);

end;
finally
end;
****************


--
With licence to ask.
Heimesida mi (ny bygdebok for Ål i Hallingdal/local genealogy )
http://www.aal-bygdebok.no


Back to top
John Herbster (TeamB)
Guest





PostPosted: Mon Oct 27, 2003 4:59 pm    Post subject: Re: StringReplace? Reply with quote




"Thor Warberg" <twarberg (AT) online (DOT) no> wrote
Quote:
... Code below does not work. ...

Thor, First this should have be asked in the forum
borland.public.delphi.language.objectpascal.

Have you tried this straight forward code?
StringReplace(strng, #10,'<BR>',[rfReplaceAll,rfIgnoreCase]);

Are you sure that the #10 is the line-break character in
your code? What about #13? Rgds, JohnH

Back to top
Bill Todd
Guest





PostPosted: Mon Oct 27, 2003 5:47 pm    Post subject: Re: StringReplace? Reply with quote



Quote:
Are you sure that the #10 is the line-break character in
your code? What about #13? Rgds, JohnH

If it is a normal Windows ASCII text file each line will end with
#13#10. You may want to replace both.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Back to top
Thor Warberg
Guest





PostPosted: Mon Oct 27, 2003 9:44 pm    Post subject: Re: StringReplace? Reply with quote


"John Herbster (TeamB)" wrote:

Quote:
"Thor Warberg" <twarberg (AT) online (DOT) no> wrote
... Code below does not work. ...

Thor, First this should have be asked in the forum
borland.public.delphi.language.objectpascal.

Have you tried this straight forward code?
StringReplace(strng, #10,'<BR>',[rfReplaceAll,rfIgnoreCase]);

Hello John.

Yes, I have tried that too. With no result.
No I am about to tear my hair ..
Remember those days of OPAL when this
was like:
WHILE text.Match(".."+CHR(10)+"...", f2, f3
text= "<BR>"

Thor



--
With licence to ask.
Heimesida mi (ny bygdebok for Ål i Hallingdal/local genealogy )
http://www.aal-bygdebok.no



Back to top
Bill Todd
Guest





PostPosted: Mon Oct 27, 2003 10:56 pm    Post subject: Re: StringReplace? Reply with quote

Are you saying that the call to StringReplace does not change
anything? Have you confirmed that the string does contain a line feed
(#10)?


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Back to top
Thor Warberg
Guest





PostPosted: Tue Oct 28, 2003 5:47 am    Post subject: Re: StringReplace? Reply with quote


Bill Todd wrote:

Quote:
Are you saying that the call to StringReplace does not change
anything? Have you confirmed that the string does contain a line feed
(#10)?

Thanks, Bill.
Yes, I know there is #9, #10 and #13 in the memos.
They must be in disguise. (And I soon in despair )

Regards,
Thor
This is how the code runs:

strng:=table21.fields[5].AsString;
StringReplace(strng, #13,'<BR>',[rfReplaceAll,rfIgnoreCase]);

Quote:


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

--
With licence to ask.
Heimesida mi (ny bygdebok for Ål i Hallingdal/local genealogy )
http://www.aal-bygdebok.no



Back to top
Bill Todd
Guest





PostPosted: Tue Oct 28, 2003 4:30 pm    Post subject: Re: StringReplace? Reply with quote

Thor,

I dropped a button on a form and added the following code to the
OnClick event handler.

procedure TForm1.Button1Click(Sender: TObject);
var
S: String;
begin
S := 'aaa' + #13#10 + 'bbb';
ShowMessage(S);
S := StringReplace(S, #13, '<BR>', [rfReplaceAll]);
ShowMessage(S);
end;

This works perfectly for me using D7. What is different about what you
are doing?


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Back to top
Thor Warberg
Guest





PostPosted: Tue Oct 28, 2003 5:43 pm    Post subject: Re: StringReplace? Reply with quote



Bill Todd wrote:

Quote:
Thor,

I dropped a button on a form and added the following code to the
OnClick event handler.

procedure TForm1.Button1Click(Sender: TObject);
var
S: String;
begin
S := 'aaa' + #13#10 + 'bbb';
ShowMessage(S);
S := StringReplace(S, #13, '<BR>', [rfReplaceAll]);
ShowMessage(S);
end;

This works perfectly for me using D7. What is different about what you
are doing?

GREAT.
Guess that will be fine here too. ( In a loop )
Today I got the upgrade for DBISAM, so no I am
going to move to D7.
Thanks a lot, Bill!

Thor

Quote:


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

--
With licence to ask.
Heimesida mi (ny bygdebok for Ål i Hallingdal/local genealogy )
http://www.aal-bygdebok.no



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.