Advertisement
lewisholcombe

Notes

Apr 1st, 2013
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1.  
  2. function del()
  3. term.clear()
  4. term.setCursorPos(1,1)
  5. print("Type 'clear' to remove all notes.")
  6. print("Type 'edit' to edit notes")
  7. print("Type 'exit' to return to notes.")
  8. com = read()
  9. delnavigate()
  10. end
  11.  
  12. function delnavigate()
  13. if com == "clear" then
  14. fs.delete("myNotes/notes")
  15. elseif com == "edit" then
  16. print("")
  17. print("We are working on a assisted deleting system")
  18. print("however it is not availible at the time you are")
  19. print("using this. To remove notes click the screen,")
  20. print("type into the console 'cd myNotes' and then")
  21. print("'edit notes' There will be a list of your")
  22. print("notes which you can edit.")
  23.  
  24. os.pullEvent("mouse_click")
  25. elseif com == "exit" then
  26. ask()
  27. else
  28. print("Unknown Input")
  29. print("Rebooting Delete Notes.")
  30. del()
  31. end
  32. end
  33.  
  34. function comR()
  35. com = read()
  36. navigate()
  37. end
  38.  
  39.  
  40. function ask()
  41. term.clear()
  42. term.setCursorPos(1,1)
  43. print("Type 'add' to add a note.")
  44. print("Type 'view' to view notes.")
  45. print("Type 'delete' to delete notes.")
  46. print("Type 'exit' to exit the program")
  47. comR()
  48. end
  49.  
  50. function navigate()
  51. if com == "exit" then
  52. os.reboot()
  53. elseif com == "add" then
  54. add()
  55. elseif com == "view" then
  56. view()
  57. elseif com == "delete" then
  58. del()
  59. else
  60. print("Unknown input")
  61. sleep(2)
  62. ask()
  63. end
  64. end
  65.  
  66. function add()
  67. local note = fs.open("myNotes/notes", "w")
  68.  
  69. if not fs.isDir("myNotes") then fs.makeDir("myNotes") end
  70.  
  71. print("Type your note.")
  72. print("Or type 'exit' to reboot notes")
  73. input = read()
  74.  
  75. if input == "exit" then
  76. ask()
  77. else
  78. note.writeLine("input")
  79. ask()
  80. note.close()
  81. end
  82. end
  83.  
  84. function view()
  85. handle = fs.open("myNotes/notes", "r")
  86. lines = handle.readLine()
  87. for lines in handle.readLine do
  88. print("")
  89. print("notes:")
  90. print(lines)
  91. print("Please Re-Type Command To Continue")
  92. end
  93. handle.close()
  94. comR()
  95. end
  96.  
  97. ask()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement