Solved

Killing Enter Character

Posted on 2000-04-26
6
142 Views
Last Modified: 2010-05-18
I want to read from a String variable and replace any ENTER with space like:

============

Nice
Night

== will be

Nice Night

============

Regards,
Hamid
0
Comment
Question by:HamidHossain
6 Comments
 

Author Comment

by:HamidHossain
ID: 2754135
Put in mind that maybe more that Enter character is available like:

============

I
am
Happy
Hello

============

that should be:

============

I am Happy Hello

============

So on .........
0
 
LVL 3

Expert Comment

by:ckaneta
ID: 2754150
p : integer;     s : string;
repeat
 p:=pos(#13+#10,str);
 delete(str,p,2);
 insert(' ',str,p);
until (p = 0);

something like that should do the trick
0
 
LVL 7

Expert Comment

by:Motaz
ID: 2754162
function KillEnter(Text: string): string;
var
  i: Integer;
begin
  for i:= 1 to Length(Text) do
   if Text[i] = #13 then
     Text[i]:= ' ';
  Result:= Text;
end;


Example of calling:

MyText:= KillEnter(MyText);

Motaz
www.geocities.com/motaz1
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Accepted Solution

by:
TheNeil earned 25 total points
ID: 2754871
Personally I'd do it this way:


FUNCTION OneLine(sText : STRING): STRING;
VAR
  iCount : LONGINT;
  sTemp  : STRING;
BEGIN
  sTemp := '';
  iCount := 1;
  REPEAT
    IF sText[iCount] = #13
    THEN
    BEGIN
      sText := sText + ' ';
      IF iCount < Length(sText)
      THEN
      BEGIN
        IF sText[iCount + 1] = #10
        THEN
          iCount := iCount + 1;
      END;
    END
    ELSE
      sTemp := sTemp + sText[iCount];
    iCount := iCount + 1;
  UNTIL iCount > Length(sText);
  Result := sTemp;
END;

A little bit long winded but it covers pretty much every eventuality

The Neil =:)
0
 
LVL 7

Expert Comment

by:Motaz
ID: 2754942
Hamida, I read your profile, please tell me your E-Mail because I'm also interested in CGI and web development.

Motaz
www.geocities.com/motaz1
motaz1@yahoo.com
0
 

Author Comment

by:HamidHossain
ID: 2853164
Comment accepted as answer
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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

19 Experts available now in Live!

Get 1:1 Help Now