🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Remove Spaces Function

#120
From: Betsy
Date: Mon, 26 Jan 2004 22:50
59 lines
2726 bytes
don't the ansireplacestr and ansireplacetext do all of this?

b
"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: <401599a1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!newsfeed00.sul.t-online.de!t-online.de!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!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 14:53:31 PST
From: "Betsy" <betsy.a.tainer@lesschwab.com>
Newsgroups: borland.public.delphi.language.objectpascal
References: <40153f7d@newsgroups.borland.com>
Subject: Re: Remove Spaces Function
Date: Mon, 26 Jan 2004 14:50:05 -0800
Lines: 61
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 12.111.178.19
Message-ID: <401599a1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1075157409 12.111.178.19 (26 Jan 2004 14:50:09 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!newsfeed00.sul.t-online.de!t-online.de!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail