RosettaCodeData/Task/Read-a-configuration-file/Icon/read-a-configuration-file.icon
2014-01-17 05:34:36 +00:00

30 lines
596 B
Text

procedure main(A)
ws := ' \t'
vars := table()
every line := !&input do {
line ? {
tab(many(ws))
if any('#;') | pos(0) then next
vars[map(tab(upto(ws)\1|0))] := getValue()
}
}
show(vars)
end
procedure getValue()
ws := ' \t'
a := []
while not pos(0) do {
tab(many(ws))
put(a, trim(tab(upto(',')|0)))
move(1)
}
return a
end
procedure show(t)
every pair := !sort(t) do {
every (s := pair[1]||" = ") ||:= !pair[2] || ", "
write(s[1:-2])
}
end