File.readnext

From OpenEUO
Revision as of 15:15, 24 November 2010 by Ximan (Talk | contribs) (Created page with "== Calling Pattern == Call local f = sl.file(a,b) local r = f.readnext() Results r is of type EOF,nil,null,boolean,number,string, or table == Example Usage == h = sl.file(...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Calling Pattern

Call

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

Results

r is of type EOF,nil,null,boolean,number,string, or table

Example Usage

h = sl.file(getinstalldir()..'scripts/testread.dat', 'read') local val = true while val ~= nil and val ~= 'EOF' do

 val = h.readnext()
 if val == sl.null then val = 'null' end
 if val == sl.EOF then val = 'EOF' end
 print('val : '..tostring(val))

end

--> val : 38.333412345
    val : null
    val : null
    val : null
    val : 30
    val : TEST_
    val : true
    val : false
    val : null
    val : true
    val : 3.141622e-030
    val : table: 0x011da540
    val : EOF

Description

Readnext reads the next value stored in the associated file. If there are no more values (readnext has reached the end of the file), then readnext returns EOF. Nils written to a file are stored and returned as null.

Upon Error

Readnext returns nil if there is a problem reading a value.

See Also

  • file.readnext