• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: processing time & stack overflow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: processing time & stack overflow


  • Subject: Re: processing time & stack overflow
  • From: Timothy Bates <email@hidden>
  • Date: Sun, 26 Aug 2001 11:48:55 +1000

On 8/25/01 4:34 PM, "monk" <email@hidden> wrote:
> i'm back refining my 'text art project' script

I have no idea what the idea of the script is, but this seems a quicker way
to create files consisting of every word of a source file written out in
random order (plus a bunch of eye candy up front)
cheers,
tim
...
set _source to open for access (choose file with prompt "choose source to
juxtapose:")
display dialog "process by:" buttons {"line", "paragraph", "word"} default
button "word"
set _buttonreply to button returned of result
if _buttonreply is "word" then
set fileDelimitters to {return, space} --read variable as list by word
and set new variable for list manipulation
else if _buttonreply is "line" then
set fileDelimitters to {return} --read variable as list by line
(sentence)
else --"paragraph"
set fileDelimitters to {return & space} --read variable as list by
paragraph (word & line)
end if
try
set _listsource to (read _source as list using delimiter
fileDelimitters)
close access _source
on error
try
close access _source
end try
end try

--return _listsource
set _fileamount to "1"
repeat until class of _fileamount is integer and _fileamount > 0 and
_fileamount < 100
try
set _fileamount to (text returned of (display dialog "enter amount
of files to generate from source (1-99)?" default answer _fileamount giving
up after 12)) as integer
on error
display dialog "that wasn't the right kind of number!"
end try
end repeat

tell application "Finder"
activate
set _newfolder to (path to desktop as string) & "juxtatext(s)"
try
open _newfolder
on error
set _newfolder to make new folder at desktop with properties
{name:"juxtatext(s)"}
open _newfolder
end try
set size of container window of _newfolder to {253, 527}
set view of container window of _newfolder to kind
end tell

try
repeat with i from 1 to _fileamount
set _filename to "juxtatext " & characters -2 thru -1 of ("0" & i)
set _juxtatext to open for access file (((path to desktop) as
string) & "juxtatext(s):" & _filename) with write permission
my juxtapose(_listsource, _juxtatext)
close access _juxtatext
end repeat
on error errmsg number errNbr
try
close access _juxtatext
end try
error errmsg number errNbr
end try

on juxtapose(_listsource, _juxtatext)
set _listsource to my randomize(_listsource)
set {AppleScript's text item delimiters, oldTIDs} to {{" "},
AppleScript's text item delimiters}
write ("" & anItem & space) to _juxtatext starting at eof
set AppleScript's text item delimiters to oldTIDs
end juxtapose

to randomize(TheList)
repeat with i from length of TheList to 1 by -1
set current_item to (random number from 1 to i)
tell TheList -- exchange item current_item with item i
set temp to item i
set item i to item current_item
set item current_item to temp
end tell
end repeat
return TheList
end randomize
Dr Timothy Bates <mailto:email@hidden>
Macquarie Centre for Cognitive Science (MACCS)
Macquarie University
Ph 61 (2) 9850 8623
Fx 61 (2) 9850 6059


  • Follow-Ups:
    • Re: processing time & stack overflow
      • From: Timothy Bates <email@hidden>
References: 
 >processing time & stack overflow (From: monk <email@hidden>)

  • Prev by Date: Re: Script running the wrong application
  • Next by Date: Re: processing time & stack overflow
  • Previous by thread: processing time & stack overflow
  • Next by thread: Re: processing time & stack overflow
  • Index(es):
    • Date
    • Thread