miva_hex_encode()

 
Convert "data" to hexadecimal notation.
Syntax
miva_hex_encode( data )
returns the resulting encoded data.
  • data = the value to encode.
User Annotations: miva_hex_encode
Ray Yates : rayyates at, pdqcoders d0t com
04/16/2018 09:58 a.m.
If you are looking for a way to convert a decimal number to hexadecimal, the function below will do that. There is a limit to the size of the input number.
<MvFUNCTION NAME = "dec2hex" PARAMETERS = "num" STANDARDOUTPUTLEVEL = "">
	<MvWHILE EXPR = "{ l.num GT 0 }">
		<MvASSIGN NAME = "l.temp" VALUE = "{ l.num mod 16 }">
		<MvIF EXPR = "{ l.temp LT 10 }">
			<MvASSIGN NAME = "l.ndx" VALUE = "{ miva_array_insert( l.array, l.temp + 48, -1 ) }">
		<MvELSE>
			<MvASSIGN NAME = "l.ndx" VALUE = "{ miva_array_insert( l.array, l.temp + 55, -1 ) }">
		</MvIF>

		<MvASSIGN NAME = "l.num" VALUE = "{ (l.num - l.temp ) / 16 }">
	</MvWHILE>

	<MvASSIGN NAME = "l.count" VALUE = "{ miva_array_elements(l.array) }">
	<MvFOR FIRST = "{ 1 }" LAST = "{ l.count }">
		<MvASSIGN NAME = "l.return" VALUE = "{ l.return $ asciichar(miva_array_pop( l.array ))  }">
	</MvFOR>

    <MvFUNCTIONRETURN VALUE = "{ l.return }">
</MvFUNCTION>