XML: Decimal To Hex Macro: Difference between revisions
From FSDeveloper Wiki
Jump to navigationJump to search
(Created page with "Decimal to Hex Macro using XMLVars <Macro Name="ValHex"> int s15 l15 10 >= if{ l15 55 + chr 'HexDigit' l32 scat (>C:XMLVARS:SearchVarName, string) (>C:XMLVAR...") |
No edit summary |
||
| Line 1: | Line 1: | ||
Decimal to Hex Macro using XMLVars | '''Decimal to Hex Macro using XMLVars''' | ||
<Macro Name="ValHex"> | <Macro Name="ValHex"> | ||
int | int d 10 >= | ||
if{ 55 + chr 'HexDigit' l31 scat (>C:XMLVARS:SearchVarName, string) (>C:XMLVARS:StringValue, string) } | |||
if{ | els{ 'HexDigit' l31 scat (>C:XMLVARS:SearchVarName, string) (>C:XMLVARS:StringValue, string) } | ||
els{ | |||
</Macro> | </Macro> | ||
<Macro Name="Dec2Hex"> | <Macro Name="Dec2Hex"> | ||
s30 | s30 | ||
'@1' (>C:XMLVARS:StoreVarName, string) | '@1' (>C:XMLVARS:StoreVarName, string) <nowiki>''</nowiki> '@1' (>C:XMLVARS:SearchVarName, string) (>C:XMLVARS:StringValue, string) | ||
0 | 0 sp31 | ||
:300 | :300 | ||
l31 ++ s31 | |||
'HexDigit' | 'HexDigit' l31 scat (>C:XMLVARS:StoreVarName, string) | ||
l30 16 % @ValHex | l30 16 % @ValHex | ||
l30 16 / int | l30 16 / int 0 == if{ g301 } els{ g300 } | ||
:301 | :301 | ||
'@1' (>C:XMLVARS:SearchVarName, string) (C:XMLVARS:StringValue, string) | '@1' (>C:XMLVARS:SearchVarName, string) (C:XMLVARS:StringValue, string) | ||
'HexDigit' | 'HexDigit' l31 scat (>C:XMLVARS:SearchVarName, string) (C:XMLVARS:StringValue, string) scat | ||
'@1' (>C:XMLVARS:SearchVarName, string) (>C:XMLVARS:StringValue, string) | '@1' (>C:XMLVARS:SearchVarName, string) (>C:XMLVARS:StringValue, string) | ||
l31 -- s31 0 != if{ g301 } | |||
</Macro> | </Macro> | ||
'''Example:''' | |||
To convert decimal 13516816 to hexadecimal and write it to an XMLVar string variable arbitrarily named 'HexExample' | |||
13516816 @Dec2Hex(HexExample) | |||
XMLVar HexExample contains the string CE4010 which is the hexadecimal equivalent of 13516816 (base 10) | |||
Dec2Hex macro creates the XMLVar string variable when it is executed. | |||
'''NOTE:''' The side-by-side single quotes in Dec2Hex line two: these are two single quotes with no space in between | |||
[[rpmc]] | |||
Revision as of 03:29, 25 July 2015
Decimal to Hex Macro using XMLVars
<Macro Name="ValHex">
int d 10 >=
if{ 55 + chr 'HexDigit' l31 scat (>C:XMLVARS:SearchVarName, string) (>C:XMLVARS:StringValue, string) }
els{ 'HexDigit' l31 scat (>C:XMLVARS:SearchVarName, string) (>C:XMLVARS:StringValue, string) }
</Macro>
<Macro Name="Dec2Hex">
s30
'@1' (>C:XMLVARS:StoreVarName, string) '' '@1' (>C:XMLVARS:SearchVarName, string) (>C:XMLVARS:StringValue, string)
0 sp31
:300
l31 ++ s31
'HexDigit' l31 scat (>C:XMLVARS:StoreVarName, string)
l30 16 % @ValHex
l30 16 / int 0 == if{ g301 } els{ g300 }
:301
'@1' (>C:XMLVARS:SearchVarName, string) (C:XMLVARS:StringValue, string)
'HexDigit' l31 scat (>C:XMLVARS:SearchVarName, string) (C:XMLVARS:StringValue, string) scat
'@1' (>C:XMLVARS:SearchVarName, string) (>C:XMLVARS:StringValue, string)
l31 -- s31 0 != if{ g301 }
</Macro>
Example:
To convert decimal 13516816 to hexadecimal and write it to an XMLVar string variable arbitrarily named 'HexExample'
13516816 @Dec2Hex(HexExample)
XMLVar HexExample contains the string CE4010 which is the hexadecimal equivalent of 13516816 (base 10)
Dec2Hex macro creates the XMLVar string variable when it is executed.
NOTE: The side-by-side single quotes in Dec2Hex line two: these are two single quotes with no space in between