I have a submit button with the following action code:
dim src as FolderItem
dim dest as FolderItem
src=SpecialFolder.Desktop.Child("FolderA")
dest=SpecialFolder.Desktop.Child("FolderB")
COPYFOLDER(src,dest)
and a method (passed on clicking above button.
Method Name: COPYFOLDER
Params: src as FolderItem, dest as FolderItem
dim m as integer
for m = 1 to src.count
if src.item(m) <> nil then
if src.item(m).directory then
dest.child(src.item(m).name).createAsFolder
CopyFolder(src.item(m), dest.child(src.item(m).name))
else
src.item(m).copyFileTo dest
end if
end if
next
All works ok, but the application seizes up (assuming because this is not asyncronus?). Can someone point me in the right direction that doesn’t include a £200.00 plugging from Monkeybread please .
You could try putting this loop in a Thread. You’ll need to bone up on how to properly integrate that with your app’s UI though. Typically, you’d use a timer and progress bar to show progress. You might do that modally. You don’t have to.
At Brad said, put your code in a thread. And if you want to save a lot of your time, then spend some looking at the Task Thread subclass described in the Wiki and demoed in the Example Projects/Desktop/UpdatingUIFromThread/UIThreadingWithTask example.
…and if you don’t fancy a thread, you might shell out to an operating system call, or create a tiny little app which does nothing but read the command line for two folder names, and then does the copy. (helper app)
Launch the app, then forget about it.
(Your code doesn’t seem to try to update the UI with progress anyway)
Helper app is obviously less useful if you need to know when the copy is complete, tho…
[quote=48412:@Jeff Tullin]…and if you don’t fancy a thread, you might shell out to an operating system call, or create a tiny little app which does nothing but read the command line for two folder names, and then does the copy. (helper app)
Launch the app, then forget about it.
(Your code doesn’t seem to try to update the UI with progress anyway)
Helper app is obviously less useful if you need to know when the copy is complete, tho… :)[/quote]
You can even use a bash script and copy with a bash command