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 14:07:23 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (65 lines)
Hello Mark,

Thank you very much for your code.

I ended with the following code:

property file_1 : ""
property runtime : 0
property firsttime : "yes" -- I added this line

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 quit -- I added "quit" here; the script quits immediately after this dialogue
	else if (number of droppedItemsList) = 1 then
		if firsttime = "yes" then -- I added this "if... end if" for another dialogue
			display dialog "Please drop another file..."
			set firsttime to "no"
		end if
		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
	
	set file_1 to ""
	set firsttime to "yes" -- I added this line to restore the value of "firsttime"
	quit
end open

One thing that I don't understand well in this is the meaning and the use of "quit". Could you please explain this?

Thank you very much in advance.

Best regard,

Nobumi Iyanaga
Tokyo,
Japan

ATOM RSS1 RSS2