🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.language.objectpascal
Article #212

Re: Remove Spaces Function

#212
From: Yehia Ahmed
Date: Mon, 26 Jan 2004 18:34
63 lines
2819 bytes
thanks for the responses,
just wondering which is best in term of speed:
copy maintext.lines.string[ln] to a string and do the code and copy it back
to maintext.line.strings[ln],
Or
just do the code direclty in maintext.text?

"Yehia Ahmed" <yehiaeg@hotmail.com> wrote in message
news:40153f7d@newsgroups.borland.com...
> hello,
> I wrote this procedure which remove the spaces after and before the
"equal"
> sign,
> for example --> test        =                  test2
>       becomes--> test = test2
> and -->test=test2
>      becomes-->test = test2
> (like the visual basic editor)
> my function was like this:
>
> Procedure RemoveSpaces (Ln:integer);
> var ReStr:String;
>     Re,re,i:integer;
>     F1,F2:boolean;
> begin
> ReStr := maintext.lines[ln-1];
> Re:= instrmt('=',lnbegin,toend - lnbegin ,[ ],true,true); -->just like
> maintext.findtext (maintext is a richedit)
> Re2:= firstcolumn(ln) -1;
> repeat
> if re <> -1 then begin
>    Restr[Re -re2]:= '`';
>    for i := 1 to length(restr) do begin
>       try
>          if (restr[re - i -re2] = ' ') And(f1=false) then restr[re -
> i -re2]:= '`' else f1 := true;
>          if (restr[re + i -re2] = ' ') And(f2=false) then restr[re +
i-re2]
> := '`' else f2 := true;
>          if (f1=true) and (f2=true) then break;
>       except
>          //
>       end;
>    end;
> Re:= instrmt('=',Re+1 ,toend - lnbegin ,[],true,true);
> end;
> until Re= -1;
> ReStr:= StringReplace(restr,'%',' = ',[rfreplaceall]); ---> error occurs
> here!!
> ReStr:= StringReplace(restr,'`','',[rfreplaceall]);
> maintext.lines[ln-1] := ReStr;
> end;
>
> this procedure is extremely slow when loading text from a file cause it's
> called on every line, sometimes there is strange EAccessViolation error on
> the stringreplace line(still don't know why), anyone can help me to
improve
> a better procedure?
>
> Yehia
>
>
>
Technical Details
Message-ID: <40155dd8@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40153f7d@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109d30,8b4ceee2931b0643
X-Google-Attributes: gid109d30,public
X-Google-ArrivalTime: 2004-01-26 10:41:02 PST
From: "Yehia Ahmed" <yehiaeg@hotmail.com>
Newsgroups: borland.public.delphi.language.objectpascal
References: <40153f7d@newsgroups.borland.com>
Subject: Re: Remove Spaces Function
Date: Mon, 26 Jan 2004 20:34:58 +0200
Lines: 65
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300
NNTP-Posting-Host: 62.68.242.119
Message-ID: <40155dd8@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1075142104 62.68.242.119 (26 Jan 2004 10:35:04 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail