View Single Post
Useful.

FWIW one other approach to getting the selected project is to use a where clause. Sth like this, perhaps:

Code:
property pTitle : "Proportion of tasks completed in selected projects"

tell application id "OFOC"
	tell front document window of default document
		repeat with oPanel in {content, sidebar}
			set lstProj to (value of selected trees of oPanel where class of its value is project)
			set lngProj to length of lstProj
			if lngProj > 0 then exit repeat
		end repeat
		if lngProj < 1 then return
		
		set str to ""
		repeat with oProj in lstProj
			tell oProj
				set {lngTasks, lngDone} to {number of tasks, number of completed tasks}
				set str to str & name & ":   "
				if lngTasks > 0 then
					set str to (str & (((lngDone / lngTasks) * 100) as integer) as string) & "%"
				else
					set str to str & "0%"
				end if
			end tell
			set str to str & return
		end repeat
		display dialog str buttons {"OK"} default button "OK" with title pTitle
	end tell
end tell
--

Last edited by RobTrew; 2012-05-31 at 01:05 AM..