Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
SetLabels: Updated error checking
  • Loading branch information
smurfier committed May 11, 2014
1 parent 758ad4d commit 130bbcf
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions @Resources/CScript.lua
Expand Up @@ -260,19 +260,20 @@ end -- ExpandFolder
function SetLabels(tbl) -- Sets weekday label text
Error.Source = 'SetLabels'

if type(tbl) == 'table' then
if #tbl ~= 7 then
Error.Create('Input must be a table with seven indicies. Using default table instead.')
tbl = {'S', 'M', 'T', 'W', 'T', 'F', 'S'}
end
if Settings.StartOnMonday then
table.insert(tbl, table.remove(tbl, 1))
end
for Label, Text in ipairs(tbl) do
SKIN:Bang('!SetOption', Meters.Labels.Name:format(Label - 1), 'Text', Text)
end
else
Error.Create('Input must be a table. Received %s instead.', type(tbl))
if type(tbl) ~= 'table' then
Error.Create('Input must be a table. Received %s instead. Using default table.', type(tbl))
tbl = {'S', 'M', 'T', 'W', 'T', 'F', 'S'}
elseif #tbl ~= 7 then
Error.Create('Input must be a table with seven indicies. Using default table instead.')
tbl = {'S', 'M', 'T', 'W', 'T', 'F', 'S'}
end

if Settings.StartOnMonday then
table.insert(tbl, table.remove(tbl, 1))
end

for Label, Text in ipairs(tbl) do
SKIN:Bang('!SetOption', Meters.Labels.Name:format(Label - 1), 'Text', Text)
end
end -- SetLabels

Expand Down

0 comments on commit 130bbcf

Please sign in to comment.