Droplet that crash (2)
Droplet that crash (2)
- Subject: Droplet that crash (2)
- From: Iwan Buetti <email@hidden>
- Date: Thu, 12 Feb 2004 12:42:28 +0100
Why this droplet crashes?
you have to copy-paste the script below in Application.applescript
(Xcode), build and drop a .mov file (not double-click) over the
compiled app. The script will launch, execute and crash. But if you add
a line with a "display dialog" the app will not crash (see below).
It's more than 2 month that i've tried to have a solution... :-(
Please, help me.
Thnx
=====================================================================
Application.applescript:
=====================================================================
on idle
(* Add any idle time processing here. *)
return true
end idle
on open names
(* Add your script to process the names here. *)
repeat with i from 1 to the count of names
set this_item to item i of names
set the item_info to info for this_item
if (folder of the item_info is false) then
if (alias of the item_info is false) then
process_item(this_item, item_info)
else
display dialog "You can not drag aliases." buttons {"Exit"} default
button "Exit"
end if
else
display dialog "You can not drag folders." buttons {"Exit"} default
button "Exit"
end if
end repeat
quit
end open
on process_item(this_item, item_info)
set thePath to this_item as text
set thePath to POSIX path of thePath
set theName to the name of the item_info as text
set theShortName to trim_line(theName, ".mov", 1)
set thePathOfFolder to trim_line(thePath, theName, 1)
set thePathOfFolder to trim_line(thePathOfFolder, "/", 1)
-- IF YOU INSERT HERE A "DISPLAY DIALOG" THE DROPLET WILL NOT
CRASH!!!! WHY???
end process_item
on trim_line(this_text, trim_chars, trim_indicator) -- from apple.com
-- 0 = beginning, 1 = end, 2 = both
set x to the length of the trim_chars
-- TRIM BEGINNING
if the trim_indicator is in {0, 2} then
repeat while this_text begins with the trim_chars
try
set this_text to characters (x + 1) thru -1 of this_text as string
on error
-- the text contains nothing but the trim characters
return ""
end try
end repeat
end if
-- TRIM ENDING
if the trim_indicator is in {1, 2} then
repeat while this_text ends with the trim_chars
try
set this_text to characters 1 thru -(x + 1) of this_text as string
on error
-- the text contains nothing but the trim characters
return ""
end try
end repeat
end if
return this_text
end trim_line
=====================================================================
_______________________________________________
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.