Quick Search for:  in language:    
just,like,name,says,Following,functions,Delph
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Delphi Stats

 Code: 209,911. lines
 Jobs: 14. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login





Latest Code Ticker for Delphi.
Nevolnik
By Johny Vlak on 1/3


Click here to see a screenshot of this code!Balls
By Alexander Izmukhambetov on 1/2

(Screen Shot)

Recycle Bin name changer
By ShoBaiR ShaIkhY on 12/30


Ninth backdoor 2003
By k0nsl on 12/27


Tank game 0.02
By Peter Williams on 12/25


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

Replace,InStr,Left,Right,LeftTrim,RightTrim,Reverse,Split,Replace,Mid Functions

Print
Email
 
VB icon
Submitted on: 7/21/2001 5:30:09 PM
By: Tanner Ezell (aka Lord Nova Ice)  
Level: Intermediate
User Rating: By 13 Users
Compatibility:Delphi 5, Delphi 4, Pre Delphi 4

Users have accessed this code 15673 times.
 
(About the author)
 
     This is just like the name says, The Following Vb functions for Delphi all coded/translated by me: RightTrim LeftTrem InStr Mid Left Right Replace Split Reverse
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

    !**************************************
    ! for :Replace,InStr,Left,Right,LeftTrim
    !     ,RightTrim,Reverse,Split,Replace,Mid Fun
    !     ctions
    !**************************************
    CopyRight 2001 By Me, Use in any manner you wish
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    !**************************************
    ! Name: Replace,InStr,Left,Right,LeftTri
    !     m,RightTrim,Reverse,Split,Replace,Mid Fu
    !     nctions
    ! Description:This is just like the name
    !     says, The Following Vb functions for Del
    !     phi all coded/translated by me:
    RightTrim
    LeftTrem
    InStr
    Mid
    Left
    Right
    Replace
    Split
    Reverse
    ! By: Tanner Ezell (aka Lord Nova Ice)
    !
    !This code is copyrighted and has    ! limited warranties.Please see http://w
    !     ww.Planet-Source-Code.com/vb/scripts/Sho
    !     wCode.asp?txtCodeId=382&lngWId;=7    !for details.    !**************************************
    
    unit Functions;
    interface
    uses
    Windows,Messages, SysUtils, Classes, Graphics,StdCtrls;
    function RightTrim(const s:String):String;
    function LeftTrim(const s:String):String;
    function InStr(Start: integer; Source: string; SourceToFind: string): integer;
    function Mid(Source: string; Start: integer; Length: integer): string;
    function Left(Source: string; Length: integer): string;
    function Right(Source: string; Lengths: integer): string;
    function Replace(sData: String; sSubstring: String; sNewsubstring: string): String;
    function Split(Source, Deli: string; StringList: TStringList): TStringList;
    function Reverse(Line: string): string;
    implementation
    function Reverse(Line: string): string;
    	var i: integer;
    	var a: string;
    begin
    	For i := 1 To Length(Line) do
    	begin
    	a := Right(Line, i);
    	Result := Result + Left(a, 1);
    	end;
    end;
    function Split(Source, Deli: string; StringList: TStringList): TStringList;
    var
    EndOfCurrentString: byte;
    begin
    repeat
    EndOfCurrentString := Pos(Deli, Source);
    if EndOfCurrentString = 0 then
    StringList.add(Source)
    else
    StringList.add(Copy(Source, 1, EndOfCurrentString - 1));
    Source := Copy(Source, EndOfCurrentString + length(Deli), length(Source) - EndOfCurrentString);
    until EndOfCurrentString = 0;
    result := StringList;
    end;
    function Replace(sData: String; sSubstring: String; sNewsubstring: string): String;
    var
    i: integer;
    lSub: Longint;
    lData: Longint;
    begin
    i := 1;
    lSub := Length(sSubstring);
    lData := Length(sData);
    repeat
    begin
    i := InStr(i, sData, sSubstring);
    If i = 0 Then
    begin
    sNewSubString := sData;
    Exit
    end
    Else
    sData := Copy(sData, 1, i - 1) + sNewsubstring + Copy(sData, i + lSub, lData);
    i := i + lSub;
    End;
    Until i > lData;
    Replace := sData;
    end;
    function Left(Source: string; Length: integer): string;
    begin
    	Result := copy(Source,1,Length);
    end;
    function Right(Source: string; Lengths: integer): string;
    begin
    Result := copy(source,Length(Source) - Lengths,Lengths);
    end;
    function Mid(Source: string; Start: integer; Length: integer): string;
    begin
    	Result := copy(Source,Start,Length);
    end;
    function InStr(Start: integer; Source: string; SourceToFind: string): integer;
    begin
    	Result := pos(SourceToFind,copy(Source,Start,Length(Source) - (Start - 1)));
    end;
    function RightTrim(const s:String):String;
    var
    i:integer;
    begin
    i:=length(s);
    while (i>0) and (s[i]<=#32) do
    Dec(i);
    result:=Copy(s,1,i);
    end;
    function LeftTrim(const s:String):String;
    var
    i, L:integer;
    begin
    L:=length(s);
    i:=1;
    while (i<=L) and (s[i]<=#32) do
    Inc(i);
    result:=Copy(s,i, MaxInt);
    end;
    end.


Other 3 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
7/21/2001 5:32:41 PM:Lord Nova Ice
if you find any bugs that i didnt leave 
a comment and ill fix ASAP, if you want 
a vb function that i dont have here 
leave a comment and ill try to make it, 
btw please vote ! ;]
Note: its not 
commented because its really plug in 
play
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/21/2001 7:16:59 PM:Jared Collums
A lot of these function have a Delphi 
counterpart, but it works just the same.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/23/2001 12:31:28 AM:Lord Nova Ice
47 views and only 1 vote? 47 is a lot 
for delphi! please vote and leave me 
comments!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/27/2001 2:34:49 PM:codecaine
ill vote for your efforts, delphi has a 
few functions built in now that do the 
same things, just to let ya k now.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/17/2001 4:05:25 PM:HighLander
Well..the Function Reverse..doesn't 
work correctly
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/18/2001 6:23:23 AM:ChrisMc
the funciont for Right doesn't work 
correctly. It should be:
Result := 
copy(source,Length(Source) - Lengths + 
1,Lengths + 1);
These functions were 
quite useful for me. 
Hey I'll vote 
for you!
ChrisMc
    
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/18/2001 6:24:45 AM:ChrisMC
Your function for "Right" is wrong, I 
think: It should be something like 
this:
Result := 
copy(source,Length(Source) - 
Lengths+1,Lengths+1);
You code quite 
helped me, so... I'll vote for 
you!
Have a nice day...
ChrisMc
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/30/2002 3:42:03 AM:Alan777
Apart from the other comments 
above,
you don't need to have all of 
these in your uses clause:
Windows, Messages, Graphics, StdCtrls;
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/19/2003 4:43:33 PM:Rana Hossain
replacing 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/19/2003 4:43:59 PM:Rana Hossain
replacing "e; with /"e; doesn't 
work
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/26/2003 10:05:24 PM:Api
uses StrUtils;
you can 
do
AnsiReplaceText, LeftStr, RightStr, 
MidStr, ReverseString, and alota the 
other stuff...
but its all 
gravvvvvvvvy
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Delphi Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.