Daniel W. Posted June 13, 2006 Share Posted June 13, 2006 Hi, I want to rewrite _StringReverse but it returns this "" and not the reversed string. This is my code so far #include <String.au3> Msgbox(0,'',_StringReverse( "esreveR" ) & @CRLF & StringReverse("esreveR")) Exit Func StringReverse( $s_string ) Local $string = "" Local $chars For $a = 1 to 255 $chars = $chars & "|" & Chr( $a ) Next Local $split = StringSplit( $s_string , $chars ) For $b = $split[0] to 1 Step -1 $string = $string & $split[$b] Next Return $string EndFunc I think it stucks at the second for loop but i dunno why ... Regards --------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote] Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted June 13, 2006 Share Posted June 13, 2006 (edited) check out StringMid, by the way _StringReverse is already a UDF so if u need help why not just check there? Edited June 13, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
Daniel W. Posted June 13, 2006 Author Share Posted June 13, 2006 (edited) I want to rewrite it to learn it and i already thought of stringmid but when i walked home from bus i got this idea with stringsplit and i dont know why it does not work... €: its done with wOuters Help Func StringReverse( $s_string ) Local $string Local $split = StringSplit( $s_string , '' ) For $b = $split[0] to 1 Step -1 $string &= $split[$b] Next Return $string EndFunc Edited June 13, 2006 by Daniel W. --------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote] Link to comment Share on other sites More sharing options...
jvanegmond Posted June 13, 2006 Share Posted June 13, 2006 Why not do this? It's the first thing that came in mind.. Local $String = "Hello" Local $NewString While $String <> "" $NewString &= StringRight($String, 1) $String = StringTrimRight($String,1) WEnd MsgBox(0, "$NewString", $NewString) github.com/jvanegmond Link to comment Share on other sites More sharing options...
jvanegmond Posted June 13, 2006 Share Posted June 13, 2006 I want to rewrite it to learn it and i already thought of stringmid but when i walked home from bus i got this idea with stringsplit and i dont know why it does not work... : its done with wOuters Help Func StringReverse( $s_string ) Local $string Local $split = StringSplit( $s_string , '' ) For $b = $split[0] to 1 Step -1 $string &= $split[$b] Next Return $string EndFunc That's the second hehe github.com/jvanegmond Link to comment Share on other sites More sharing options...
w0uter Posted June 13, 2006 Share Posted June 13, 2006 (edited) my best attempt: Using '' _StringReverse: 1 - 759.462608774554 xStringReverse: 1 - 916.683793213463 Using 'R' _StringReverse: 0 - 1188.24971622757 xStringReverse: 0 - 862.55897285795 Using 'AutoIt v3' _StringReverse: 0 - 3706.05057500871 xStringReverse: 0 - 2915.81731524058 expandcollapse popup#include <String.au3> Func xStringReverse($s_string) Local $v_temp = StringLen($s_string) If $v_temp > 1 Then $v_temp = '' Local $as_split = StringSplit($s_string, '') For $i = $as_split[0] To 1 Step - 1 $v_temp &= $as_split[$i] Next Return $v_temp Else SetError(BitXOR($v_temp, 1)) Return $s_string EndIf EndFunc ;==>xStringReverse $c = 10000 ConsoleWrite('Using ''''' & @LF) $t = TimerInit() For $i = 0 To $c _StringReverse("") Next ConsoleWrite("_StringReverse: " & @error & ' - ' & TimerDiff($t) & @LF) $t = TimerInit() For $i = 0 To $c xStringReverse("") Next ConsoleWrite("xStringReverse: " & @error & ' - ' & TimerDiff($t) & @LF) ConsoleWrite('Using ''R''' & @LF) $t = TimerInit() For $i = 0 To $c _StringReverse("R") Next ConsoleWrite("_StringReverse: " & @error & ' - ' & TimerDiff($t) & @LF) $t = TimerInit() For $i = 0 To $c xStringReverse("R") Next ConsoleWrite("xStringReverse: " & @error & ' - ' & TimerDiff($t) & @LF) ConsoleWrite('Using ''AutoIt v3''' & @LF) $t = TimerInit() For $i = 0 To $c _StringReverse("AutoIt v3") Next ConsoleWrite("_StringReverse: " & @error & ' - ' & TimerDiff($t) & @LF) $t = TimerInit() For $i = 0 To $c xStringReverse("AutoIt v3") Next ConsoleWrite("xStringReverse: " & @error & ' - ' & TimerDiff($t) & @LF) Edited June 13, 2006 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Busti Posted June 13, 2006 Share Posted June 13, 2006 could you check myne too ? Func _StringReverse($_String) Local $Ret If StringLen($_String) < 1 Then Return "" For $i = 1 To StringLen($_String) $Ret &= StringRight(StringTrimRight($_String,$i-1),1) Next Return $Ret EndFunc 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 More sharing options...
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