Hi,
I need to convert a DECimal value into a HEXadecimal and do some XORing for CheckSum calculation.
I don't find how to convert the DECValue to a HEX value and append it to the XORing line calculation.
Any help please?
Code:' DEC to HEX and XORing
DECValue = 0
Data$ = ""
CheckSum = 0
'message to be sent (serial): "94 10 00 nn xx"
' 94 10 00 = header
' nn = entered value
' xx = CheckSum
NOMAINWIN
[MAIN]
TEXTBOX #Main.TBx10, 30, 30, 30, 20
BUTTON #Main.Btn10,"Calculate",[Calculate],UL,115, 30, 60, 22
OPEN "DEC to HEX and XORing" FOR window AS #Main
#Main "TRAPCLOSE [QUIT]"
WAIT
[Calculate] ' message example where DECValue is 20 = "94 10 00 14 90"
#Main.TBx10, "!contents? DECValue"
CS = &H94 XOR &H10 XOR &H00 XOR &H14
Data$ = "94 10 00 " + DECHEX$(DECValue) + " " + DECHEX$(CS)
NOTICE "Result" + CHR$(13) + Data$
WAIT
[QUIT]
CLOSE #Main
END