Difference between revisions of "Fs.list"
From ComputerCraft Wiki
Zalerinian (Talk | contribs) (fixed my own formatting error.) |
Zalerinian (Talk | contribs) (fixed code error.) |
||
Line 11: | Line 11: | ||
|code=abc = fs.list("") | |code=abc = fs.list("") | ||
i = 1 | i = 1 | ||
− | while i ~= | + | while i ~= 15 do |
print(abc[i]) | print(abc[i]) | ||
i = i+1 | i = i+1 | ||
Line 24: | Line 24: | ||
i = 1 <- sets i equal to one. | i = 1 <- sets i equal to one. | ||
− | while i ~= | + | while i ~= 15 do <- While i is not 15, continue to do this. |
print(abc[i]) <- print the files and directories. | print(abc[i]) <- print the files and directories. | ||
Line 31: | Line 31: | ||
end <- end the loop. | end <- end the loop. | ||
+ | |||
+ | |||
+ | this code will print 15 lines, blank or not, with the contents of the root directory. |
Revision as of 16:49, 27 May 2012
Function fs.list | |
Returns a list of all the files contained in a directory as a table | |
Syntax | fs.list(string path) |
Returns | table list of files and folders in path, which must be a directory |
Part of | ComputerCraft |
API | fs |
Examples
abc = fs.list("") <- will get all the files and directories in the system root into a table, all saved as 'abc'.
i = 1 <- sets i equal to one.
while i ~= 15 do <- While i is not 15, continue to do this.
print(abc[i]) <- print the files and directories.
i = i+1 <- add 1 to i each run so a different file/directory gets listed next.
end <- end the loop.
this code will print 15 lines, blank or not, with the contents of the root directory.