Conflict Between Command.Progress Window and Delete Progress Window

I have a script for which the progress window from Command.Progress is replaced by the delete progress window after a Delete command is issued. Is this by design? How do I prevent that?

I tried using a separate command object for the Delete command, but then I got an error and files were not being deleted.

function OnClick(clickData)
{
	var cmd = clickData.func.command;
	var Progress = cmd.Progress;
	Progress.pause = true; // Allow pause button.
	Progress.abort = true; // Allow abort button.
	Progress.Init(clickData.func.sourcetab, "Cleaning Duplicate Files Collection");
	Progress.SetStatus("Removing already processed files...");
	DOpus.Delay(200);
	Progress.Show();

	// Main loop.
	var keep_trying = true;
	while (keep_trying) {
		cmd.ClearFiles();
		clickData.func.sourcetab.Update();
		Progress.SetFiles(clickData.func.sourcetab.all.count);
		Progress.Restart();
		
		// Handle progress flow control.
		var abortState = Progress.GetAbortState();
		if (abortState == "a")
			break; // Aborted.
		if (abortState == "p")
		{
			DOpus.Delay(500);
			continue; // Paused; restart the loop to see if we are still paused.
		}
		
		for (var eSel = new Enumerator(clickData.func.sourcetab.all); !eSel.atEnd(); eSel.moveNext())
		{

			// Handle progress display.
			Progress.SetName(eSel.item().name);
			Progress.SetType("file");

			if (!(DOpus.FSUtil.Exists(eSel.item())))
			{
				cmd.AddFile(eSel.item());
			} else if (eSel.item().filegroup.count === 1) {
				cmd.AddFile(eSel.item());
			}
			
			// Update state data.
			Progress.StepFiles(1);
		}
		
		if (cmd.files.count >= 1) {
			cmd.AddLine("Delete REMOVECOLLECTION QUIET");
			cmd.Run();
		} else {
			keep_trying = false;
		}
	}
}
  1. Use DOpus.Create.Command to get a new Command object with a separate progress dialog (this is the one you should use in your script).
  2. Then when you run the Delete command using the original Command object, use Command.SetModifier("noprogress") to prevent it from showing its own progress indicator.
1 Like