Syntax use of AND

Hi,

I am looking at adapting a script to search an outline. I wish to restrict the search to rows at levels 1 & 2 but I can’t get the syntax correct.

Here is the line that finds the text which is contained in var strQuery

set refRows to a reference to ( rows where topic contains strQuery)

I want to use (rows where topic contains strQuery AND level <3)

Any ideas?

It’s been quite a while since I wrote an AppleScript for OO, but I wrote some in the past that did row-filtering tasks that sound similar to what you’re working on.

The example below is a copy/paste of one of my scripts with the bulk pulled out and the remaining skeleton adapted to your task. It compiles and returns results that seem correct in one of my documents. YMMV, but I hope it’s helpful!

   tell application "OmniOutliner"
	tell front document
		repeat with MyRow in (every row whose level is less than 3)
			-- code that filters down to the exact rows I want goes here
			
		end repeat
	end tell
end tell

Edit: after posting, realized the goal was to search levels 1 & 2, not 3 and above. Corrected script.

Thanks Brian,

it’s been quite a while since I wrote an AppleScript for OO

Me to! I tried JS but all those braces…

I will try your code and report back.

best wishes
Simon

FWIW, in Applescript probably you can do something like this:

tell application "OmniOutliner"
	tell front document
		set strQuery to "Search String"
		set oRows to a reference to (rows whose level is less than 3 and name contains strQuery)
		return name of oRows
	end tell
end tell
1 Like