View Single Post
A sketch of something more cautious:

Aims to select only completely empty and childless rows.
(unchecked and childless, with neither topic nor note, nor any data in any other columns).

Code:
-- Ver 0.2		A little faster in documents without additional columns

-- SELECT ALL COMPLETELY EMPTY ROWS
-- 	i.e. rows which:
--	1.	ARE UNCHECKED
--	2.	HAVE NEITHER TOPIC NOR NOTE
--	3.	HAVE NO DATA IN OTHER COLUMNS	
--	4.	HAVE NO CHILDREN

property plstEmpty : {"", missing value, "unchecked"}

tell application id "OOut"
	if (count of documents) < 1 then return
	select my EmptyRows(front document)
	activate
end tell

on EmptyRows(oDoc)
	tell application id "OOut"
		tell oDoc
			-- COLLECT A LIST OF UNCHECKED CHILDLESS ROWS WHICH HAVE NEITHER TOPIC NOR NOTE,
			set refRows to a reference to (rows where topic = "" and note = "" and state = unchecked and has subtopics = false)
			
			-- AND WHICH HAVE NO DATA IN ANY OTHER COLUMNS
			if (count of columns) > 2 then
				set lstEmpty to {}
				set {lstID, lstValue} to {id, (value of cells)} of refRows
				repeat with i from 1 to length of lstID
					set blnEmpty to true
					repeat with oValue in item i of lstValue
						if oValue is not in plstEmpty then
							set blnEmpty to false
							exit repeat
						end if
					end repeat
					if blnEmpty then set end of lstEmpty to item i of lstID
				end repeat
			else
				return contents of refRows
			end if
			
			-- CONVERT ID LIST TO LIST OF ROWS
			repeat with i from 1 to length of lstEmpty
				set item i of lstEmpty to (row id (item i of lstEmpty))
			end repeat
		end tell
		return lstEmpty
	end tell
end EmptyRows
--

Last edited by RobTrew; 2011-09-23 at 02:07 AM.. Reason: ver 0.2 - a little faster in documents without additional cols