Advertisement
Namentis

Untitled

Aug 26th, 2015
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. function clear() -- A function just to clear the screen and reset the mouse.
  2. term.clear()
  3. term.setCursorPos(1, 1)
  4. end
  5.  
  6.  
  7. clear()
  8.  
  9. done = false
  10.  
  11. print("Welcome to Notebook")
  12. print("1. Read file")
  13. print("2. Write file")
  14. print("3. List documents")
  15. print("4. Exit program") -- Press any of these numbers to activate that function
  16.  
  17. while true do
  18. event, key = os.pullEvent("char")
  19.  
  20. if key == "1" then
  21. clear()
  22. print("Which file do you want to read?")
  23. sFile = read()
  24. print("Standby, opening file")
  25. sleep(1)
  26. print(file.read("notes/"..sFile, "a")) -- This is our API, remember?
  27. return
  28.  
  29. elseif key == "2" then
  30. clear()
  31. print("What do you want to name the file? (No spaces)")
  32. sFile = read()
  33. print("Standby, opening file")
  34. sleep(1)
  35. clear()
  36. print("Type exit() to quit editing document")
  37. repeat
  38. input = read()
  39. if input == "exit()" then
  40. done = true
  41. else
  42. file.write("notes/"..sFile, "w", input)-- This is also our api
  43. end
  44. until done -- Keep looping until the input is "exit()"
  45. return
  46.  
  47. elseif key == "3" then
  48. clear()
  49. shell.run("list", "notes")
  50. return
  51. elseif key == "4" then
  52. return
  53. end
  54. endο»Ώ
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement