Jump to content

Function : _fString


Busti
 Share

Recommended Posts

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...