Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clear() -- A function just to clear the screen and reset the mouse.
- term.clear()
- term.setCursorPos(1, 1)
- end
- clear()
- done = false
- print("Welcome to Notebook")
- print("1. Read file")
- print("2. Write file")
- print("3. List documents")
- print("4. Exit program") -- Press any of these numbers to activate that function
- while true do
- event, key = os.pullEvent("char")
- if key == "1" then
- clear()
- print("Which file do you want to read?")
- sFile = read()
- print("Standby, opening file")
- sleep(1)
- print(file.read("notes/"..sFile, "a")) -- This is our API, remember?
- return
- elseif key == "2" then
- clear()
- print("What do you want to name the file? (No spaces)")
- sFile = read()
- print("Standby, opening file")
- sleep(1)
- clear()
- print("Type exit() to quit editing document")
- repeat
- input = read()
- if input == "exit()" then
- done = true
- else
- file.write("notes/"..sFile, "w", input)-- This is also our api
- end
- until done -- Keep looping until the input is "exit()"
- return
- elseif key == "3" then
- clear()
- shell.run("list", "notes")
- return
- elseif key == "4" then
- return
- end
- endο»Ώ
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement