Syntax:
stringvar = LongToHex(number)
Command Availability:
Available on all microcontrollers.
Explanation:
The LongToHex function converts a Long number into hexadecimal format. The input number should be a Long variable, or a fixed number between 0 and 4294967295 inclusive. After running the function, the string variable stringvar contains an 8-digit hexadecimal number.
Example:
'Set chip model
#chip 16F1936
'Set up hardware serial connection
#define USART_BAUD_RATE 9600
#define USART_TX_BLOCKING
'Send EEPROM data over serial connection
'Uses Hex to display as hexadecimal
For CurrentLocation = 0 to 65535
'Send location
HSerPrint LongToHex(CurrentLocation) ' <<< the LongToHex instruction
HSerPrint ":"
'Read Long and send
EPRead CurrentLocation, CurrLong
HSerPrint Hex(CurrLong)
'Send carriage return/line feed
HSerPrintCRLF
NextKey line: LongToHex(CurrentLocation) — formats the current address as a fixed 8-digit hex string, so addresses line up neatly in the terminal output regardless
of their value.
See Also:

