Accessing superscript with AppleScript

Timothy J. Wood tjw at omnigroup.com
Wed Sep 17 19:44:03 PDT 2003


  There are some known bugs with setting the baseline offset and 
superscript via AppleScript (which have been fixed internally for our 
next release), but getting them is (mostly) working for me in 2.2.3:

tell application "OmniOutliner"
	set MyDoc to (make new document at end of documents)
	set selected row of MyDoc to first row of MyDoc
	
	make new column with properties {title:"Baseline Offset"} at end of 
columns of MyDoc
	make new column with properties {title:"Superscript"} at end of 
columns of MyDoc
	
	set MyRow to first row of MyDoc
	set MyCell to (cell 2 of MyRow)
	
	-- without this you'll get 0.0 and 0
	-- set text of cell 2 of MyRow to "foo"
	set text of cell 3 of MyRow to (baseline offset of text of MyCell as 
string)
	set text of cell 4 of MyRow to (superscript of text of MyCell as 
string)
end tell

   The 'mostly' part is that if there is no baseline offset or 
superscript level set on the text, then we return a null value instead 
of returning zero.  Somehow it is working if you have a zero length 
string.  I've logged a bug to fix this problem (#10688).

   As a workaround, you can convert the returned value to a string and 
then compare it against "".  There probably is a way to check if you 
got a null back, but I don't have may AppleScript reference (such as it 
is) handy.

   Here is a version of the script above that works even with the 'foo' 
line uncommented:

tell application "OmniOutliner"
	set MyDoc to (make new document at end of documents)
	set selected row of MyDoc to first row of MyDoc
	
	make new column with properties {title:"Baseline Offset"} at end of 
columns of MyDoc
	make new column with properties {title:"Superscript"} at end of 
columns of MyDoc
	
	set MyRow to first row of MyDoc
	set MyCell to (cell 2 of MyRow)
	
	set text of cell 2 of MyRow to "foo"
	
	set MyBaselineOffset to (baseline offset of text of MyCell as string)
	if MyBaselineOffset is "" then
		set MyBaselineOffset to "0.0"
	end if
	set text of cell 3 of MyRow to MyBaselineOffset
	
	set MySuperscript to (superscript of text of MyCell as string)
	if MySuperscript is "" then
		set MySuperscript to "0"
	end if
	
	set text of cell 4 of MyRow to MySuperscript
	
end tell


   Definitely let us know if there are particular scripts you write that 
don't work the way you expect.  Test cases like this are most useful if 
they either create a new document or modify an existing document (this 
isn't always possible, so don't worry if its hard to formulate an 
example -- just let us know it's busted :).  But, with a test case like 
this we can drop it into our growing automated AppleScript regression 
test suite and make sure that it never breaks again.

-tim



On Wednesday, September 17, 2003, at 06:36  PM, John Tiftickjian wrote:

> Hello OO group,
>
> I am experimenting with AppleScript to customize exporting an outline 
> as HTML so as to use predefined CSS styles. I have had some success so 
> far, but have hit a snag when trying to get the superscript/subscript 
> status of an attribute run.
>
> The AppleScript dictionary of OO shows a suite called "Extended Text 
> Suite," under which falls the "attribute run" class. This class lists 
> properties such as: font, alignment, underlined, baseline offset, 
> color, etc. If I write a script that tries to get the font, color, or 
> size of an attribute run, the correct information is returned. However 
> if I try to get baseline offset, or superscript, an error is returned.
>
> Does this mean that those particular properties of attribute runs are 
> not yet supported, or am I just doing something wrong? If not yet 
> implemented, is this planned in the future?
>
> A somewhat related question: why is it that OmniOutliner appears twice 
> in the list of applications that is accessed through the "dictionary" 
> command in ScriptEditor? (This is not peculiar to OO, several other 
> applications appear more than once also in spite of the fact that 
> there is only one copy of the application installed.)
>
> Thanks for any help,
>
> John.
> -- 
> ---------------------------------------------------------    // /\
> John Tiftickjian, Ph.D.    Chair and Professor of Biology   // //\\
>                                                            // //  \\
> Department of Biological Sciences          662-846-4240   // // \\ \\
> Delta State University               FAX: 662-846-4798   // //   \\ \\
> Cleveland, Mississippi 38733     jtift at deltastate.edu    =======  \\ \\
> ---------------------------------------------------       ==========
>
> _______________________________________________
> OmniOutliner-Users mailing list
> OmniOutliner-Users at omnigroup.com
> http://www.omnigroup.com/mailman/listinfo/omnioutliner-users
>




More information about the OmniOutliner-Users mailing list