File.tofile
From OpenEUO
Calling Pattern
Call
local f = sl.file(a,b)
local r = f.tofile(c[,...])
Args
c1...cN are any of: nil, null, boolean, number, string, or table
Results
r is a boolean
Example Usage
local t = {[3.14] = 0.7071, [' una ']=1, test='Some "random" string.'} local f = sl.file(getinstalldir()..'scripts/testwrite.dat', 'write') f.tofile(t) f.finalize() f = nil local g = sl.file(getinstalldir()..'scripts/testwrite.dat', 'read') local v = g.readnext() g = nil print(sl.keyvalstr(v))
--> table keys:values = { una :1, test:Some "random" string., 3.14:0.7071, }
Description
The tofile method writes the given data to a structured file and flushes the file buffer. In version 0.06 will return a boolean denoting success or failure.
Upon Error
Tofile fails silently if passed an invalid type (function, thread, userdata).