Busti Posted February 8, 2007 Posted February 8, 2007 (edited) Hi all, i just want to share my newest function i made Its realy easy, but i hope usefull too . UDF : expandcollapse popup; 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 February 8, 2007 by Busti My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity
Valik Posted February 8, 2007 Posted February 8, 2007 Congratulations, you implemented a retarded version of StringFormat().
Josbe Posted February 9, 2007 Posted February 9, 2007 Congratulations, you implemented a retarded version of StringFormat(). @Busti: Yeah, sometimes can be useful. StringFormat() already was implemented (long time ago) in AutoIt. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
Busti Posted February 9, 2007 Author Posted February 9, 2007 (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 February 9, 2007 by Busti My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now