-- Функция сортировки function Sorter(v1,v2) if (String.SplitPath(v2).Filename > String.SplitPath(v1).Filename) then return true; else return false; end end function GetImgTb() --наша таблица файлов local tImgs={}; -- отсортированная таблица tSortImgs = {}; -- маски файлов для поиска и добавлеия local tMasks={'*.jpg', '*.bmp', '*.gif', '*.png'}; -- перебираем каждую маску в цикле for n, cMask in tMasks do -- ищем файлы по маске tFilePaths = File.Find(_SourceFolder.."\\Images\\", cMask, false, false, nil, nil); -- если нашли файлы if (tFilePaths) then -- перебираем пути файлов в цикле for n, sFilePath in tFilePaths do -- добаляем в ЛистБокс tImgs[Table.Count(tImgs) + 1] = sFilePath; end end end -- если таблица не пустая if (Table.Count(tImgs) > 1) then -- сортируем Table.Sort(tImgs, Sorter); for n, sPath in tImgs do tSortImgs[Table.Count(tSortImgs) + 1] = {Name=String.SplitPath(sPath).Filename..String.SplitPath(sPath).Extension, Path=sPath}; end end if (Table.Count(tSortImgs) > 1) then -- возвращаем табл. return tSortImgs; else -- также возвр. nil return nil; end end -- если табл. сущ-ет if (GetImgTb()) then -- добавл. в ЛистБокс символ возврата к пред. папке ListBox.AddItem("ListBox1", "...", ""); -- перебираем а цикле злементы табл. for n=1, Table.Count(tSortImgs) do -- заполняем ЛистБокс ListBox.AddItem("ListBox1", tSortImgs[n].Name, tSortImgs[n].Path); end end |