Solved

Add a character to a memo.

Posted on 2004-09-18
5
349 Views
Last Modified: 2010-04-05
I have a memo containing HTML code. The first character must be a <.   How can I add a < if it isn't there but not if it is already there?

I use Delphi 6. I need a quick answer so I will give the maximum 500 points.  Thanks for your help.
0
Comment
Question by:rincewind666
  • 4
5 Comments
 
LVL 10

Expert Comment

by:Jacco
Comment Utility
Maybe like this:

if (Memo1.Lines[0]+#32)[1] <> '<' then
  Memo1.Lines[0] := '<' + Memo1.Lines[0];

Regards Jacco
0
 
LVL 10

Accepted Solution

by:
Jacco earned 500 total points
Comment Utility
Or maybe if the first line can be empty or whitespace before is allowed:

for liLine := 0 to Memo1.Lines.Count-1 do
begin
  if Trim(Memo1.Lines[liLine]) > '' then
  begin
    if Trim(Memo1.Lines[liLine][1] <> '<' then
      Memo1.Lines[liLine] := '<' + Memo1.Lines[liLine];
  end;
end;

Regards Jacco
0
 
LVL 10

Expert Comment

by:Jacco
Comment Utility
Type in last comment:

if Trim(Memo1.Lines[liLine][1] <> '<' then
should read
if Trim(Memo1.Lines[liLine])[1] <> '<' then

0
 

Author Comment

by:rincewind666
Comment Utility
Many thanks for your very fast help Jacco.
0
 
LVL 10

Expert Comment

by:Jacco
Comment Utility
Anytime!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now