Progress dialog, abort, skip buttons greyed out

Hello! o)

Can somebody take a quick look why in this demo-script, the buttons in the progress dialog are all greyed out?
Is there some other thing to be done to get them working? I looked through the docs, not sure what I missed.

You can run this button with some files selected, it will open the progress, delay for 1 second each and do nothing more.

Thanks! o)

//##############################################################################
function OnClick(data){
//##############################################################################
	var f=data.func, cmd=f.command, tab=f.sourcetab;
	var shell = new ActiveXObject("WScript.Shell");

	var progress = initProgressDialog( cmd, tab, tab.selected_files.count );
	
	for(var i=0;i<tab.selected_files.count;i++){
		if (progress.GetAbortState() == "s") {
			progress.ClearAbortState();
			progress.SkipFile(false);
			continue;
		}
		DOpus.Delay(1000);
		if (progress.GetAbortState() == "a") break;

		var fileDOItem = tab.selected_files(i); //get selected DO item
		var fileName = fileDOItem.name; //get item name

		progress.SetName( fileName );
		progress.StepFiles(1);
		
		DOpus.Output("File [" + fileName + "]..");
	}
	progress.Hide();
}
//##############################################################################
function initProgressDialog( cmd, tab, itemCount ) {
//##############################################################################
	var progress = cmd.progress;
	
	progress.Init( tab, "Filename-Date to EXIF..");
	progress.pause = true;
	progress.abort = true;
	progress.skip = true;
	progress.owned = false;
	progress.bytes = false;
	progress.full = false;
	progress.AddFiles( itemCount );

	progress.Show();
	progress.SetStatus( "Processing..");
	//DOpus.Delay(1000);
	return progress;
}

Move the Init call down to just before AddFiles and it should work.

The manual is a bit unclear about this, which we'll improve. Came up a couple of days ago, and this thread links to a few examples if anyone needs them:

Ah I see. Ironically I tried this because @Berndi asked in the german forum about it and I thought it would be nice to have a easy to use example for myself, seems he was faster than me. o) Anyway, I learned something along this! o)

One "kind of" question remained, the "Pause" button.. I can press that in the dialog, but the script won't stop. I guess I need to check for "pause" abort state here too and also handle the resume on my own. Makes sense, since DO won't know at what command in my script it shall pause or continue I guess.

Thanks! o)

Yep, the script has to check if pause is set, and if it is you'd normally then loop and keep checking until the state changes, with a DOpus.Delay call in the loop to avoid burning CPU.

We could add a mode where the GetAbortState call simply blocks until unpaused, and never returns "p" as the state, which would simplify things.

I don't think many scripts use the progress dialog at all though. Since scripts can't use multiple threads and usually only deal with very high level commands (not on a byte-by-byte basis), they aren't often suited to displaying progress. But there are some cases where they can be.

Ok, thank you for wrapping that up! o)

It also looks like there was no way to get the Skip button enabled from a script (or if there was, it was very hard; it only happens if the speed timers in the progress dialog were enabled, and I'm not sure scripts can do that).

We'll be adding a new EnableSkip method to the progress object for this.

In addition to the previous post, we've implemented this (and a couple of other quality-of-life improvements) for GetAbortState in the next beta.

A new argument will let the method handle checking the Paused state for you, blocking until unpaused. As long as you call GetAbortState occasionally, you then only have to worry about the other states, and don't need a silly wait/delay/re-check loop in the script.

Where is the difference to the ".skip" property with this?

Sounds good, thank you! o)

The .skip property tells the dialog you want the skip button to be (potentially) available before you create the dialog. (It could potentially mean the button isn't there at all, although we currently display all three buttons if any one of them is in use.)

The EnableSkip method tells the dialog you want the Skip button to be enabled/disabled when you call it. (EnableSkip won't do anything if .skip=false before creating the dialog.)

It will also let you reset the Skip state (without also resetting and losing the Abort/Pause states at the same time, which was a problem before), and also gives you the functionality of the internal commands where you can enable the Skip button for each file, but only after a delay. That gives the user a chance to react if they get tired of waiting and click Skip just as one file completes and they risk clicking Skip on the next file.

Ah I think I got it! o)