Sign in to follow this  
Followers 0
403forbidden

Does this function exist?

12 posts in this topic

Is there any function that could modify a string in a way that makes the letter of a string go up or down one, like the basis of all encryption? For instance, "dog" as the string, and "eph" as the return? I can make it myself, but i wanted to check just in case it already existed.

Share this post


Link to post
Share on other sites



Why in the world would such a trivial function be included in the autoit product?

It's no more than 5 lines of code.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

your right but on the other hand why include _stringExplode() as its nothing extra than StringSplit() other than maybe 1 or 2 lines of code if you wanted to use the $Limit var

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You can do it.

global $Text = '403forbidden'

$Text = _StringInverse($Text)
ConsoleWrite($Text & @CR)
$Text = _StringInverse($Text)
ConsoleWrite($Text & @CR)

func _StringInverse($sString)
    
    local $Ret = ''
    
    while $sString > ''
        $c = Asc(StringLeft($sString, 1))
        switch $c
            case 32 to 127
                $Ret &= Chr(32 + 127 - $c)
            case else
                $Ret &= Chr($c)
        endswitch
        $sString = StringTrimLeft($sString, 1)
    wend
    return $Ret
endfunc; _StringInverse
Edited by Yashied

Share this post


Link to post
Share on other sites

Thanks for the help, I will have a look.

Share this post


Link to post
Share on other sites

while $sString > ''

was just wondering about that? can a string be used in a numeric expression like this "a"<"b" ?

testing it it does look like it can but does that mean that it assigns the ASCII val to the strings automatically or is it just a null string ""= 0 (FALSE) and anything other than a null "Z"=1 (TRUE)?

tried looking at Number("a") but it returns 0 so im a little confused how using while $sString > "" would work


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

was just wondering about that? can a string be used in a numeric expression like this "a"<"b" ?

testing it it does look like it can but does that mean that it assigns the ASCII val to the strings automatically or is it just a null string ""= 0 (FALSE) and anything other than a null "Z"=1 (TRUE)?

tried looking at Number("a") but it returns 0 so im a little confused how using while $sString > "" would work

while StringLen($sString) > 0

Share this post


Link to post
Share on other sites

was just wondering about that? can a string be used in a numeric expression like this "a"<"b" ?

testing it it does look like it can but does that mean that it assigns the ASCII val to the strings automatically or is it just a null string ""= 0 (FALSE) and anything other than a null "Z"=1 (TRUE)?

tried looking at Number("a") but it returns 0 so im a little confused how using while $sString > "" would work

When comparing strings as in if $a > $b, AutoIt seems to compare alphabetically but case independantly. When comparing a string to a number then AutoIt will take any leading digits as the number for the string.

Effectively If $a > '' is the same as If $a <> ''


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

string comp to int "a"="0" False

string comp to string "a"= 0 True

aye interesting, so when a string is compared to a string "1"<"2"<"3"<"a"<"b"<"c" ... etc, but if an int is involved then the string is only valued as the first number in the string, but then why does "1a" <> 1 ?

it's all pretty academic really as you wouldn't really compare strings in this way, but interesting how AI treats them.

dont mine my musing I'll have to go and have a tinker and try some things out just for my peace of mind on this one, cheers for the pointer Martin that was very helpful.


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Ok, I have what I wa't, Yashied, I was thinking something more like this.

MsgBox(0, "Info", _String_Inverse("403forbidden", 1, "Down"))
MsgBox(0, "Info", _String_Inverse("403forbidden", 1, "Up"))
MsgBox(0, "Info", _String_Inverse("403forbidden", 8, "Up"))
MsgBox(0, "Info", _String_Inverse("403forbidden", 8, "Down"))

Func _String_Inverse($String, $Inverse_Count, $Direction = "Up")
    Local $Count = 1
    Local $Return

    For $Count = 1 To StringLen($String)
        If StringIsAlNum(StringRight(StringLeft($String, $Count), 1)) = 0 Then Return -1
    Next
    $Count = 1
    If $Direction = "Up" Then
        For $Count = 1 To StringLen($String)
            If StringIsLower(StringRight(StringLeft($String, $Count), 1)) = 1 Then
                If Asc(StringRight(StringLeft($String, $Count), 1)) + $Inverse_Count > 122 Then
                    $Return = $Return & Chr(Asc(StringRight(StringLeft($String, $Count), 1)) + $Inverse_Count - 26)
                EndIf
                If Asc(StringRight(StringLeft($String, $Count), 1)) + $Inverse_Count < 122 Then
                    $Return = $Return & Chr(Asc(StringRight(StringLeft($String, $Count), 1)) + $Inverse_Count)
                EndIf
            EndIf
            If StringIsUpper(StringRight(StringLeft($String, $Count), 1)) = 1 Then
                If Asc(StringRight(StringLeft($String, $Count), 1)) + $Inverse_Count > 90 Then
                    $Return = $Return & Chr(Asc(StringRight(StringLeft($String, $Count), 1)) + $Inverse_Count - 26)
                EndIf
                If Asc(StringRight(StringLeft($String, $Count), 1)) + $Inverse_Count < 90 Then
                    $Return = $Return & Chr(Asc(StringRight(StringLeft($String, $Count), 1)) + $Inverse_Count)
                EndIf
            EndIf
            If StringIsDigit(StringRight(StringLeft($String, $Count), 1)) = 1 Then
                If Asc(StringRight(StringLeft($String, $Count), 1)) + $Inverse_Count > 57 Then
                    $Return = $Return & Chr(Asc(StringRight(StringLeft($String, $Count), 1)) + $Inverse_Count - 10)
                EndIf
                If Asc(StringRight(StringLeft($String, $Count), 1)) + $Inverse_Count < 57 Then
                    $Return = $Return & Chr(Asc(StringRight(StringLeft($String, $Count), 1)) + $Inverse_Count)
                EndIf
            EndIf
        Next
    EndIf
    If $Direction = "Down" Then
        For $Count = 1 To StringLen($String)
            If StringIsLower(StringRight(StringLeft($String, $Count), 1)) = 1 Then
                If Asc(StringRight(StringLeft($String, $Count), 1)) - $Inverse_Count > 97 Then
                    $Return = $Return & Chr(Asc(StringRight(StringLeft($String, $Count), 1)) - $Inverse_Count)
                EndIf
                If Asc(StringRight(StringLeft($String, $Count), 1)) - $Inverse_Count < 97 Then
                    $Return = $Return & Chr(Asc(StringRight(StringLeft($String, $Count), 1)) - $Inverse_Count + 26)
                EndIf
            EndIf
            If StringIsUpper(StringRight(StringLeft($String, $Count), 1)) = 1 Then
                If Asc(StringRight(StringLeft($String, $Count), 1)) - $Inverse_Count > 65 Then
                    $Return = $Return & Chr(Asc(StringRight(StringLeft($String, $Count), 1)) - $Inverse_Count)
                EndIf
                If Asc(StringRight(StringLeft($String, $Count), 1)) - $Inverse_Count < 65 Then
                    $Return = $Return & Chr(Asc(StringRight(StringLeft($String, $Count), 1)) - $Inverse_Count + 26)
                EndIf
            EndIf
            If StringIsDigit(StringRight(StringLeft($String, $Count), 1)) = 1 Then
                If Asc(StringRight(StringLeft($String, $Count), 1)) - $Inverse_Count > 48 Then
                    $Return = $Return & Chr(Asc(StringRight(StringLeft($String, $Count), 1)) - $Inverse_Count)
                EndIf
                If Asc(StringRight(StringLeft($String, $Count), 1)) - $Inverse_Count < 48 Then
                    $Return = $Return & Chr(Asc(StringRight(StringLeft($String, $Count), 1)) - $Inverse_Count + 10)
                EndIf
            EndIf
        Next
    EndIf
    Return $Return
EndFunc ;==>_String_Inverse
Edited by 403forbidden

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