Solved

Killing Enter Character

Posted on 2000-04-26
6
146 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

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…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

756 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