The difference in the three macros is the first produces a decimal, the second a hex and the third a hex mask series of numbers.
So for example if five lines are marked an the macro is run with an intial value of zero the macros will produce the following results:
Numbers Macro
Code: Select all
0
1
2
3
4
Code: Select all
0x0
0x1
0x2
0x3
0x4
Code: Select all
0x01
0x02
0x04
0x08
0x10
Code: Select all
--
-- Name: Numbers Macro
--
-- Author: Jussi Jumppanen
--
-- Language: Lua Macro
--
-- Description: This simple Lua macro will replace a column marked area
-- with a series of incremental numbers. To use the macro
-- column mark a range of lines and then run the macro.
--
-- How To Run: All Zeus macros can be run using the macro execute menu
-- item or they can be bound to the keyboard or they can
-- be attached to the macro drop down or popup menus.
--
function key_macro()
-- macro only works for read/write documents.
if (is_read_only() == 1) or (is_document() == 0) then
message("This macro can only be used with a writable document.")
beep()
return
end
local MARK_COLUMN = 0
-- macro only works for column marked regions
if is_marked() == 0 or get_marked_mode() ~= MARK_COLUMN then
message("This macro needs a column marked area.")
beep()
return
end
-- the initial value
local initial_value = "0"
-- ask for a user supplied decimal number
local value = user_input("Initial Value:", initial_value)
if string.len(value) == 0 then
message("Operation cancelled by user!")
return
end
-- get the marked text details
local top = get_marked_top()
local range = get_marked_bottom() - top + 1
-- disable screen updates
screen_update_disable()
-- delete the marked area
MarkDeleteEx()
-- convert the string into a number
local offset = string.format("%d", value)
-- maximum number
local max_number = range - 1 + offset
-- the maximum length
local max_length = string.len(string.format("%s", max_number)) - 1
-- number the lines selected
for i = 0, range - 1, 1 do
-- build the number
local number = string.format("%s", i + offset)
-- save the current cursor
cursor_save()
for k = string.len(number), max_length, 1 do
-- write out the padding
write(" ")
end
-- write out the number
write(number)
-- restore cursor
cursor_restore()
-- move to the next line
MoveLineDown()
end
-- restore screen updates
screen_update_enable()
end
key_macro() -- run the macro
Code: Select all
--
-- Name: Numbers Hex Macro
--
-- Author: Jussi Jumppanen
--
-- Language: Lua Macro
--
-- Description: This simple Lua macro will replace a column marked area
-- with a series of incremental hex numbers. To use the macro
-- column mark a range of lines and then run the macro.
--
-- How To Run: All Zeus macros can be run using the macro execute menu
-- item or they can be bound to the keyboard or they can
-- be attached to the macro drop down or popup menus.
--
function key_macro()
-- macro only works for read/write documents.
if (is_read_only() == 1) or (is_document() == 0) then
message("This macro can only be used with a writable document.")
beep()
return
end
local MARK_COLUMN = 0
-- macro only works for column marked regions
if is_marked() == 0 or get_marked_mode() ~= MARK_COLUMN then
message("This macro needs a column marked area.")
beep()
return
end
-- the initial value
local initial_value = "0"
-- ask for a user supplied decimal number
local value = user_input("Initial Value:", initial_value)
if string.len(value) == 0 then
message("Operation cancelled by user!")
return
end
-- get the marked text details
local top = get_marked_top()
local range = get_marked_bottom() - top + 1
-- disable screen updates
screen_update_disable()
-- delete the marked area
MarkDeleteEx()
-- convert the string into a number
local offset = string.format("%d", value)
-- maximum number
local max_number = range - 1 + offset
-- the maximum length
local max_length = string.len(string.format("%s", max_number)) - 1
-- number the lines selected
for i = 0, range - 1, 1 do
-- build the number
local number = string.format('%X', i + offset)
-- save the current cursor
cursor_save()
-- write out the prefix
write("0x")
for k = string.len(number), max_length, 1 do
-- write out the padding
write("0")
end
-- write out the number
write(number)
-- restore cursor
cursor_restore()
-- move to the next line
MoveLineDown()
end
-- restore screen updates
screen_update_enable()
end
key_macro() -- run the macro
Code: Select all
--
-- Name: Numbers Mask Macro
--
-- Author: Jussi Jumppanen
--
-- Language: Lua Macro
--
-- Description: This simple Lua macro will replace a column marked area
-- with a series of incremental left shifted bit values. To
-- use the macro column mark a range of lines and then run
-- the macro.
--
-- How To Run: All Zeus macros can be run using the macro execute menu
-- item or they can be bound to the keyboard or they can
-- be attached to the macro drop down or popup menus.
--
function key_macro()
-- macro only works for read/write documents.
if (is_read_only() == 1) or (is_document() == 0) then
message("This macro can only be used with a writable document.")
beep()
return
end
local MARK_COLUMN = 0
-- macro only works for marked regions
if is_marked() == 0 or get_marked_mode() ~= MARK_COLUMN then
message("This macro needs a column marked area.")
beep()
return
end
-- the initial value
local initial_value = "0"
-- ask for a user supplied decimal number
local value = user_input("Initial Value:", initial_value)
if string.len(value) == 0 then
message("Operation cancelled by user!")
return
end
-- get the marked text details
local top = get_marked_top()
local range = get_marked_bottom() - top + 1
-- disable screen updates
screen_update_disable()
-- delete the marked area
MarkDeleteEx()
-- convert the string into a number
local offset = string.format("%d", value)
-- maximum number
local max_number = 2 ^ range - 1 + offset
-- the maximum length
local max_length = string.len(string.format("%s", max_number)) - 1
local x = 1
-- number the lines selected
for i = 0, range - 1, 1 do
-- build the number
local number = string.format('%X', 2 ^ i)
-- save the current cursor
cursor_save()
-- write out the prefix
write("0x")
for k = string.len(number), max_length, 1 do
-- write out the padding
write("0")
end
-- write out the number
write(number)
-- restore cursor
cursor_restore()
-- move to the next line
MoveLineDown()
end
-- restore screen updates
screen_update_enable()
end
key_macro() -- run the macro