lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> But if you do, in fact, need your parameters to be traversed 
> in order, and that order is consistent throughout, this will work:
> 
>     -- Specify order for parameters.
>     local paramNames = "name server IP domain class license JDK " ..
>                        "WebLogicVersion Console instance port"
> 

That's much neater than my suggestion. Another variation would be to
store the keys to the named fields in a table:

local paramNames = { "name", "server", "IP", etc...}

Then iterate paramNames using ipairs, and using that to index into the
table in Project. This avoids having to parse the string each time, and
might be faster for really large datasets. I don't know this for sure
though, and the difference might be trivial. In fact I am really just
guessing :-)

function Project(table)
	for i,v in ipairs(paramNames) do
		if table[v] then 
			print(table[v]) 
		end
	end

	-- iteration of subtables is as before.
end

- DC