Hex To Decimal

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Hex To Decimal

Post by PepsiHog » Sat Feb 18, 2012 7:08 pm

Hello Everyone,

I have something in mind for this macro. Until today, I had NO idea how to do this. Now I have learned how and I wrote a macro that I hope will be usefull to some of you.

ENJOY!!

This macro prompts for a hex number and then calculates what the decimal number is.

Code: Select all

let>NewValue=
let>matches=0
let>pwr=0
let>Total=0
let>asd=0
let>simi=;

Input>Hex,Enter a HEX value
UpperCase>Hex,Hex

RegEx>[0-9a-fA-F],Hex,0,Hexidecimal,matches,0

Repeat>matches
let>Temp=Hexidecimal_%matches%
ConCat>NewValue,Temp
ConCat>NewValue,simi
sub>matches,1
Until>matches=0
RegEx>;$,NewValue,0,Values,nm,1,,NewValue
StringReplace>NewValue,A,10,NewValue
StringReplace>NewValue,B,11,NewValue
StringReplace>NewValue,C,12,NewValue
StringReplace>NewValue,D,13,NewValue
StringReplace>NewValue,E,14,NewValue
StringReplace>NewValue,F,15,NewValue
Separate>NewValue,;,Value
let>Count=%Value_count%
Repeat>asd
add>asd,1
let>hx={Power(16,%pwr%)}
let>digit=Value_%asd%
let>eq=%digit%*%hx%
let>Total=%Total%+%eq%
add>pwr,1
Until>asd=%Count%

mdl>%Total%

Later, I plan to post a macro to do the opposite. Decimal to Hex.

PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts