Solved

Add a character to a memo.

Posted on 2004-09-18
5
363 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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