Solved

Add a character to a memo.

Posted on 2004-09-18
5
350 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
ID: 12091013
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
ID: 12091019
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
ID: 12091022
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
ID: 12091047
Many thanks for your very fast help Jacco.
0
 
LVL 10

Expert Comment

by:Jacco
ID: 12091099
Anytime!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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

12 Experts available now in Live!

Get 1:1 Help Now