Progess indicator help required

ok, I’m thick! I’ll admit it!

Can someone tell me, in very very simple terms how to get the progress indicator or the new 10.2 idicator to animate in Studio.

All I want to do is click a button, which would animate the progress bar (in it’s barber pole mode) and then the script continues to do stuff, then I get the progress bar to stop.

I’ve tried and failed to do this very simple thing.

Anyone fancy creating a project which has a window, a progress indicator and a button, and showing a thicko like me the code needed to click the button and have the bar animate.

I’ve looked at the ‘debug test’ script, and canablised part of it into a new project but I still can’t get it to work.

Apart from this little bit, the rest of my nice complex script works, but I’d love some progress indication as otherwise it looks like it’s crashed!

thanks for any help.

well…

A) you have to no interface builder (not just how to put the objects on, but how to name and wire them)

B) you have to understand object orientated programming and cocoa

and supposing you know that this will help:


//PROPERTIES

property keepRunning : true
property prop1 : "Test property 1"
property prop2 : "Test property 2"
property prop3 : 0

//EVENTS

on clicked theObject
	if title of theObject is "Start" then

//theObject is what ever is being clicked, in this case "Start" is a button, so its really just saying if the button is clicked

		runforever()
end clicked

on will open theObject
	set prop3 to 10
end will open

//FUNCTIONS

on runforever()
	set numberTest to 1
	set stringTest to "testing"
	
	runonce()
	
	repeat while keepRunning
		tell progress indicator "Barber Pole" of window "Main" to animate
		set prop3 to prop3 + 1
		set numberTest to numberTest + 1
		
		set contents of text field "counter" of window "Main" to numberTest as string
	end repeat
end runforever

on runonce()
	set prop3 to prop3 + 1
	set prop3 to prop3 + 1
	set prop3 to prop3 + 1
	set prop3 to prop3 + 1
	
	runonceagain()
end runonce

on runonceagain()
	set prop3 to prop3 + 1
	set prop3 to prop3 + 1
	set prop3 to prop3 + 1
	set prop3 to prop3 + 1
	
	runlasttime()
end runonceagain

on runlasttime()
	set prop3 to prop3 + 1
end runlasttime

-xen

Just noticed this post and it reminded me what I spent last weekend doing …

The following refers to a main window “main” with “stop” and “start” buttons and a text field “filetoenter”, and a second window “status” with a progress indicator (indeterminate), a “cancel” button and a text field “fileneame”.

on clicked theObject
	set myWindow to window "status"
	if name of theObject is "start" then
		show myWindow
		start progress indicator "progress" of myWindow
		set contents of text field "filename" of myWindow to contents of text field "filetoenter" of window "main"
	else if name of theObject is "stop" then
		stop progress indicator "progress" of myWindow
		set contents of text field "filename" of myWindow to ""
	else if name of theObject is "cancel" then
		close panel myWindow
	end if
end clicked

on should quit after last window closed theObject
	return true
end should quit after last window closed

It is very basic but seems to do what you are looking for. What really impressed me was that Applescript Studio lets you manage multiple buttons located on two windows via a single on clicked handler.
PS: As will be obvious, I am VERY new to this stuff!

hey sharkusmarkus,

if you are going to be using the progress bar a bunch this might help:


--Custom handlers for starting and stopping Progress bar--------------------------------------------------------------------------- 
on progressBarStart()
	tell window "main"
		set uses threaded animation of progress indicator "progress" to true
		set visible of progress indicator "progress" to true
		set visible of button "stopButton" to true
		tell progress indicator "progress" to start
	end tell
end progressBarStart

on progressBarStop()
	tell window "main"
		tell progress indicator "progress" to stop
		set visible of progress indicator "progress" to false
		set visible of button "stopButton" to false
	end tell
end progressBarStop

1)this is code from workflopro, so change the names as you like
2)“stopButton” is just a button I have that allows the user to stop the event
3)I call these handlers as needed when I want to start or stop the bar

good luck