MyEarth Posted October 6, 2014 Posted October 6, 2014 I'd like to make an easy number cipher, pratically just add N number to the final result My attempt: $sReturn = "" $sText = "0123456789" $nPos = 3 $aSplit = StringSplit($sText, "") For $i = 0 To UBound($aSplit) - 1 Select Case Number($aSplit[$i]) < 7 $sReturn &= $aSplit[$i] + $nPos Case Number($aSplit[$i]) = 7 $sReturn &= 0 Case Number($aSplit[$i]) = 8 $sReturn &= 1 Case Number($aSplit[$i]) = 9 $sReturn &= 2 EndSelect Next ConsoleWrite($sReturn & @CRLF) I don't know how to make the number start from zero if is bigger the 9, i can't make the case like the example because work only if $nPos = 3 Thanks
JohnOne Posted October 6, 2014 Posted October 6, 2014 Please explain a bit more "I don't know how to make the number start from zero if is bigger the 9, i can't make the case like the example because work only if $nPos = 3" and exact goal of script. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
MyEarth Posted October 6, 2014 Author Posted October 6, 2014 (edited) Ok I want to add a number to another number, in the example the position are three, but is a variable and this value can change so: 0 = 3 (0+3) 1 = 4 (1+3) 2 = 5 (2+3) But when it come the 7 7 = 10 (7+3) Is wrong, the number are only ten and the max value is 9, so need to start from zero: 7 = 0 8 = 1 9 = 2 So explected string is, if the position to move are three: 0123456789 = 3456789012 Is clear? Oh, i need to reverse the process too Edited October 6, 2014 by MyEarth
Gianni Posted October 6, 2014 Posted October 6, 2014 using Mod() could do $sReturn = "" $sText = "0123456789" $nPos = 3 $aSplit = StringSplit($sText, "", 2) For $i = 0 To UBound($aSplit) - 1 $sReturn &= Mod($aSplit[$i] + $nPos, 10) Next ConsoleWrite($sReturn & @CRLF) Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
MyEarth Posted October 7, 2014 Author Posted October 7, 2014 (edited) Wait, and for reverse the process? Come back from 3456789012 To 0123456789 Edited October 7, 2014 by MyEarth
Gianni Posted October 7, 2014 Posted October 7, 2014 (edited) Wait, and for reverse the process? Come back from 3456789012 To 0123456789 this could do ... $sReturn = "" $sText = "0123456789" $nPos = 3 $max = 10 ; (0-9) ; ; forth $aSplit = StringSplit($sText, "", 2) For $i = 0 To UBound($aSplit) - 1 $sReturn &= Mod($aSplit[$i] + $nPos, $max) Next ConsoleWrite($sReturn & @CRLF) ; ; and back $aSplit = StringSplit($sReturn, "", 2) $sReturn = "" For $i = 0 To UBound($aSplit) - 1 $sReturn &= Mod($aSplit[$i] - $nPos + ($max * ($aSplit[$i] < $nPos)), $max) Next ConsoleWrite($sReturn & @CRLF) Edited October 8, 2014 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
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