lua-users home
lua-l archive

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


Hi!

2010/3/7 Luciano de Souza <luchyanus@predialnet.com.br>:
> Hello,
>
> Suppose we have the following table:
>
> t =
>
> {
>
> {country = 'Brazil', city = 'São Paulo'},
>
> {country = 'Italy', city = 'Napoli'},
>
> {country = 'France', city = 'Nantes'},
>
> {country = 'United States', city = 'Chicago'}
>
> }
>
> I know how to add or remove elements. But, how to save it in a file?

Your problem is known as "serialization"
(http://en.wikipedia.org/wiki/Serialization, someone may add a Lua
example here). Take a look at http://www.lua.org/pil/12.1.html or
http://lua-users.org/wiki/TableSerialization.

Regards,
Matthias