Posted 06 April 2012 - 01:27 PM
So I've been looking around for a while now, and I just cant work out what's wrong with my script. As usual, I'm certain it's something obvious, but I cant figure it out.
I have a table of functions (options for a menu), and when one is selected, it opens the file in the Edit program.
The table has one preset file, but the rest are listed from the directory and added to the table.
The problem I have is, when running the program I can select the preset file option, and it can be opened, edited and saved fine. However when I select one of the options that are added dynamically, it can be opened, but when trying to save the Edit program gives its "Access denied" message down the bottom. Why?
Table of functions:
EDIT: Never mind, just after I posted this I found the small typo of the file directory.. It seems the access denied error was because I was technically trying to save the file to a directory that didn't exist. I guess that's what I get for coding this at 3am last night/this morning :)/>/>
I have a table of functions (options for a menu), and when one is selected, it opens the file in the Edit program.
The table has one preset file, but the rest are listed from the directory and added to the table.
The problem I have is, when running the program I can select the preset file option, and it can be opened, edited and saved fine. However when I select one of the options that are added dynamically, it can be opened, but when trying to save the Edit program gives its "Access denied" message down the bottom. Why?
Table of functions:
tChoices = {}
tChoices[0] = "Edit scrolling text"
tActions = {}
tActions[0] = function()
sPath = "/data/news/scrolltext.txt"
os.run({}, "/wolfos/edit", sPath)
end
tAll = fs.list("/data/news")
for n, sItem in pairs(tAll) do
table.insert(tChoices, "Edit " .. sItem)
table.insert(tActions, function()
sPath = "/data/new/" .. sItem
os.run({}, "/wolfos/edit", sPath)
end)
end
EDIT: Never mind, just after I posted this I found the small typo of the file directory.. It seems the access denied error was because I was technically trying to save the file to a directory that didn't exist. I guess that's what I get for coding this at 3am last night/this morning :)/>/>
Edited on 08 April 2012 - 02:20 PM