I want to receive an incoming file (for example, if the file is opened through my application) and store it in a variable. Can it be done?
Accepted Reply
Ah, OK. In that case the standard technique is to create an on open handler. For example, if you put this code in a script:
on open fileList
repeat with f in fileList
set p to POSIX path of f
display dialog "Path: " & p buttons {"OK"} default button "OK"
end repeat
end open
and save it as application, dropping items on to the application shows their paths in a series of dialogs.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Replies
if the file is opened through my application
I’m confused by your setup here. Do you have a script and an application? Or have you exported your script as an application?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
I have a application
I have a application
OK. Presumably this is a Mac app, in that AppleScript is only available on the Mac. What language is the app written in? And what UI framework does it use (AppKit, UIKit, SwiftUI)?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
This application written on AppleScript using Script Editor
Ah, OK. In that case the standard technique is to create an on open handler. For example, if you put this code in a script:
on open fileList
repeat with f in fileList
set p to POSIX path of f
display dialog "Path: " & p buttons {"OK"} default button "OK"
end repeat
end open
and save it as application, dropping items on to the application shows their paths in a series of dialogs.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"