The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > Developer > AppleScripting Omni Apps
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
OO3 get value from a column Thread Tools Search this Thread Display Modes
Hi, for my personal use of oo3 i need to introduce same simply mathematical function, but i am a newby of applescript, for example i try to get a value from a cell to a specific column but al my script return a error -1728 for example :

tell front document of application "OmniOutliner"
set var to value of column "ricarico"

end tell

where i wrong

thank in advance
 
You need to tell it which row...

The following code will loop through all the rows and sum the values of the contents of the "ricarico" column, as an example.

Code:
tell application "OmniOutliner"
	tell front document
		set SumTotal to 0.0
		repeat with MyRow in every row
			set cellValue to value of cell "ricarico" of MyRow
			set SumTotal to SumTotal + cellValue
		end repeat
	end tell
end tell
 
yes but for the single row ?

for example

Column1 Column2 Column3
10 20 (this is the sum of Column1+Column2)

i must read the value of column1 of the rom 1.

when i try some various script (in the old mailing list there is a post that explain this) i have the error -1728 in every method.

with this script i must update all the outline.

but thank you for example i can create a script for all the document
 
You still need to tell Applescript which row you are operating upon, even if there is only one. A column doesn't have a value, a cell in a column does, but to specify which cell in the column, you need to specify which row.

My code gave an example of looping through all of the rows in the document. If you want to do only the selected rows, the code might look like:

Code:
tell application "OmniOutliner"
	tell front document
		set SumTotal to 0.0
		repeat with MyRow in selected rows
			set cellValue to value of cell "ricarico" of MyRow
			set SumTotal to SumTotal + cellValue
		end repeat
	end tell
end tell
and if you wanted to do only the third row, the code might look like:

Code:
tell application "OmniOutliner"
	tell front document
		set SumTotal to 0.0
		set MyRow to third row
		set cellValue to value of cell "ricarico" of MyRow
		set SumTotal to SumTotal + cellValue
	end tell
end tell
 
thank you, your example explain me the correct work method, now i can script the OO3 and personalize for my work.


Thank a lot

P.S.
i have a bad english and it doesn't help me for the forum reply and in applescript scripting, sorry for my error.
 
Quote:
Originally Posted by whpalmer4 View Post
My code gave an example of looping through all of the rows in the document.
(This was randomly bumped by a piece of spam, but FWIW ...)

A variant approach which may give a little more speed (and possibly simplicity ?) is to get a whole list of values in a single apple event by evaluating a property of a reference.

Code:
tell application id "com.omnigroup.OmniOutlinerPro3"
	tell front document
		-- quickly get a *list* of values by evaluating a property of a reference
		set refCol to a reference to cell "Ricarico" of rows
		set lstValues to value of refCol
		
		-- Iterate through an applescript list (faster and simpler)
		-- rather than through a collection in an application object model 
                --(slower and more complex)
		set lngTotal to 0
		repeat with varValue in lstValues
			if contents of varValue is missing value then
				-- skip
			else
				set lngTotal to lngTotal + varValue
			end if
		end repeat
	end tell
end tell
 
Rob,

this is an example of why I've got a project in OF called "Useful Applescript posts" populated primarily with links to your posts :)

I write just enough Applescript that a former employer's dictum comes frequently to mind:

"All programmers steal code; good programmers know whose code to steal"

Thanks for all of your efforts bushwhacking through the Applescript jungle on our behalf!
 
Quote:
Originally Posted by whpalmer4 View Post
Thanks for all of your efforts bushwhacking through the Applescript jungle on our behalf!
Seconded!
 
That's very kind of both of you (though I prefer to think of it as a vineyard :-)
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste from Word Column to OO Column jhlindstrom OmniOutliner 3 for Mac 1 2011-02-10 03:05 PM
Using the Estimates Column cschneid OmniFocus 1 for Mac 3 2009-10-19 05:16 PM
Where's the estimate column? newguy OmniFocus for iPhone 1 2009-10-01 12:04 AM
date column henri OmniOutliner 3 for Mac 0 2008-05-24 02:20 PM
Context Column jameswwalker2003 OmniFocus 1 for Mac 5 2007-11-28 04:31 AM


All times are GMT -8. The time now is 01:18 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.