How many times do you convert decimal-to-hex or hex-to-decimal when you are in coding. SciteConvertDecHex converts the selected text to decimal or hex. You don't need external programmer's calculator application and copy&paste jobs anymore.
scite_Command {
'Convert Dec/Hex|ConvertDecHex|Alt+Shift+C',
}
function IsHexString (s)
local header = string.sub(s, 1, 2)
if "0x" == header or "0X" == header then
return true
else
return false
end
end
function ConvertDecHex ()
local current_selected_text, current_selected_length = editor:GetSelText()
local converted_number = tonumber(current_selected_text)
if not (converted_number == nil) then
local converted_text = nil
if IsHexString(current_selected_text) then
converted_text = tostring(converted_number)
else
converted_text = string.format("0x%X", converted_number)
end
editor:ReplaceSel(converted_text)
end
end
RecentChanges · preferences
edit · history
Last edited April 6, 2013 10:27 am GMT (diff)