Sign in to follow this  
Followers 0
dmca

Help converting Octal to Hex....easily

5 posts in this topic

Hi, I just started using this fantastic app today. I'm planning on using it in my carPC to automate a few tedious processes that would otherwise cause me to crash my car. I'm working on a script that requires me to convert an octal into its hexadecimal equivalent and I was hoping there would be a built-in function available that would do the hard work for me. I have my script completed barring this one, small problem. There doesn't seem to be a oct() function mentioned anywhere. I know I could spend a half an hour an code a function that will do this for me but I'm wondering ( hoping ) that some AutoIT guru has done this already and would be willing to share the knowledge. Thanks!!

Share this post


Link to post
Share on other sites



Hi, I just started using this fantastic app today. I'm planning on using it in my carPC to automate a few tedious processes that would otherwise cause me to crash my car. I'm working on a script that requires me to convert an octal into its hexadecimal equivalent and I was hoping there would be a built-in function available that would do the hard work for me. I have my script completed barring this one, small problem. There doesn't seem to be a oct() function mentioned anywhere. I know I could spend a half an hour an code a function that will do this for me but I'm wondering ( hoping ) that some AutoIT guru has done this already and would be willing to share the knowledge. Thanks!!

And yet another choice for your consideration.

$iDec = 17

$iOct = StringFormat("%o", $iDec); <== Conversion Dec 2 Oct
$iOct2Hex = Hex(Oct2Dec($iOct), 6) ; <== Conversion Oct 2 Hex

MsgBox(0, "Decimal2Oct", "Decimal       " & "= " & $iDec & @CRLF & _
                         "Hexidecimal " & "= " & "0x" & Hex($iDec, 6) & @CRLF & _
                         "Octal           " & "= " & $iOct & @CRLF & _
                         "Oct2Hex     " & "= " & "0x" & $iOct2Hex)
; 
Func Oct2Dec($iN)
    Local $aN, $iOct = 0
    $aN = StringSplit($iN, "", 1)
    For $x = 1 To UBound($aN) - 1
        $iOct += $aN[$x] * (8 ^ (UBound($aN) - 1 - $x))
    Next
    Return $iOct
EndFunc   ;==>Oct2Dec

Welcome to the forums.

Share this post


Link to post
Share on other sites

Thanks for all the help, I trawled through those suggestions and managed to get it going last night. Although, that method last posted seems to be a lot "cleaner" than what I ended up with. Thanks :P

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