Difference between revisions of "File.readall"

From OpenEUO
Jump to: navigation, search
(See Also)
m (Upon Error)
 
Line 35: Line 35:
 
== Upon Error ==
 
== Upon Error ==
  
Readall returns [[nil]] if there is a problem reading the file.
+
Readall returns [[nil]] if there is a problem reading the file. Erroneous entries in the structured file return as a string, 'ERROR'.
  
 
== See Also ==
 
== See Also ==

Latest revision as of 15:23, 24 November 2010

Calling Pattern

Call

local f = sl.file(a,b)
local r = f.readall()

Results

r is of type table (or nil upon error).

Example Usage

h = sl.file(getinstalldir()..'scripts/testread.dat', 'read')
local val = h.readall()
print(keyvalstr(val))
--> table keys:values = {
    1:38.333412345,
    2:null,
    3:null,
    4:null,
    5:30,
    6:TEST_,
    7:true,
    8:false,
    9:null,
    10:true,
    11:3.141622e-030,
    12:table: 0x011da540,
    }

Description

Readall reads all remaining values stored in the associated file from the current cursor position. If there are no more values (readnext has reached the end of the file), then readall returns EOF. Nils written to a file are stored and returned as null.

Upon Error

Readall returns nil if there is a problem reading the file. Erroneous entries in the structured file return as a string, 'ERROR'.

See Also