IB Statements/ihexdec
From CometWiki
IHEXDEC function
Syntax: IHEXDEC(string-argument)
Discussion: The IHEXDEC function converts the string-argument (a string of up to 4 Intel hex formatted bytes) into the equivalent decimal integer value (length.precision = 10.0).
Note: Intel-based systems store numeric data in "Intel hex format."
Windows passes data in this format to Comet and expects the same in return.
This function, along with the DECIHEX function, provide a streamlined way to convert formats.
For example, consider the hex value "@00654321@". In Intel format, this value is "@21436500@". The IHEXDEC function would convert "@21436500@" to the decimal numeric equivalent, 6636321.
Example:
Set TestHex$ = "@21436500@" ! 0x00654321 Set TestDec = 6636321 ! Length 4 & Local Hex$ Length 10.0 & Local Dec ! Print (Cs);(Et) ! Hex$ = TestHex$ Dec = IHexDec(Hex$) If (Dec EQ TestDec) Print "IHexDec succeeded" Else Print "IHexDec failed" EndIf ! Hex$ = DecIHex(Dec) If (Hex$ EQ TestHex$) Print "DecIHex succeeded" Else Print "DecIHex failed" EndIf ! Wait Stop