Jump to content

Recommended Posts

Posted

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!!

Posted (edited)
dmca said:

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, "Octal2Decimal", _
        "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 Int($iOct)
EndFunc   ;==>Oct2Dec

Welcome to the forums.

Edited by Malkey
Changed Return $iOct to Return Int($iOct) in Oct2Dec() function.
Posted

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

  • 12 years later...
Posted

You know that this topic is more than 12 years old and the OP is absent since 2011?
Please do not necro old posts!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

  • Developers
Posted
3 hours ago, water said:

You know that this topic is more than 12 years old and the OP is absent since 2011?

Spammer ...whom is now zapped?  ;)  

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...