EOF

From OpenEUO
Revision as of 10:27, 24 November 2010 by Ximan (Talk | contribs) (Created page with "== Description == EOF is a unique library defined value that is employed in place of nil in certain areas. It's best to pull EOF into the global environment if needed to any...")

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

Description

EOF is a unique library defined value that is employed in place of nil in certain areas. It's best to pull EOF into the global environment if needed to any degree. The type returned by type(EOF) is 'table', so it should be explicitly tested against as a value if it is an expected return value. EOF only comes into with the file library object.

local sl = dofile(getinstalldir()..'lib/simplelib.lua')
EOF  = sl.EOF
null = sl.null
local f = sl.file(getinstalldir()..'scripts/data.dat'
local b = true
local c,d = "",""
while b ~= nil and b ~= EOF do
  b = f.readnext()
  if     b == null then c = 'nil'
  elseif b == EOF  then c = 'EOF'
  else   c = tostring(b)
  end
  d = d..' '..c
end
print(c)
-->1 A 2 TEST 3 FILE 4 EOF

See Also