Log In  


Cart #54225 | 2018-07-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA


I am trying to get a program to list the files in the current directory. The Wiki says that ls() outputs a table of the folder's contents, but it gives me a [NIL] for every item in the folder. Why is that? Does anyone know how to do this?
Thanks!



I think you're trying to index (incorrectly) from within the print command.

I've just tried this and it worked:

files=ls()
cls()
print("count: "..#files)
for file in all(files) do
 print(file)  -- no need to index here, as the "for" gives you the actual value
end

Thanks! That did the trick. That made me feel like a doofus.



[Please log in to post a comment]