MACSCRPT Archives

February 2012

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Nobumi Iyanaga <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Sat, 11 Feb 2012 11:50:56 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (64 lines)
Hello Mark,

Thank you very much for your code.

It works well if it is the first time you drop only one file. Then it will wait for the next file. -- But unfortunately, it does not work in the subsequent runs, because (I think) the value of "property file_1" stays the same as the first time it had a value.

I am sure this method is better than the other way (which uses the "choose file" dialogue) because with the "choose file" dialogue, the user tends to be not sure of selecting the right file...

Perhaps it would be possible to work around this problem if instead of "property", I write the file_1's path in a temporary file somewhere, and delete it each time the script finish its work. -- Unfortunately, I don't know how to achieve this.

Thank you in advance for any further idea.

Best regard,

Nobumi Iyanaga
Tokyo,
Japan


On Feb 11, 2012, at 2:35 AM, Mark Lively wrote:

> This should be closer to what you are looking for.  Save it as stay open.  It will hang out for 5 minutes after the first file has been dropped waiting for a second different file.
> 
> property file_1 : ""
> property runtime : 0
> 
> on idle
> 	if runtime < (current date) - 5 * minutes then
> 		set file_1 to ""
> 		quit
> 	end if
> 	return 1
> end idle
> 
> on open (droppedItemsList)
> 	set runtime to current date
> 	if (number of droppedItemsList) ≥ 3 then
> 		display dialog "This droplet accepts two files"
> 		return
> 	else if (number of droppedItemsList) = 1 then
> 		if file_1 = "" then
> 			set file_1 to first item of (droppedItemsList)
> 			set file_1 to POSIX path of file_1
> 			return
> 		else
> 			set file_2 to first item of (droppedItemsList)
> 			set file_2 to POSIX path of file_2
> 		end if
> 	else if (number of droppedItemsList) = 2 then
> 		set file_1 to first item of (droppedItemsList)
> 		set file_1 to POSIX path of file_1
> 		
> 		set file_2 to second item of (droppedItemsList)
> 		set file_2 to POSIX path of file_2
> 	end if
> 	if file_1 = file_2 then
> 		display dialog "You have chosen the same file. Quitting..."
> 		return
> 	end if
> 	
> 	display dialog file_1 & return & " compared with " & return & file_2
> 	quit
> end open

ATOM RSS1 RSS2