Sign in to follow this  
Followers 0
Busti

Function : _fString

4 posts in this topic

#1 ·  Posted (edited)

Hi all, i just want to share my newest function i made :whistle:

Its realy easy, but i hope usefull too :).

UDF :

; FunctionName : _fString()
; FunctionUsing:
;                Easy formats your strings, ex. :
;           _fString("Hello my name is %1" , "Andi")
;       -> Return : Hello my name is Andi
;           
; ErrorReturn :
;           _fString("Hello my name is x" , "Andi" )
;       -> @Error = 1
;       -> Return = the old string
;
; Function by Busti.
Func _fString($string,$1="",$2="",$3="",$4="",$5="",$6="",$7="",$8="",$9="",$10="",$11="",$12="",$13="",$14="",$15="", _
                        $16="",$17="",$18="",$19="",$20="",$21="",$22="",$23="",$24="",$25="",$26="",$27="",$28="",$29="",$30="", _
                        $31="",$32="",$33="",$34="",$35="",$36="",$37="",$38="",$39="",$40="",$41="",$42="",$43="",$44="",$45="")
    If Not StringInStr( $string, "%" ) Then
        SetError( 1 , 1 , 1 )
        Return $string ; Delim was not found
    EndIf
    For $i = 1 To 45
        $rString=Eval($i)
        If $rString = "" Then ExitLoop
        $string =StringReplace( $string , '%'&$i , $rString )
    Next
    Return $string
    
EndFunc
oÝ÷ ØLZ^jëh×6
$test = _fString( "Hello %1 a %2 String ! Now this %3 is getting %4 !" , "im" , "test", "Function", "testet" )

MsgBox( 0 , "" , $test )

Func _fString($string,$1="",$2="",$3="",$4="",$5="",$6="",$7="",$8="",$9="",$10="",$11="",$12="",$13="",$14="",$15="", _
                        $16="",$17="",$18="",$19="",$20="",$21="",$22="",$23="",$24="",$25="",$26="",$27="",$28="",$29="",$30="", _
                        $31="",$32="",$33="",$34="",$35="",$36="",$37="",$38="",$39="",$40="",$41="",$42="",$43="",$44="",$45="")
    If Not StringInStr( $string, "%" ) Then
        SetError( 1 , 1 , 1 )
        Return $string ; Delim was not found
    EndIf
    For $i = 1 To 45
        $rString=Eval($i)
        If $rString = "" Then ExitLoop
        $string =StringReplace( $string , '%'&$i , $rString )
    Next
    Return $string
    
EndFunc
Edited by Busti

My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity

Share this post


Link to post
Share on other sites



Congratulations, you implemented a retarded version of StringFormat().

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

why im always making fucntions that are already made :s...

but after looking at the string format i like mine more, but ok...

Edited by Busti

My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0