Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function load(name)
- local file = fs.open(name,"r")
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- function save(table,name)
- local file = fs.open(name,"w")
- file.write(textutils.serialize(table))
- file.close()
- end
- function printTable(table)
- if #table ~= 0 then
- for i=1,#table do
- print("Todo List:")
- write(i)
- write(" ")
- print(table[i])
- end
- end
- end
- function EditList()
- print("Current List:")
- printTable(table)
- print("Enter the task to edit")
- edit = io.read()
- clrc()
- write("Editing ")
- print(edit)
- print(table[edit])
- table[edit] = io.read()
- end
- function clrc()
- term.clear()
- term.setCursorPos(1,1)
- end
- function Addtolist()
- while input ~= "q" or "Q"do
- clrc()
- print("Adding to list (Enter q to Quit):\n")
- write(count)
- write(" ")
- input = io.read()
- if input ~= "q" or "Q" then
- table[count] = input
- end
- count = count + 1
- end
- end
- clrc()
- local table = {}
- local input = ""
- local edit
- if fs.exists("list") then
- table = load("list")
- print("Existing List found.")
- end
- local count = #table + 1
- local choice = 0
- while choice ~= 4 do
- clrc()
- print("Todo List Program:")
- print("1. Print Todo List")
- print("2. Add to the List")
- print("3. Edit part of List")
- print("4. Quit")
- input = io.read()
- if input == 1 then
- printTable()
- end
- if input == 2 then
- Addtolist()
- end
- if input == 3 then
- EditList()
- end
- if input == 4 then
- choice = 4
- end
- end
- clrc()
- save(table,"list")
- print("Todo List:")
- printTable(table)
- print("Program is not running:")
- print("Type todolist to run the program")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement