Tutorial/Notebook

Welcome to a more advanced tutorial covering how to make a Notepad-ish program in ComputerCraft.

In this tutorial we'll make use of our Custom File API we made earlier. Remember to load it up with the Apiloader.

Now, create a folder named "notes" and a file named "Notebook". 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(sFile, "w", input)-- This is also our api end until done -- Keep looping until the input is "exit" elseif key == "3" then clear shell.run("list", "notes") return elseif key == "4" then return end end Phew, that was a long one right? But now you should have yourself a Notepad program.

By Brainless243