Solved

Killing Enter Character

Posted on 2000-04-26
6
144 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 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