I’m working on a program where I am collecting folders to process by drag and drop to the application and a table in the application window. I seem to have this working fine. There is a routine I am using that chrys put together to get a file list using shell scripting which works great. I am trying to call the same routine in another part of the program and it does not seem to work and I think that it might be tied to the stored value for the folder. I have this routine for files dropped on the application:
on open droppedFiles
log "On Open"
set theFiles to {}
if class of droppedFiles is not list then set droppedFiles to {droppedFiles}
repeat with i from 1 to count of droppedFiles
copy (POSIX path of (item i of droppedFiles)) to end of theFiles
end repeat
SetTableData(theFiles)
end open
It calls this routine which adds the paths to a table and a property if the dropped item is a folder. The find file command in the loaded script library works great here.
to SetTableData(FolderList)
set update views of FolderData to false -- Turn off the updating of the views
-- For every item in the list, make a new data row and set it's contents
set foundFiles to {}
repeat with theItem in FolderList
set theItem to theItem as string
set PathList to contents of data cell "Path" of every data row of FolderData
if (theItem as string) is not in PathList then --
set ItemKind to kind of (info for (POSIX file theItem) without size)
if ItemKind is "Folder" then
copy theItem to end of FoldersToProcess
set theDataRow to make new data row at end of data rows of FolderData
set contents of data cell "Path" of theDataRow to (theItem)
set MyFileTypes to getFileTypes()
tell ScriptLib to copy FindFiles(theItem, MyFileTypes) to end of foundFiles
set ImageCount to length of last item of foundFiles
set contents of data cell "Images" of theDataRow to ImageCount
end if
end if
end repeat
set update views of FolderData to true -- Turn back on the updating of the views
end SetTableData
I’m calling it again here:
set RunStatus to "Running"
set FolderCount to count of FoldersToProcess
log {FolderCount, FoldersToProcess}
set label of theObject to "Pause"
set image name of theObject to "pauseICN"
repeat with i from 1 to FolderCount
set currentFolder to item i of FoldersToProcess
set MyFileTypes to getFileTypes()
tell ScriptLib to set FilesToProcess to FindFiles(currentFolder, MyFileTypes)
log FilesToProcess
end repeat
The list FoldersToProcess is built in the previous routine from theItem. This is used sucessfully in using the find file routine (requiring a POSIX path). However, when I call it again nothing is returned. When logging the list and the individual items everything looks the same. Classes seem to be messed up in Xcode but when getting the class I get the same string of scientific notation in both places.
Am I missing something here? Is there some potential for a forced coercion that I am not seeing? I’m don’t usually use POSIX file/paths and am cursing their addition right now to the language for the added complexity.