Sign in to follow this  
Followers 0
golfinhu

reverse text ?

6 posts in this topic

hi guys, I needed a function to reverse a string, I got to do this until it works:

Func _Revert_text($text)
    Local $count = StringLen($text)
    If $count = 0 Then Return
    Local $a = 0
    Local $newstring = ""

    For $i = $count To 1 Step -1
        Local $letter = StringMid($text, $count - $a, 1)
        $newstring = $newstring & $letter
        $a += 1
    Next

    Return $newstring
EndFunc   ;==>_Revert_text

But I think it was poorly done, is there another way to do?

thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

How about

_StringReverse($text)

Edit: Change the parameter to suit your need

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

oh, did not know this function!

thanks!

Share this post


Link to post
Share on other sites

My pleasure, I had the time ;)


My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

Hi,

I know it's already been solved, but the op was so close to reinventing the wheel.

ConsoleWrite(_Revert_text("Reverse this string") & @LF)

Func _Revert_text($text)
    Local $aSS = StringSplit($text, ""), $sTmp
    For $i = $aSS[0] To 1 Step -1
        $sTmp &= $aSS[$i]
    Next
    Return $sTmp
EndFunc   ;==>_Revert_text

Share this post


Link to post
Share on other sites

ty ppl

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