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

x
?
Solved

Killing Enter Character

Posted on 2000-04-26
6
Medium Priority
?
149 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
[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
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Accepted Solution

by:
TheNeil earned 100 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

722 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