Re: Capitilization and OSX dictionary
Re: Capitilization and OSX dictionary
- Subject: Re: Capitilization and OSX dictionary
- From: Arthur J Knapp <email@hidden>
- Date: Sat, 20 Apr 2002 16:56:40 -0400
>
Date: Sat, 20 Apr 2002 16:50:08 +0100
>
From: has <email@hidden>
>
Subject: Re: Capitilization and OSX dictionary
>
Matthew Stuckwisch wrote:
>
> random.pl is a perl script designed to access the main two dictionary
>
> files for OSX and randomly choose a word or phrase from them
>
> (AppleScript
>
> can't handle over 5000 items in a list...no way it can do over 230 000).
>
<squelch> AppleScript can handle >5000 items in a list just fine. It just
>
can't _create_ lists of >4000 items without barfing; to build big lists you
>
have to create several smaller lists and then concatenate them.
Or use vector appending: set myList's end to v
>
As for creating a 230 000 item list, I don't think you ever want to make
>
such a huge ram-hogging beast in the first place. Better to keep your data
>
as a simple string and work with that. For example, the following code will
>
extract a random word or phrase from a string:
>
on getPhrase(theString)
>
try
>
set thePara to some paragraph of theString
>
set wordCount to count thePara's words
>
set a to random number from 1 to wordCount
>
set b to random number from a to wordCount
>
thePara's text (word a) thru (word b)
>
on error number -1728 -- trap and retry if thePara contains no words
>
getPhrase(theString)
First, I just wanted to say that the above is a beautiful and well written
bit of AppleScript. There are not many scripters who take full advantage of
the "text (boundry 1) thru (boundry 2)" syntax. :)
Secondly, I was absolutely AMAZED to discover that the following works:
thePara's text from some word to some word
thePara's text some word thru some word
Talk about a cool bit of undocumented functionality !!!
on GetPhrase(s)
try
return s's some paragraph's text some word thru some word
on error number -1728
return GetPhrase(s)
end try
end GetPhrase
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
<
mailto:email@hidden>
try
<
http://www2.linkedresources.com/tools/carthandle.html>
on error number -128
end try
}
_______________________________________________
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.