View Single Post
On reflection, the following might be a little simpler:

Code:
on run
	tell application "OmniFocus"
		set lstSections to every section of first document
		
		set lstProjects to my ListProjects(lstSections)
	end tell
	
	display dialog length of lstProjects
end run


on ListProjects(lstSections)
	set lstProjects to {}
	using terms from application "OmniFocus"
		repeat with oSectn in lstSections
			if class of oSectn is project then
				set end of lstProjects to oSectn
			else
				set lstSubSections to every section of oSectn
				if lstSubSections ≠ {} then
					set lstProjects to lstProjects & my ListProjects(lstSubSections)
				end if
			end if
		end repeat
	end using terms from
	return lstProjects
end ListProjects