View previous topic :: View next topic |
Author |
Message |
Razi Expert Cheater
Reputation: 1
Joined: 17 Jan 2018 Posts: 205
|
Posted: Sun Nov 17, 2019 6:05 pm Post subject: Hexadecimal calculations in the edit box |
|
|
How to perform hexadecimal calculations in the edit box? I want to perform hexadecimal calculations in the edit box with mouse wheel. Example:
Code: | local function incrvalhex(editbox)
if tonumber(editbox.Text) == nil then
editbox.Text ='00'
else
local a = tonumber(editbox.Text,16) +0x1
editbox.Text = string.format('0%X', a)
end
end
local function decrvalhex(editbox)
if tonumber(editbox.Text) == nil then
editbox.Text ='00'
else
local a = tonumber(editbox.Text,16) -0x1
editbox.Text = string.format('0%X', a)
end
end
MainForm.scanvalue.OnMouseWheelUp = function()
if MainForm.cbHexadecimal.Checked == true then
incrvalhex(MainForm.scanvalue)
end
end
MainForm.scanvalue.OnMouseWheelDown = function()
if MainForm.cbHexadecimal.Checked == true then
decrvalhex(MainForm.scanvalue)
end
end |
But, the code above does not work. Where is the error in the code? |
|
Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sun Nov 17, 2019 6:37 pm Post subject: |
|
|
Code: | local function changeHex(delta)
if MainForm.cbHexadecimal.Checked then
if MainForm.scanvalue.Text=='' then MainForm.scanvalue.Text='0' end
local value = tonumber(MainForm.scanvalue.Text,16)+delta
MainForm.scanvalue.Text = string.format('%016X',value) -- leading zeros and length always 16 digits
end
end
MainForm.scanvalue.OnMouseWheelUp = function() changeHex(-1) end
MainForm.scanvalue.OnMouseWheelDown = function() changeHex(1) end |
_________________
|
|
Back to top |
|
 |
Razi Expert Cheater
Reputation: 1
Joined: 17 Jan 2018 Posts: 205
|
Posted: Sun Nov 17, 2019 7:26 pm Post subject: |
|
|
Thanks. I also want to add same function (OnMouseWheel Up\Down) to the "Change address" window to the address edit box (editAddress), but the problem is that the addresses there are displayed in two formats, in the format 009D874E and in the format "ePSXe.exe" + 5D874E. How to add +0x01 to this address "ePSXe.exe" + 5D874E ? So, after the “OnMouseWheelUp” event, the address will become “ePSXe.exe” + 5D874F or “OnMouseWheelDown” event, the address will become “ePSXe.exe” + 5D874D. |
|
Back to top |
|
 |
|