Solved

Remove whitespace from memo

Posted on 2006-11-24
5
317 Views
Last Modified: 2010-04-05
Does anybody know how to remove whitespace from a memo?

Blank lines being whitespace
and also any blank spaces like this "the cat                              sat on the mat, have                   a nice day"

Thanks
0
Comment
Question by:zattz
  • 2
  • 2
5 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 18007070
0
 
LVL 14

Accepted Solution

by:
Pierre Cornelius earned 500 total points
ID: 18007469
There is a lot to go through in that link, so I put together a function for you to do what you asked for:

procedure StripWhiteSpaces(AMemo: TMemo);
var p1,p2: pchar;
    s: string;
    i: integer;
begin
  s:= AMemo.Lines.Text;
  if s = '' then exit;

  p1:= pchar(s);
  p2:= p1;
  while p2^ <> #0 do
  begin
    if (p2^ = ' ') AND ((pchar(p2+1)^ = ' ') or (pchar(p2-1)^ in [#13,#10]))
      then Delete(s, p2 - p1 + 1,1)
      else inc(p2);
  end;
  AMemo.Lines.Text:= trim(s);
  for i:= AMemo.Lines.Count-1 downto 0 do
    if AMemo.Lines[i] = ''
      then AMemo.Lines.Delete(i);
end;

Regards
Pierre
0
 
LVL 28

Expert Comment

by:2266180
ID: 18007534
that will teach me to choose a function and not just give a link to the list of functions. though it should have been more correct to at least mark my resonse as assisted.
whatever.
0
 

Author Comment

by:zattz
ID: 18007555
noted...
0
 

Author Comment

by:zattz
ID: 18017796
Hi Pierre,

I need the procedure altered to work with VCL.NET so I've opened a new question. I thought i'd paste it here incase you were interested:

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_22073038.html

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

815 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

9 Experts available now in Live!

Get 1:1 Help Now