Current area: HOME -> Blogs -> Actor's Blog -> Read Post

Trimming strings

Posted on Wednesday, January 02, 2008 at 2:43 AM
Here, for completeness without further comment, is the code for RTrim, LTrim and Trim which are included in the unit Tools.

      Function RTrim (Var S : String) : String ;
      {
         RTrim -- remove trailing blanks
      }
      Var
         i : Byte ;
      begin { RTrim }
         for i := Length(S) downto 1 do
            if S[i] > BLANK then begin
               S     := Copy(S,1,i) ;
               RTrim := S ;
               Exit
            end ;
         {
               if we reach this point then S contains only BLANKS
            so we return a null string
         }
         S     := '' ;
         RTrim := S
      end ; { RTrim }

      Function LTrim (Var S : String) : String ;
      {
         LTrim -- remove leading blanks
      }
      Var
         i : Byte ;
      begin { LTrim }
         for i := 1 to Length(S) do
            if S[i] > BLANK then begin
               S     := Copy(S,i,MAXSTR) ;
               LTrim := S ;
               Exit
            end ;
         {
               if we reach this point then S contains only BLANKS
            so we return a null string
         }
         S     := '' ;
         LTrim := S
      end ; { LTrim }

      Function Trim  (Var S : String) : String ;
      {
         Trim -- remove leading and trailing blanks
      }
      begin { Trim }
         S     := RTrim(S) ;
         S     := LTrim(S) ;
         Trim  := S
      end ; { Trim }
Tags: String, Trim

Comments
very good - Posted on Wednesday, January 02, 2008 at 11:47 PM by xz116926
[url=http://www.cnzhongliu.com]?????[/url] [url=http://www.cnzhongliu.com/zlfl/hxxt/fa/Index.html]??[/url][url=http://www.cnzhongliu.com/zlfl/xhxt/wa/Index.html]??[/url]
[url=http://www.cnzhongliu.com/zlfl/xhxt/ga/Index.html]??[/url]
[url=http://www.cnzhongliu.com/zlfl/xhxt/sda/Index.html]???[/url] [url=http://www.cnzhongliu.com/zlfl/xhxt/yxa/Index.html]???[/url] [url=http://www.cnzhongliu.com/zlfl/xhxt/bma/Index.html]???[/url]
dfd - Posted on Wednesday, January 02, 2008 at 11:48 PM by xz116926
[url=http://www.cnzhongliu.com]?????[/url] [url=http://www.cnzhongliu.com/zlfl/hxxt/fa/Index.html]??[/url]


Sponsored links

Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Check Out IT Certification Preparation Materials
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Six Sigma Certification
100% Online-Six Sigma Certificate from Villanova - Find Out More Now.
Virtual File System SDK
Create your own file systems in Windows and .NET applications
PureCM Software Configuration Management
Version control and integrated issue tracking - powerful and easy to use. Get your FREE trial now!


Newsletter | Submit Content | About | Advertising | Awards | Contact Us | Link to us |
© 1996-2008 Community Networks Ltd All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Synchron Data - .NET development.