Advertisement
Freack100

Example of line counting

Aug 20th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.35 KB | None | 0 0
  1. --[[example for linecounting.
  2.  
  3. made by Freack100 aka laklaklak
  4.  
  5.  
  6. Note:
  7. Load it as an API
  8. ]]--
  9.  
  10. function getLineCount(file)
  11.     if not fs.exists(file) then return nil end
  12.     local handle = fs.open(file,"r")
  13.     local count = 1
  14.     local sLine = handle.readLine()
  15.     while sLine do
  16.         sLine = handle.readLine()
  17.         count = count+1
  18.     end
  19.     return count
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement