lua-users home
lua-l archive

RE: Table element addressing syntax

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


> untested code:
> 
> function GetElement(table, field)
> 	local pos = strfind(field,".")
> 	if pos then 
> 		return GetElement(table[strsub(field,1,pos-1)],
strsub(field,pos+1)) 
> 	end
> 	return table[field]
> end
That's a step in the right direction. I guess for an arbitrary field
string, which may have any number of periods, you just iteratively get
the next table, get the appropriate field, rinse, and repeat.
Thanks,
Curt

AltStyle によって変換されたページ (->オリジナル) /