AppleScript: Our Friend. My (sometimes) Enemy. Why you should learn it.

Angus McIntyre angus at pobox.com
Tue Feb 25 17:41:01 PST 2003


At 19:05 -0800 24.02.2003, Brian C. wrote:
>Okay. Steve knows what's going on, and we know when it'll be fixed.
>
>Diagnosis:
>>  "make new row at end of rows" returns an object specifier for the
>>  new row, something like "third row of root of first document".
>>  When you "indent theRow" then theRow might be "first row of
>>  second row of root of first document" but the object specifier is
>>  still the old one.  So "set value of cell 2 of theRow to "hi there""
>>  fails because there isn't a row where "theRow" says there is.
>
>Prognosis:
>We'll change this, but not right away; probably in the 3.0 timeframe. I
>futzed around trying to find a workaround, but eventually got stymied.
>Anyone with more talent than me have any luck?

The trick seems to be to refresh the reference. For example, while:

    tell first document of application "OmniOutliner"
       set theRowSpec to make new row at end of rows
       indent theRowSpec
       set value of cell 2 of theRowSpec to "hi there"
    end tell

will fail with the error that I described,

    tell first document of application "OmniOutliner"
       set theRowSpec1 to make new row at end of rows
       indent theRowSpec1
       set theRowSpec2 to last row
       set value of cell 2 of theRowSpec2 to "hi there"
    end tell

works correctly (as far as I can see). If you're in a situation where 
you can easily work out what the new object specifier is, then this 
could be a valid workaround. How hard it will be to determine the new 
object specifier after an 'indent' may depend on the exact situation.

Perhaps some future version of OO could arrange things so that 
'indent' returned the new specifier of the indented object after the 
indent operation.

Thanks for your help.

Angus
-- 
angus at pobox.com                             http://pobox.com/~angus



More information about the OmniOutliner-Users mailing list