lua-users home
lua-l archive

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

On Mar 7, 2010, at 7:09 PM, Luciano de Souza wrote:

> But, how to save it in a file?

As mentioned, you need to serialize (i.e. create a string representation) your table.

For example:

local Data = require( 'Data' )

-- save the content of table 't' to file 't.txt'
Data[ 't.txt' ] = t

-- load the content of file 't.txt' into variable 't'

t = Data[ 't.txt' ]

-- print the content of table 't' as a string
print( Data( t ) )

_[1]["city"]="São Paulo"
_[4]["country"]="United States"

Attachment: Data.lua
Description: Binary data