Advertisement
Marlingaming

Document Copy Edit System

Nov 19th, 2022 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. local Folder = "files"
  2.  
  3. local function PrintDoc(file,Name)
  4. local Doc = fs.open(file,"r")
  5. local I
  6. printer.newPage()
  7. printer.setTitle(Name)
  8. repeat
  9. I = Doc.readLine()
  10. if I ~= nil then printer.writeLine(I) end
  11. until I == nil
  12. Doc.close()
  13. printer.endPage()
  14. end
  15.  
  16. local function openFile(File)
  17. local Path = fs.combine("Folder",File)
  18. local Add = "Copy"
  19. fs.copy(Path,Add)
  20. shell.run("edit",Add)
  21. PrintDoc(Add,File)
  22. fs.delete(Add)
  23. os.reboot()
  24. end
  25.  
  26. local function Menu()
  27. term.clear()
  28. term.setCursorPos(1,1)
  29. print("==Government Property==")
  30. print("Public Document Access Terminal")
  31. local n = 1
  32. while true do
  33. for i = 1, #fs.list(Folder) do
  34. term.setCursorPos(3, i + 3)
  35. term.clearLine()
  36. if n == i then term.write(">> "..fs.list(Folder)[i]) else term.write(fs.list(Folder)[i]) end
  37. end
  38. local a, b = os.pullEvent("key")
  39. if b == keys.w and n > 1 then n = n - 1 end
  40. if b == keys.s and n < #fs.list(Folder) then n = n + 1 end
  41. if b == keys.enter then break end
  42. end
  43. openFile(fs.list(Folder)[n])
  44. end
  45.  
  46. Menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement