Rewrite script to use native progress bar instead of AsObjC Runner?

I’ve been using Shane Stanley’s superb AsObjC Runner to provide a progress bar in AppleScripts that may be used in pre-Yosemite systems. For various reasons that you can guess but which I can’t say, this method will cause problems in the future, and I now want to make my scripts use native AppleScript progress bars and run only in Yosemite or later.

What I can’t figure out is how to translate the syntax of AsObjC Runner into native AppleScript. My AsObjC syntax looks like this:

set properties of progress window to {button title:"Cancel", button visible:false, message:"Converting...", detail:cnvFile, indeterminate:false, max value:4, current value:0}

As you see, my dialog displays the name of the file currently being converted (from the variable named cnvFile), and the “current value” is set at different points in the script.

I’ve been scratching my head over this, and will be grateful for any help.

Partial answer: I see that this method using timing to determine which stage number to display; what I can’t figure out is how to set the “Conversion stage” number to a number set elsewhere in the script.

set cnvPosix to POSIX path of cnvFile
		set progress description to "Converting " & cnvPosix
		set progress additional description to "Preparing."
		set progress total steps to -1
		delay 0.5
		set progress total steps to 4
		repeat with i from 1 to 4
			try
				set progress additional description to "Conversion stage " & i
				set progress completed steps to i
				delay 0.2
			on error thisErr
				display alert thisErr
				exit repeat
			end try
		end repeat

You can use it anywhere in your code. Just use:

 set AppleScript's progress additional description to ...

Thank you! Two last questions:

  1. Is there a way to make the progress bar “steps” correspond to changes declared elsewhere in the code, and not simply according to fixed intervals?

  2. Am I right to think there’s no way to turn off the progress bar altogether?

Thanks again - I’ll miss AsObjC Runner; it’s terrific code.

I’m not sure what you mean. You can set their value at point you like.

I don’t think so.

Have you checked out Stefan’s scriptable progress app?

I see - you mean I can set “Applescript’s progress completed steps” anywhere in the code.

I’ve been looking for it! Can you point me to it? You mentioned in another post that there were progress apps out there but I wasn’t able to find them.

I assumes that Shane wrote about : SKProgressBar 1.5

http://macscripter.net/viewtopic.php?id=36409&p=2

Yvan KOENIG running El Capitan 10.11.5 in French (VALLAURIS, France) lundi 20 juin 2016 13:59:02

Thank you - it should have been obvious, but I didn’t find it in a search (which means I don’t know how to search…)

I used the forum’s search tool with the keyword progress and the author stefanK
Search restricted to AppleScript / Mac OS X.

To test it, I used the code delivered in the very first message of : http://macscripter.net/viewtopic.php?id=36409.

Yvan KOENIG running El Capitan 10.11.5 in French (VALLAURIS, France) lundi 20 juin 2016 14:32:14

Yes, but when I was searching yesterday, I didn’t know that StefanK had written this and had no way of knowing that he wrote it, so I had no way of knowing that I should search for his name. All I knew was that Shane wrote that apps exist to provide progress bars. A search for

progress bar

in the keyword field did not bring it up on either the first or second page of the search. I should have gone on to the third page, where it does appear, but I lazily assumed it would show up earlier. I’ll know better next time. Thank you again!