KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Passing arguments to AppleScript using LAUNCH EXTERNAL PROCESS
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac OS X
Published On: November 24, 2010

The Tech Tip Using LAUNCH EXTERNAL PROCESS to launch Applescripts explained the basics of launching an AppleScript script using the 4D command LAUNCH EXTERNAL PROCESS. The bascis are:

LAUNCH EXTERNAL PROCESS("osascript <POSIX path to sript file>")


Beginning with Mac OS 10.4 osascript arguments can be passed to an AppleScript script. The new definition is:



The man page states: Any arguments following the script will be passed as a list of strings to the direct parameter of the "run" handler.

So what does that translate to in 4D?

LAUNCH EXTERNAL PROCESS("osascript <POSIX path to sript file> <Argument1> <Argument2> <Argument3>")


Notice that there is a space character between the path to the script file and Argument1, as well as a space character between each ot the arguments.

So now you can write an AppleScrript script that accepts arguments and then call it from different places within yor 4D application with custom arguments used in each call.