Hex conversion
PatG
Junior Member
HI, I need to convert a string of hex into decimal but I can't seem to figure it out. A string something like
$0,$36,$EE,$80
Needs to be seen as
$0036EE80
And that one hex value converted to decimal or even ASCII, something I can perform some math on and then display ultimately as decimal.
Any ideas much appreciated.
Answers
-
Something like this:
DEFINE_VARIABLE VOLATILE CHAR cHexString[] = {$0,$36,$EE,$80} VOLATILE LONG lDecimal DEFINE_FUNCTION LONG fnHex(CHAR cHexData[]) { STACK_VAR VOLATILE CHAR cResult[100] STACK_VAR VOLATILE INTEGER i FOR(i = 1 ;i<=LENGTH_ARRAY(cHexData); i++) { cResult = "cResult,FORMAT('%02X',cHexData[i])" } SEND_STRING 0, cResult RETURN HEXTOI(cResult) } lDecimal = fnHex(cHexString) -
Thanks I'll see if I can make that work. The thing is the hex string can change at any time so I have to allow for any possibility of 4 bytes.
-
@PatG said:
Thanks I'll see if I can make that work. The thing is the hex string can change at any time so I have to allow for any possibility of 4 bytes.As long as the four bytes represent a valid number, it'l work. Good luck.
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums