2 This may be moved to a separate library at some point (Holiman)
6 -- Asks the user for Yes or No
7 confirm = function(message, ...)
9 message = message .. " [y/n] ?"
14 if answer == 'Y' or answer == "y" then
16 elseif answer == 'N' or answer == 'n' then
22 -- Asks the user for input
23 input = function (message , default)
25 if default ~= nil then
26 message = message .. " (default: ".. default.. " )"
28 message = message .." \n > "
32 if answer == '' then answer = default end
37 -- Converts DECIMAL to HEX
38 ConvertDec2Hex = function(IN)
39 local B,K,OUT,I,D=16,"0123456789ABCDEF","",0
42 IN,D=math.floor(IN/B),math.mod(IN,B)+1
43 OUT=string.sub(K,D,D)..OUT
48 -- Convert Byte array to string of hex
49 ConvertBytes2String = function(bytes)
51 for i = 1, #(bytes) do
52 s[i] = string.format("%02X",bytes[i])
54 return table.concat(s)