"a reference to" failure
"a reference to" failure
- Subject: "a reference to" failure
- From: "Marc K. Myers" <email@hidden>
- Date: Wed, 20 Jun 2001 13:51:58 -0400
- Organization: [very little]
I wrote the attached script and found that it worked as planned when it
was the top level or run handler of a script. I discovered, though,
that the size of the applet file grew after running it, so I tried to
get rid of the top level variables by putting the body of the script
into a lower level handler. When I did this the references to items in
the list referred to by "wordRef" stopped working, with the error
message "Can't make some data into the expected type". Is there a
reason why references like this will only work in top level or run
handler code?
(* Glossary Maker 6/20/01 *)
--on makeGloss()
set theFile to (choose file of type {"TEXT"})
set startTime to the ticks
tell application "Finder"
open theFile using application file id "TBB6"
set theName to name of theFile
set theFldr to (container of theFile) as text
end tell
tell application "Tex-Edit Plus"
set the capitalization of the contents of window 1 to lowercase
set theText to contents of window 1
close window 1 without saving
end tell
tell me to activate
set wordList to sort (words of theText)
set wordRef to a reference to wordList
(* NEXT LINE CONTAINS THE REFERENCE THAT BREAKS *)
set glossList to {item 1 of wordRef}
repeat with i from 2 to (count wordRef)
if (item i of wordRef) is not (item (i - 1) of wordRef) then
set glossList to glossList & (item i of wordRef)
end if
end repeat
set {od, AppleScript's text item delimiters} to [optn-L]
{AppleScript's text item delimiters, {return}}
set theGlossary to (glossList as text)
set AppleScript's text item delimiters to od
tell application "Tex-Edit Plus"
activate
make new window with properties {name:theName & " Glossary"}
set contents of window 1 to theGlossary
if (count of theName) > 29 then
set theName to characters 1 thru 29 of theName
end if
save window 1 in file (theFldr & theName & " '")
end tell
set theSecs to ((the ticks) - startTime) / 60 -- convert ticks to seconds
set theSecs to (round (theSecs * 100)) / 100 -- round to 2 decimal places
tell me to activate
display dialog "Glossary processing took " & (theSecs as text) & [optn-L]
" seconds" buttons {"OK"} default button 1 giving up after 10 with
icon note
--end makeGloss
--makeGloss()
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[6/20/01 1:49:05 PM]