Solved

Killing Enter Character

Posted on 2000-04-26
6
148 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
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

Industry Leaders: 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!

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

628 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