Solved

Add a character to a memo.

Posted on 2004-09-18
5
353 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
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 …

828 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