OO3 get value from a column
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 [/code] |
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 [/code] 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 [/code] |
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=whpalmer4;69349]My code gave an example of looping through all of the rows in the document.[/QUOTE]
(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 [/CODE] |
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=whpalmer4;79424]Thanks for all of your efforts bushwhacking through the Applescript jungle on our behalf![/QUOTE]
Seconded! |
That's very kind of both of you (though I prefer to think of it as a vineyard :-)
|
All times are GMT -8. The time now is 06:14 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.