Appleworks script needs refining
Appleworks script needs refining
- Subject: Appleworks script needs refining
- From: Mr Tea <email@hidden>
- Date: Tue, 12 Feb 2002 00:08:23 +0000
I was going to make "Buff up my kludge" the subject of this message, but
I thought it might fall foul of apple's new list guidelines on
inappropriate language.
I've just started the laborious process of trying to reproduce (with
applescript) the functionality of some of my old AppleWorks macros in the
macro-free OS X version. The example below is my first crack at writing a
script to turn chunks of a document into sub-topics and collapse them.
It works backwards from an insertion point, stopping when it gets to a
paragraph that starts with underlined text, then indents the section it's
just been through and tucks it away. My goal is to have a script that
will go through an entire document, but before I move on to that stage I
feel that what I've got so far could be, er, tightened up a little.
Those with fragile sensibilities should maybe look away at this point, as
what follows is seriously ugly (right up there in the Rondo Hatton
league). I feel in my heart that there must be a prettier way to do this
than having constructions like 'paragraph before paragraph before
selection' and lines that contain the word 'of' four times. And I'm not
entirely happy about having those dweeby 'select menu' commands in there
amongst the 'real' applescript, when what I really want to do is set the
level of the selected paragraphs (to 2) and specify precise values for
left indent and first line indent.
Here's the poor, sick beast:
tell application "AppleWorks 6"
activate
set endPara to index of paragraph before selection of document 1
repeat until on styles of style of character 1 of selection of document
1 contains underline
set thePara to select paragraph before paragraph before selection of
document 1
end repeat
set startPara to index of paragraph after paragraph after selection of
document 1
select paragraphs startPara thru endPara of document 1
select menu item "with subtopics" of menu item "move right" of menu "outline"
select paragraph before paragraph before selection of document 1
select menu item "collapse" of menu "outline"
end tell
Thanks in advance for any beauty tips. And, incidentally, an AS
application dictionary pasted into AppleWorks makes an ideal test document...
Mr Tea
--
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.