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/o@uNggD@+p,PxRQnLS?3QkQ](PT]OUy{tFj]uvxy0_.^^4B,[9qjeV0iW)2VVD#i;aMN^w(N!wLXlLfy^GA$B8nA*qvj@sD7QsDye=2xNR/C5WR;q;7rHSt0e[(hVp[lz#h3#DQ9MhdEn6$m_8:,MYx8/1LjdK0o!u48Xo!ypZ8cm/fKgm#![9tEeK=3xkJK$y0SoSlW6jU.)CjwV{_R5;O5_-DB)i7bu!T+a?rb}[80=!=eMnG:O7=^=IkIV^q!zn/Kr%*M2z8[i{a2(MJR4WLi!P+kS},3wpaU!NZDln.;Sy21tc6}6+UlYwO5Z%L+C^K97E+ke[[;GTYZ@Zbyik=Ag8Bbx_%z)v!KUfSQy4)HkQY{)(EOlV%FMA1!m)}cdz.Oq=twXoq5!m:ZO!S#MdJ6ah/52QBIU.cK9r$V44M;;1qMcECOWd9wvm10Urt(36RMZp*-+6.+;NZ+%ADv!^?A?O10(/7QjN=6R{f;1Qwe?RR5xVmDuSsCX;r--QEhJ-3r.}uxRGO%_:TIvTX8Eq3GELjly7wj8Jy^x@b$q^(x5E[sz:H(s_qrO6:?[/U=n]Iw94@Dw/%(2MUqOXiFK?Em}d84Q:%gdIoRSk4Jegfy4twmv+V3j=jTt5b+Jsf}I$+zMv2X8zsLU=yGUSd0Wh4ODW]Fg@@;HRFxenYszCNiGDw9++Mt^8K1wDBu;72hoXk@XQ?v?pf:,Q@3hHwU+zzotBQWB+!iP0*mI-_ig?{D!fMSF+Ut!8=vMzb?.K$f!dIzG@:-3_^]OA%AKjbYkN7m[^mef</hcSubForm>
  </Forms>
  <CheatEntries/>
  <UserdefinedSymbols/>
  <LuaScript>-- Hex Values Converter
-- by AltairPL


--GLOBAL VARIABLES DECLARATION--

-- set number of sub-forms displayed at start
DefaultFormCount = 3
-- set value types selected by default in sub-form combo-boxes (list position counted from 0)
DefaultDecType = 2
DefaultHexType = 0
-- set default sub-form toggle-boxes states (0: off, 1: on)
DefaultSigned = 0
DefaultMode = 0
-- set sub-form template temporary filename
TemplateFileName = "hcSubFormTemplate.frm"
-- string byte separators
SeparatorHexValue = ""
SeparatorArrayOfBytes = " "


--FUNCTIONS REQUIRED BY CONVERSION TABLES DECLARATION--

-- added for compatibility with built-in CE functions
function byteToByteTable(value)
	value = tonumber(value)
	-- return one element table containing 0 (if out of bounds) or number
	if not value or value &lt; -128 or value &gt; 255 then return({0}) else return({value}) end
end

-- added for compatibility with built-in CE functions
function byteTableToByte(byteTable)
	return(byteTable[1])
end


--VARIOUS TABLES DECLARATION--

-- decimal/string to bytes table conversion table
-- keys: selected decimal/string type
dec2hexTable = {
	[0] = byteToByteTable,
	[1] = wordToByteTable,
	[2] = dwordToByteTable,
	[3] = qwordToByteTable,
	[4] = floatToByteTable,
	[5] = doubleToByteTable,
	[6] = stringToByteTable,
	[7] = wideStringToByteTable
}

-- bytes table to decimal/string conversion table
-- keys: selected decimal/string type
hex2decTable = {
	[0] = byteTableToByte,
	[1] = byteTableToWord,
	[2] = byteTableToDword,
	[3] = byteTableToQword,
	[4] = byteTableToFloat,
	[5] = byteTableToDouble,
	[6] = byteTableToString,
	[7] = byteTableToWideString
}

-- bytes size table
-- keys: selected decimal/string type
bytesSizeTable = {
	[0] = 1,
	[1] = 2,
	[2] = 4,
	[3] = 8,
	[4] = 4,
	[5] = 8
}

-- minimum/maximum decimal values table
-- level 1 keys: signed box state
-- level 2 keys: selected decimal/string type
-- level 3 - key: minimum, value: maximum
minmaxTable = {
	[0] = {
		[0] = {[0] = 255},
		[1] = {[0] = 65535},
		[2] = {[0] = 4294967295},
		-- [3] = {[0] = 18446744073709551615},										-- proper min/max for qword
		[3] = {[0] = 9223372036854775807},
	},
	[1] = {
		[0] = {[-128] = 127},
		[1] = {[-32768] = 32767},
		[2] = {[-2147483648] = 2147483647},
		-- [3] = {[-9223372036854775808] = 9223372036854775807},	-- proper min/max for qword
		[3] = {[-9223372036854775806] = 9223372036854775807},
	},
}

-- create sub-forms table
subForms = {}


--GLOBAL FUNCTIONS DECLARATION--

-- add sub-form
function addSubForm(sender, sfCount)
	sfCount = sfCount or 1
	-- save template to file
	hcSubForm.saveToFile(TemplateFileName)
	-- create sub-form from this file
	for i = 1, sfCount do
		local sForm = createFormFromFile(TemplateFileName)
		-- configure sub-form
		sForm.Parent = hcMainForm
		sForm.Top = 30 + #subForms * 80
		sForm.decCBox.ItemIndex = DefaultDecType
		sForm.hexCBox.ItemIndex = DefaultHexType
		sForm.signedTBox.setState(DefaultSigned)
		sForm.modeTBox.setState(DefaultMode)
		sForm.Visible = true
		sForm.DoNotSaveInTable = true
		-- add sub-form to the table
		table.insert(subForms, sForm)
	end
	-- delete template file
	os.remove(TemplateFileName)
	-- adjust window size
	hcMainForm.Height = 30 + #subForms * 80
end

-- remove sub-form
function removeSubForm(sender)
	-- beep and return on attempt to close last sub-form
	if #subForms == 1 then
		beep()
		return
	end
	-- -- remove last sub-form from the table and close it
	table.remove(subForms).close()
	-- adjust window size
	hcMainForm.Height = 30 + #subForms * 80
end

-- assigned to combo-boxes' OnChange and called by signedToggle() and modeToggle() functions
function refreshValues(sender)
	-- fetch sender owner form
	local sForm = sender.Owner
	-- force values refresh depending on mode toggle-box state
	if sForm.modeTBox.getState() == 0 then decChange(sForm.decEBox) else hexChange(sForm.hexEBox) end
end

-- assigned to signed toggle-box' OnChange
function signedToggle(sender)
	-- change accordingly own caption
	if sender.getState() == 0 then sender.Caption = "unsigned" else sender.Caption = "signed" end
	-- call function to refresh values
	refreshValues(sender)
end

-- assigned to mode toggle-box' OnChange
function modeToggle(sender)
	-- fetch sender owner form
	local sForm = sender.Owner
	-- change accordingly own caption and edit-boxes' ReadOnly property
	if sender.getState() == 0 then
		sender.Caption = "=&gt;"
		sForm.decEBox.ReadOnly = false
		sForm.hexEBox.ReadOnly = true
		sForm.decEBox.setFocus()
	else
		sender.Caption = "&lt;="
		sForm.decEBox.ReadOnly = true
		sForm.hexEBox.ReadOnly = false
		sForm.hexEBox.setFocus()
	end
	-- call function to refresh values
	refreshValues(sender)
end

-- assigned to decimal/string edit-box' OnChange
function decChange(sender)
	-- if this edit-box is used for input in current mode
	if not sender.ReadOnly then
		-- fetch sender owner form
		local sForm = sender.Owner
		-- store note label in local variable - used on various occasions
		local label = sForm.noteLabel
		-- store selected decimal/string value type in local variable - used on various occasions
		local decType = sForm.decCBox.ItemIndex
		-- if text is empty string, set empty string to other edit-box and hide note label
		if sender.Text == "" then
			sForm.hexEBox.Text = ""
			label.Visible = false
			return
		end
		-- if any number value type is selected
		if decType &lt; 6 then
			-- convert inputted value to number and store in local variable
			local vInput = tonumber(sender.Text)
			-- if value is a number
			if vInput then
				-- if any integer value type is selected
				if decType &lt; 4 then
					-- fetch minimum and maximum values for current conditions ((un)signed, selected decimal/string type)
					local vMin, vMax = next(minmaxTable[sForm.signedTBox.getState()][decType])
					-- and use them to modify vInput variable
					vInput = vInput &gt;= vMin and vInput &lt;= vMax
					-- if qword value type is selected
					if decType == 3 then
						-- set warning message to note label
						label.Visible = true
						label.Font.Color = 0xFF0000
						label.Caption = "Warning: Lua cannot properly handle this type!"
					-- if any other integer value type is selected - hide note label
					else
						label.Visible = false
					end
				-- if float or double value type is selected
				else
					-- set warning message to note label
					label.Visible = true
					label.Font.Color = 0xFF0000
					label.Caption = "Warning: Float/Double conversion may be inaccurate!"
				end
			end
			-- if value is not a number or it is out of bounds
			if not vInput then
				-- make sound and set empty string to other edit-box
				beep()
				sForm.hexEBox.Text = ""
				-- set error message to note label
				label.Visible = true
				label.Font.Color = 0x0000FF
				label.Caption = "Error: Inputted value is invalid or out of bounds!"
				return
			end
		-- if any string value type is selected - only hide note label
		else
			label.Visible = false
		end
		-- convert value to bytes table and store it in local variable
		local hexBytes = dec2hexTable[decType](sender.Text)
		-- convert bytes values to formatted strings
		for k,v in ipairs(hexBytes) do hexBytes[k] = string.format("%02X", v) end
		-- if hex value is selected as hex value type
		if sForm.hexCBox.ItemIndex == 0 then
			-- create table with reversed byte order
			local tempSize = #hexBytes
			local hexBytesR = {}
			for k,v in ipairs (hexBytes) do hexBytesR[tempSize - k + 1] = v end
			-- set value to hex edit-box
			sForm.hexEBox.Text = table.concat(hexBytesR, SeparatorHexValue)
		-- if array of bytes is selected as hex value type
		else
			-- set value to hex edit-box
			sForm.hexEBox.Text = table.concat(hexBytes, SeparatorArrayOfBytes)
		end
	end
end

-- assigned to hexadecimal edit-box' OnChange
function hexChange(sender)
	-- if this edit-box is used for input in current mode
	if not sender.ReadOnly then
		-- fetch sender owner form
		local sForm = sender.Owner
		-- store note label in local variable - used on various occasions
		local label = sForm.noteLabel
		-- if text is empty string, set empty string to other edit-box and hide note label
		if sender.Text == "" then
			sForm.decEBox.Text = ""
			label.Visible = false
			return
		end
		-- create temp string by removing all spaces from inputted text
		tempString = sender.Text:gsub("%s+", "")
		-- if string contains not allowed characters
		if tempString:find("%X") then
			-- set error message to note label
			label.Visible = true
			label.Font.Color = 0x0000FF
			label.Caption = "Error: Inputted value is invalid!"
			return
		end
		-- create byte table
		local hexBytes = {}
		-- if hex value is selected as hex value type
		if sForm.hexCBox.ItemIndex == 0 then
			-- add leading zero to the string if number of digits is not even
			if (#tempString % 2) == 1 then tempString = "0"..tempString end
			-- create table for reversed byte order
			local hexBytesR = {}
			-- add byte values converted to numbers to the table
			for byte in string.gmatch(tempString, "..") do table.insert(hexBytesR, tonumber(byte,16)) end
			-- create table with "normal" byte order
			local tempSize = #hexBytesR
			for k,v in ipairs (hexBytesR) do hexBytes[tempSize - k + 1] = v end
		-- if array of bytes is selected as hex value type
		else
			-- add leading zero to the last byte if number of digits is not even
			if (#tempString % 2) == 1 then tempString = tempString:sub(1, #tempString - 1).."0"..tempString:sub(#tempString, #tempString) end
			-- add byte values converted to numbers to the table
			for byte in string.gmatch(tempString, "..") do table.insert(hexBytes, tonumber(byte,16)) end
		end
		-- store selected decimal/string value type in local variable
		local decType = sForm.decCBox.ItemIndex
		-- initialize result flag
		local result = false
		-- if any number value type is selected
		if decType &lt; 6 then
			-- update result flag by checking if max byte size was not exceeded
			result = #hexBytes &lt;= bytesSizeTable[decType]
			-- if max byte size not exceeded
			if result then
				-- store decimal value in result variable
				result = hex2decTable[sForm.decCBox.ItemIndex](hexBytes)
				-- if any integer value type is selected
				if decType &lt; 4 then
					-- if signed toggle-box is enabled
					if sForm.signedTBox.getState() == 1 then
						-- fetch minimum and maximum values for current conditions ((un)signed, selected decimal/string type)
						local vMin, vMax = next(minmaxTable[1][decType])
						-- if value exceeds maximum use minimum to modify result variable
						if result &gt; vMax then result = result + 2 * vMin end
					end
					-- if qword value type is selected
					if decType == 3 then
						-- set warning message to note label
						label.Visible = true
						label.Font.Color = 0xFF0000
						label.Caption = "Warning: Lua cannot properly handle this type!"
					-- if any other integer value type is selected - hide note label
					else
						label.Visible = false
					end
				-- if float or double value type is selected
				else
					-- set warning message to note label
					label.Visible = true
					label.Font.Color = 0xFF0000
					label.Caption = "Warning: Float/Double conversion may be inaccurate!"
				end
			-- if max byte size exceeded
			else
				-- make sound and set empty string to other edit-box
				beep()
				sForm.decEBox.Text = ""
				-- set error message to note label
				label.Visible = true
				label.Font.Color = 0x0000FF
				label.Caption = "Error: Inputted value is out of bounds!"
				return
			end
		-- if string is selected as decimal/string value type
		else
			-- if string is selected as decimal/string value type
			if decType == 6 then
				-- for every hexBytes table index
				for i = 1, #hexBytes do
					-- set result variable to true and break if byte value is 0
					if hexBytes[i] == 0 then
						result = true
						break
					end
				end
			-- if wide string is selected as decimal/string value type
			elseif decType == 7 then
				-- for every hexBytes table index
				for i = 1, #hexBytes, 2 do
					-- set result variable to true and break if this byte value is 0 and next byte value is 0 or nil
					if hexBytes[i] == 0 and (not hexBytes[i+1] or hexBytes[i+1] == 0) then
						result = true
						break
					end
				end
			end
			-- if null-terminated string
			if result then
				-- set warning message to note label
				label.Visible = true
				label.Font.Color = 0xFF0000
				label.Caption = "Warning: Probably null-terminated string!"
			-- if not null-terminated string - hide note label
			else
				label.Visible = false
			end
			-- convert bytes to string/wide string and store it in result variable
			result = hex2decTable[sForm.decCBox.ItemIndex](hexBytes)
		end
		-- set result text to decimal/string edit-box
		sForm.decEBox.Text = result
	end
end

-- assigned to edit-boxes' OnDblClick - select whole contents of the box
function SelectText(sender)
	sender.selectAll()
end

-- assigned to sub-form's OnClose
function sfOnClose(sender)
	return caFree
end

-- assigned to main-form's OnClose
function hcOnClose(sender)
	-- close form without closing CE if script launched from CE
	if getMainForm().Visible then
		-- return caHide
		return caHide
	-- close dialog along with CE if stand-alone
	else
		closeCE()
		return caFree
	end
end


--MAIN SCRIPT--

-- create starting sub-forms
addSubForm(nil, DefaultFormCount)
-- show main converter form
form_show(hcMainForm)

</LuaScript>
</CheatTable>
