Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Add a character to a memo.

Posted on 2004-09-18
5
Medium Priority
?
370 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

688 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