Initiating app by dropping files OR by running?

I’m trying to combine two apps into one if possible. They are navigational tools.

The first runs as a droplet and processes a file for it’s naming convention and then uses that info to reveal a path to a server folder

The second prompts the user to enter a piece of info that is then used to reveal a path to a server folder.

Is there any way to combine? i.e. run one set of operations if a file is dropped and another if the user runs the app directly?

Here is a script which I use daily.
Must be saved as an application.


# Code executed when we double click the app's icon
on run
	set _ to choose file with prompt "Choose a file …"
	my TraiteLeFichier(_)
end run


on open sel # sel is the list of aliases dropped upon the app's icon
	my TraiteLeFichier(sel's item 1)
end open # fin 2


on TraiteLeFichier(zefile)
		set leChemin to zefile as text
		set the clipboard to (quote & leChemin & quote)
	on error MsgErr number NroErr
		if NroErr is not -128 then
			beep 2
			tell application "Finder" to ¬
				display dialog "" & NroErr & " : " & MsgErr with icon 0 ¬
					buttons {"Oops"} giving up after 20
		end if
	end try
end TraiteLeFichier


Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 2 février 2020 22:36:09

This cleared it up for me. I wasn’t using a “process file” function in the run and open sections. Thanks so much!!