Re: drapplet?
Re: drapplet?
- Subject: Re: drapplet?
- From: "S. J. Cunningham" <email@hidden>
- Date: Wed, 25 Jan 2017 20:31:11 -0500
On Jan 25, 2017, at 5:51 PM, Mitchell L Model wrote:
I rarely make script apps, so this may be a really naive question. Is it widely (at all?) recognized that you can have a script app that can be run either by double-clicking or by dragging files over it? A "drapplet"? As follows:
-- Demonstration of a "drapplet": -- a script that can be run either by double-clicking -- or by dragging files over its icon -- -- Mitchell L Model, email@hidden, 2017-01-25
on run argv display alert "Double-clicked or run from editor" -- I don't know how to tell the difference end run
on open args set oldDelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to {return & return} try display alert "Files dropped:" & return & return & (args as text) end try set AppleScript's text item delimiters to oldDelimiters end open
Here is a template I use that allows you to use the same code whether it is dropped or run:
(* This technique allows you to differentiate whether the main routine was entered by a drop or by a direct open. *)
property p_Open : false global g_OpenArgList
on open (aList) global g_OpenArgList
set g_OpenArgList to aList set p_Open to true run end open
on run if p_Open then set p_Open to false set aList to g_OpenArgList set theSender to "open" else set aList to {1, 2, 3} set theSender to "run" end if
display dialog "aList from \"" & theSender & "\": " & aList as string with title "Main Routine"
end run
Steve ------------------ OS X 10.6.8, AppleScript 2.1.2
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
References: | |
| >drapplet? (From: Mitchell L Model <email@hidden>) |