How do I know when a script has completed?

I've been using the excellent script created by tbone in response to my requested here: [url]Script Request: Clean folders with only a single file]. However, when I run the script on a large number of folders, I can't figure out how to tell when the script has finished or how to stop the script.

Scripts can display progress dialogs, if they want to, but that's up to the script itself to do.

Is there a simple call that I can add to a script to simply show a progress bar or even pop up a "finished" dialog?

data.func.dlg.Request("I'm Finished");

For example:

@script jscript function OnClick(data) { data.func.dlg.Request("I'm Finished"); }

Thanks, Leo. I'll give that a try. Is there a way to stop a script that is being processed?

Only when it's run via the CLI (or by quitting Opus), that I know of at least.

Another option is to use the progress dialogue. I used it in this script.
The script run a lengthy process on a list of folders. The way I have written it you cant stop the current folder being processed but if you click pause or stop then this will be taken in to account before processing the next one.
So in this way if I selected a lot of folders I can see the progress of them as each folder finishes being processed, and then I can pause or about.

The code looks something like this.

  var folderCount = 1;
  while (!objEnum.atEnd())
  {
    if(progress.GetAbortState=="a") break;
    
    if(progress.GetAbortState!="p")
    {
      var folder = objEnum.item();
      SetCurrentStatus(folder);
      progress.SetTitle("Creating thumbnails and folder images ("+folderCount+"/" + funcData.func.sourcetab.selected_dirs.count + ")");
      //Do the work
      CreateAllThumbnails(folder);
      objEnum.moveNext();    
      folderCount++;
      progress.StepFiles();
    }
  }
  progress.hide();

I added Leo's "I'm finished" command to the end of the script. I'll try wowbagger's GetAbortState procedure next. Thanks to everyone for their help!