Re: Scripts no longer work in 9.2.2
Re: Scripts no longer work in 9.2.2
- Subject: Re: Scripts no longer work in 9.2.2
- From: Laine Lee <email@hidden>
- Date: Sat, 08 Dec 2001 00:42:06 -0600
I have also had trouble with some of my Akua Sweets based scripts since
upgrading to 1.7F2 a couple of weeks ago. Same problems exist with 1.7.
Here are 3 similar scripts. The first two error and the last one works. How
come? Only the second from last line is different.
To test them you need Applescript 1.7, Akua Sweets 1.4.3 and a small amount
(<30 characters) of text on the keyboard. At the end of this message is a
script that when saved as an application or run from the script editor will
place a sound, picture, or text on the clipboard into a clipping file of the
appropriate type on the desktop. Thanks.
1-------
set cp to {}
set flavs to (clip with content flavors)
set tItems to (collect items of flavs that match "TEXT")
if (tItems is not {}) then
set flavs to {"TEXT"} & ,
(edit list flavs with edits tItems with removal of items)
end if
repeat with flav in flavs
set cp to cp & {clip flavor flav}
end repeat
set myFile to (((path to desktop) as string) & ,
item 1 of cp)
save clipping cp in myFile
---------
2--------
set cp to {}
set flavs to (clip with content flavors)
set tItems to (collect items of flavs that match "TEXT")
if (tItems is not {}) then
set flavs to {"TEXT"} & ,
(edit list flavs with edits tItems with removal of items)
end if
repeat with flav in flavs
set cp to cp & {clip flavor flav}
end repeat
set myFile to (((path to desktop) as string) & ,
item 1 of cp) as alias
save clipping cp in myFile
---------
3--------
set cp to {}
set flavs to (clip with content flavors)
set tItems to (collect items of flavs that match "TEXT")
if (tItems is not {}) then
set flavs to {"TEXT"} & ,
(edit list flavs with edits tItems with removal of items)
end if
repeat with flav in flavs
set cp to cp & {clip flavor flav}
end repeat
set myFile to (((path to desktop) as string) & ,
item 1 of cp) as file specification
save clipping cp in myFile
---------
save clipboard to clipping file on desktop:
--------------------
property kasIndex : 0
global flavs
global tItems
on run
-- Save as a clipping and tell Finder to open it
set kasIndex to kasIndex + 1
set flavs to (clip with content flavors)
set tItems to (collect items of flavs that match "TEXT")
if (tItems is not {}) then
set cliptext to clip flavor "TEXT"
if (number of (every item of cliptext as list)) + 9 > 32 then
set myFile to ((path to desktop) & ,
items 1 through 16 of cliptext as text) ,
as file specification
else
set myFile to ((path to desktop) & ,
every item of cliptext as text) as file specification
end if
else
if (clipboard info) = {} then
display dialog ,
"Are you sure the
clipboard isn't empty?" buttons {"Cancel"} ,
default button 1 with icon 2 giving up after 10
else
display dialog "You may enter a short name for the clipping
or just click \"OK\" and
the clipping will be numbered." default answer "Clipping"
set the ClippingName to the text returned of the result
if the ClippingName is in {"Clipping"} then
set myFile to (((path to desktop) & ClippingName & ,
" #" & kasIndex) as string) as file specification
else
set myFile to (((path to desktop) & ClippingName) ,
as string) as file specification
end if
end if
end if
-- Save it
try
save clipping GetClipboard() in myFile
on error
try
set ShortName to items 1 ,
through 16 of ClippingName as text
set myFile to (path to desktop & ,
ShortName & " clipping") as file specification
save clipping GetClipboard() in myFile
on error
set cliptext to clip flavor "TEXT"
try
if (number of (every item of cliptext as list)) ,
+ 9 > 32 then
set myFile to (((path to desktop) & ,
items 8 through 23 of cliptext as text) ,
& " clipping") as file specification
else
set myFile to (((path to desktop) & ,
every item of cliptext as text) & ,
" clipping") as file specification
end if
save clipping GetClipboard() in myFile
on error
set cliptext to munge cliptext from ":" to "_"
if (number of (every item of cliptext as list)) ,
+ 9 > 32 then
set myFile to (((path to desktop) & ,
items 1 through 16 of cliptext as text) ,
& " clipping") as file specification
else
set myFile to (((path to desktop) & ,
every item of cliptext as text) & " clipping") ,
as file specification
end if
save clipping GetClipboard() in myFile
end try
end try
end try
tell application "Finder" to open myFile
end run
on GetClipboard()
-- Get flavours available
set cp to {}
set flavs to (clip with content flavors)
-- Make sure "TEXT" goes first,
--otherwise styled text creates sound clipping icon'd files
set tItems to (collect items of flavs that match "TEXT")
if (tItems is not {}) then
set flavs to {"TEXT"} & ,
(edit list flavs with edits tItems ,
with removal of items)
end if
-- Collect the data
repeat with flav in flavs
set cp to cp & {clip flavor flav}
end repeat
return cp
end GetClipboard
--------------------
--
Laine Lee
email@hidden
http://www.txdirect.net/users/llee