Module:MOS modes: Difference between revisions

Ganaram inukshuk (talk | contribs)
mNo edit summary
Ganaram inukshuk (talk | contribs)
No edit summary
Line 81: Line 81:


-- This is for entering multiple columns of info, if a single column of mode names isn't enough
-- This is for entering multiple columns of info, if a single column of mode names isn't enough
-- For n column headers, the number of entries must match the number of modes times the number of headers
-- For n headers, the number of entries must match the number of modes times the number of headers
-- or else column data won't be added
-- or else column data won't be added
local column_headers_unparsed = frame.args['Column Headers']
local headers_unparsed = frame.args['Headers']
local column_headers = p.parse_entries(column_headers_unparsed)
local headers = p.parse_entries(headers_unparsed)
local column_entries_unparsed = frame.args['Column Entries']
local entries_unparsed = frame.args['Entries']
local column_entries = p.parse_entries(column_entries_unparsed)
local entries = p.parse_entries(entries_unparsed)


-- To determine whether to add additional columns, determine whether the number of entries
-- To determine whether to add additional columns, determine whether the number of entries
-- and the number of columns are nonzero, and if so, determine whether the number of entries
-- and the number of columns are greater than zero, and if so, determine whether the number of entries
-- divided by the number of columns exactly matches the number of modes
-- is equal to the number of headers times the number of modes
local add_columns = number_of_columns ~= 0 and number_of_entries ~= 0
local add_columns = number_of_columns > 0 and number_of_entries > 0
if add_columns then
if add_columns then
add_columns = add_columns and #column_entries / #column_headers == number_of_modes
add_columns = add_columns and #modes * #headers == #entries
end
end
Line 112: Line 112:
-- If mode names and columns are used, mode names come first
-- If mode names and columns are used, mode names come first
if add_columns then
if add_columns then
for i = 1, #column_headers do
for i = 1, #headers do
result = result .. "! " .. column_headers[i] .. "\n"
result = result .. "! " .. headers[i] .. "\n"
end
end
end
end
Line 141: Line 141:
-- Add columns if given
-- Add columns if given
if add_columns then
if add_columns then
for j = 1, #column_headers do
for j = 1, #headers do
result = result .. "|" .. column_entries[i + j - 1] .. "\n"
result = result .. "|" .. entries[i + j - 1] .. "\n"
end
end
end
end