Accessing Dictionary Contents (was: Re: AppleScript Try)
Accessing Dictionary Contents (was: Re: AppleScript Try)
- Subject: Accessing Dictionary Contents (was: Re: AppleScript Try)
- From: Mr Tea <email@hidden>
- Date: Thu, 29 Aug 2002 13:33:22 +0100
This from Reinhold Penner - dated 29-8-02 01.24 am:
>
More often than not I just want to open the
>
Standard Addition or the Finder's dictionary. I hate to get the list of
>
all scriptable apps, because it takes ages to load and on top of that
>
you have to mouse through the list to find them
If that's all you want to do, you could create aliases to Standard Additions
& Finder (etc.), put them in a folder with an alias to the Script Editor,
and drop them onto the script editor alias when you want to view the
dictionaries.
Another approach is to paste dictionary contents into a word processor or
text editor document, which brings the additional benefit of being able to
use 'find' to track down specific terminology in large dictionaries. Back
before I had Script Debugger's quick access to specific dictionaries, I used
AppleWorks for this.
The outlining function in AW can be used to collapse dictionaries down to a
list of suites that can be easily accessed and browsed, and AS can be used
to automate this otherwise dull and time-consuming process.
I dug out the script that I used for this and found - to my dismay - that it
had broken since I installed 10.2. So I've included both the original
version which ran perfectly well in 10.1.x, and an amended version which
works in Jaguar. As ever, watch out for line wraps if pasting this script
into an editor (any line that abuts the left margin and does not begin with
'tell', 'set' or 'end' has been wrapped).
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
Regards
Nick
pp 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.