Advertisement
shadowkat1010

sked

Apr 27th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. local b = {}
  2. local l = 1
  3. while true do
  4. local command = io.read()
  5. if command == "l" then for k,v in pairs(b) do print(v) end
  6. elseif command == "lc" then print(b[l])
  7. elseif command == "s" then --Seek
  8. print">"
  9. l = tonumber(io.read())
  10. elseif command == "so" then --Output line
  11. print(l)
  12. elseif command == "a" then --Append
  13. print":"
  14. table.insert(b,l,io.read()) l = l + 1
  15. elseif command == "r" then --Replace
  16. print":"
  17. b[l]=io.read()
  18. elseif command == "d" then --Delete
  19. print(table.remove(b,l))
  20. elseif command == "o" then --Load
  21. print">"
  22. local rF = io.read()
  23. local f = io.open(rF,"r")
  24. local a=f:read()
  25. repeat table.insert(b,a) print(a) a=f:read("*l") until a==nil
  26. f:close()
  27. elseif command == "w" then --Save
  28. print">"
  29. local wT = io.read()
  30. local f = io.open(wT,"w")
  31. for k,v in pairs(b) do f:write(v.."\n") end f:close()
  32. elseif command == "e" then break else print"?" end end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement