Applescript question

BJ Terry bjterry at adelphia.net
Sat Jan 17 22:35:59 PST 2004


> Hi there
>
> I'm wanting to use applescript to re-arrange an outline from this 
> (where
> the children are topics and the project is set via a pop-up list in a
> second column):
>
> The resulting outline does not need to have the second column operative
> as a popup list: it is sufficient to have those values as text.
>
> Any clues would be greatly appreciated.
>
> Regards
>
> Richard


Here's what I came up with. It takes 93 seconds to run on my machine 
for a file with 50 parents, 10 projects, and 700 rows. You can't set 
the second column to a popup from the applescript interface, because OO 
doesn't let you set the options, and isn't smart enough to take the 
text you give it:

on makeObj(myParent, myValue, myProject) --simple data structure to
	script
		property parentValue : myParent
		property rowValue : myValue
		property project : myProject
	end script
end makeObj

set rowList to {}
set projectList to {}

tell application "OmniOutliner"
	tell document 1
		repeat with i from 1 to (count rows)
			
			set currentRow to row i
			
			if level of currentRow is equal to 2 then
				set currentParent to currentRow's parent 1's topic
				set currentProject to currentRow's cell 3's text
				set end of rowList to my makeObj(currentParent, currentRow's topic, 
currentProject)
				if not (projectList contains currentProject) then
					set end of projectList to currentProject
				end if
			end if
		end repeat
	end tell
	
	
	make new document
	tell document 1
		delete row 1
		make new column at end
		repeat with projectCount from 1 to count projectList
			set currentProject to projectList's item projectCount
			set currentProjectRow to make new row at end with properties 
{topic:currentProject}
			repeat with rowCount from 1 to count rowList
				set currentRow to rowList's item rowCount
				if currentRow's project is equal to currentProject then
					set newRow to make new row at end of currentProjectRow with 
properties {topic:currentRow's rowValue}
					set newRow's cell 3's text to currentRow's parentValue
				end if
			end repeat
		end repeat
	end tell
	
end tell


BJ




More information about the OmniOutliner-Users mailing list