View Single Post
Just been asked this in a private message. Public discussion spreads the load and brings better harvests, so here's a first seedling.

Code:
tell application id "OFOC"
	tell default document
		-- SOME FOLDER, LET'S JUST GRAB THE FIRST WE SEE ...
		set oFolder to first folder
		
		-- ALL ACTIVE CHILD-BEARING PROJECTS ENCLOSED BY THIS FOLDER, REGARDLESS OF NESTING
		set refProjects to a reference to (flattened projects of oFolder where number of tasks > 0 and status is active)
		
		-- HARVEST THE PROGENY THEREOF (PERHAPS FILTERED) AS A LIST OF LISTS
		set lstTasks to flattened tasks of refProjects where completed is false
		
		-- FLATTEN THE LIST, IF NEED BE
		set lstTasks to my FlatList(lstTasks)
	end tell
end tell


on FlatList(lst)
	if class of lst is not list then
		{lst}
	else if lst ≠ {} then
		FlatList(item 1 of lst) & (FlatList(rest of lst))
	else
		{}
	end if
end FlatList