Posted 29 October 2012 - 09:52 AM
Hey everyone ;D
I have perfectly working function that list's all the programs in a floppy disk which displays when you click enter for 'List left' or 'List right'. Everything works great but the code for listing will take too much if I do it the way I've done it now. So I went to check the the 'list' file because the list command works awesome.
I have no clue what's happening within the list file and have no clue how it does all the sorting, getting file names etc. Can someone show me how to change this function so it sort's it by itself? Thanks.
Pictures:
Left Disk
I have perfectly working function that list's all the programs in a floppy disk which displays when you click enter for 'List left' or 'List right'. Everything works great but the code for listing will take too much if I do it the way I've done it now. So I went to check the the 'list' file because the list command works awesome.
function listFiles()
cX,cY = term.getSize()
for i =1, cX-1 do cp(i,2) write('-') end
cp(1,1)
local selection = menuW("OK", "List left", "List right")
if selection == "OK" then lol()
elseif selection == "List left" then
term.clear()
if disk.isPresent(side_CopyFrom) then
fileList = fs.list("disk")
if fileList[1] then
status = #fileList.." files"
for i = 1, #fileList do
if i < 14 then
cp(1,i+4)
print(" - "..fileList[i])
elseif i >= 14 then
cp(15,i-13+4)
print(" - "..fileList[i])
end
end
else
print(err["NoDataFound"])
status = "No Data"
end
else
print(err["NoDiskFound"])
status = "No Disk"
end
cp(1,3) print("Left disk ["..status.."]")
elseif selection == "List right" then
term.clear()
if disk.isPresent(side_CopyTo) then
if disk.isPresent(side_CopyFrom) then fileList = fs.list("disk2") else fileList = fs.list("disk") end
cp(30,1) print(#fileList)
if fileList[1] then
status = #fileList.." files"
for i = 1, #fileList do
if i < 14 then
cp(1,i+4)
print(" - "..fileList[i])
elseif i >= 14 then
cp(15,i-13+4)
print(" - "..fileList[i])
end
end
else
print(err["NoDataFound"])
status = "No Data"
end
else
print(err["NoDiskFound"])
status = "No Disk"
end
cp(1,3) if diskToLabel ~= "No label" then print("Left disk ["..status.."]".." - "..diskToLabel) else print("Left disk ["..status.."]") end
end
return listFiles()
end
I have no clue what's happening within the list file and have no clue how it does all the sorting, getting file names etc. Can someone show me how to change this function so it sort's it by itself? Thanks.
Pictures:
Spoiler
Right Disk:Spoiler
Left Disk