AppleWorks script broken by Jaguar !?
AppleWorks script broken by Jaguar !?
- Subject: AppleWorks script broken by Jaguar !?
- From: Mr Tea <email@hidden>
- Date: Thu, 29 Aug 2002 14:30:49 +0100
I just got through testing a script that worked fine in OS 10.1.x, but was
broken in 10.2. I fixed it, but still don't understand why it broke.
The original script and the updated version were reproduced in my recent
post to the list with the subject line "Accessing Dictionary Contents (was:
Re: AppleScript Try)", but I have also appended them to this message for
convenience - the changed lines in the second script have been commented
accordingly.
The scripts outline and collapse AppleScript dictionary contents pasted into
an AppleWorks document by working backwards through the paragraphs, checking
each one to see if the text is underlined (command headings) or the font
size is 18 (suite headings). When I tried to run the original script in OS
10.2, it skipped past the suite headings and then got into a mess trying to
find paragraphs with a negative index instead of stopping when it reached
paragraph one. I fooled around with the sections of the script that were
going wrong until I got the thing working again, but I have no idea why this
was necessary.
Can anyone shed a light on this?
Thanks
Nick
----------------------------------------------------
THE SCRIPTS...
VERSION 1 - FOR OS X 10.1.x
tell application "AppleWorks 6" to set theText to text of document 1
set AppleScript's text item delimiters to tab
set theText to every text item of theText
set AppleScript's text item delimiters to ""
tell application "AppleWorks 6"
activate
set text of document 1 to theText as string
set thePara to index of last paragraph of document 1
repeat until thePara is 1
set endTopic to thePara
repeat until size of character 1 of paragraph thePara of document 1 is 18
set endPara to thePara
set currentPara to endPara
repeat until on styles of style of character 1 of paragraph thePara of
document 1 contains underline
set thePara to currentPara
set currentPara to currentPara - 1
end repeat
set startPara to index of paragraph after paragraph thePara of document 1
set startTopic to index of paragraph before paragraph thePara of document
1
if startPara < endPara then
select paragraphs startPara thru endPara of document 1
select menu item "with subtopics" of menu item "move right" of menu
"outline"
select paragraph (startPara - 1) of document 1
select menu item "collapse" of menu "outline"
else
set thePara to thePara - 1
end if
end repeat
if startTopic < endTopic then
select paragraphs startTopic thru endTopic of document 1
select menu item "with subtopics" of menu item "move right" of menu
"outline"
select paragraph (startTopic - 1) of document 1
select menu item "collapse" of menu "outline"
else
set thePara to thePara - 1
end if
end repeat
end tell
VERSION 2 - FOR OS X 10.2
tell application "AppleWorks 6" to set theText to text of document 1
set AppleScript's text item delimiters to tab
set theText to every text item of theText
set AppleScript's text item delimiters to ""
tell application "AppleWorks 6"
activate
set text of document 1 to theText as string
set thePara to index of last paragraph of document 1
repeat until thePara < 2 --***CHANGED LINE***
set endTopic to thePara
repeat until size of character 1 of paragraph before paragraph thePara of
document 1 is 18 --***CHANGED LINE***
set endPara to thePara
set currentPara to endPara
repeat until on styles of style of character 1 of paragraph thePara of
document 1 contains underline
set thePara to currentPara
set currentPara to currentPara - 1
end repeat
set startPara to index of paragraph after paragraph thePara of document 1
set startTopic to index of paragraph before paragraph thePara of document
1
if startPara < endPara then
select paragraphs startPara thru endPara of document 1
select menu item "with subtopics" of menu item "move right" of menu
"outline"
select paragraph (startPara - 1) of document 1
select menu item "collapse" of menu "outline"
else
set thePara to thePara - 1
end if
end repeat
if startTopic < endTopic then
select paragraphs startTopic thru endTopic of document 1
select menu item "with subtopics" of menu item "move right" of menu
"outline"
select paragraph (startTopic - 1) of document 1
select menu item "collapse" of menu "outline"
else
set thePara to thePara - 2 --***CHANGED LINE***
end if
end repeat
end tell
----------------------------------------------------
A bit of additional, irrelevant info - timings in seconds for formatting the
contents of the Finder's dictionary when running the script (version 2) in
various ways.
Run from System Script Menu: 28
Run from DragThing dock: 25
Run from AppleWorks Script Menu: 19
Pip pip
N.
_______________________________________________
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.