[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Question on reading config files
- From: meino.cramer@...
- Date: Mon, 16 Jul 2012 05:40:52 +0200
Hi,
Currently I am programming a piece of code what will become a reader
and handler for config files. The starting point was an example code
from "Programming in Lua". The final code should read a config file
with different profiles to setup and handle serial ports so this is
only an example.
My config file has this layout currently:
profile{
first={
author="Donald E. Knuth",
title= "Literate Programming",
press= "CSLI",
year= 1992
},
second={
author= "Jon Bentley",
title= "More Programming Pearls",
press= "Addison-Wesley",
year= 1990
}
}
where "first" and "second" are names of different profiles, which the
user is allowed to name as s/he wants.
A sketch of a snippet of code which reads the config file looks like
this:
#! /usr/bin/lua
local count = 0
function profile (...)
for key, value in ipairs{...} do
-- something meaningful here
end
end
function main()
dofile("data")
end
main()
My question is: Is it possible to determine the names of the profiles
(in my example "first" and "second") from inside the code without
further input from the user land?
Thank you very much in advance for any help!
Best regards,
mcc