Difference between revisions of "EOF"

From OpenEUO
Jump to: navigation, search
(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...")
 
m (Description)
 
Line 6: Line 6:
 
  EOF  = sl.EOF
 
  EOF  = sl.EOF
 
  null = sl.null
 
  null = sl.null
  local f = sl.file(getinstalldir()..'scripts/data.dat'
+
  local f = sl.file(getinstalldir()..'scripts/data.dat')
 
  local b = true
 
  local b = true
 
  local c,d = "",""
 
  local c,d = "",""
Line 20: Line 20:
  
 
  -->1 A 2 TEST 3 FILE 4 EOF
 
  -->1 A 2 TEST 3 FILE 4 EOF
+
 
 
== See Also ==  
 
== See Also ==  
  

Latest revision as of 10:28, 24 November 2010

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