| View previous topic :: View next topic |
| Author |
Message |
grolo12 How do I cheat?
Reputation: 0
Joined: 17 Jan 2020 Posts: 8
|
Posted: Fri Jan 17, 2020 6:16 am Post subject: Error Dec To Hex convertion |
|
|
Hello
I'd like to calculate "011d" - "1200" which and equals 131D
my code gives 12F how to make the addition of the two code please?
| Code: |
function CETrainer_CEButton1Click(sender)
hex1 = CETrainer.CEEdit1.text
resultat1 = string.format("0%x", hex1)
Control_setCaption(CETrainer_CEEdit2, resultat1)
end
function CETrainer_CEButton2Click(sender)
hex2 = CETrainer.CEEdit3.text*2
resultat2 = string.format("%x00", hex2)
Control_setCaption(CETrainer_CEEdit4, resultat2)
end
function CETrainer_CEButton3Click(sender)
Control_setCaption(CETrainer_CEEdit5, string.format("%#2x", hex2 + hex1))
end |
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25859 Location: The netherlands
|
Posted: Fri Jan 17, 2020 7:58 am Post subject: |
|
|
fist convert the text into binary form
Since your input is in hexadecimal (base 16) you need to convert the text that way
so use
| Code: |
hex1 = tonumber(CETrainer.CEEdit1.text,16)
if hex1==nil then
messageDialog(CETrainer.CEEdit1.text..' is an invalid number', mtError, mbOK)
return
end
|
and same for other texts _________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
grolo12 How do I cheat?
Reputation: 0
Joined: 17 Jan 2020 Posts: 8
|
Posted: Fri Jan 17, 2020 9:55 am Post subject: |
|
|
| Dark Byte wrote: | fist convert the text into binary form
Since your input is in hexadecimal (base 16) you need to convert the text that way
so use
| Code: |
hex1 = tonumber(CETrainer.CEEdit1.text,16)
if hex1==nil then
messageDialog(CETrainer.CEEdit1.text..' is an invalid number', mtError, mbOK)
return
end
|
and same for other texts |
Thank you very much Dark Byte,
works perfectly  |
|
| Back to top |
|
 |
|