His response included the following words of enlightenment with regards to the "Choose Application" dialog.
The official way to do this is to pass kOSAModeNeverInteract as a mode flag when calling OSACompile. Unfortunately, OSAScript doesn't give you that level of control -- you'd have to call OSACompile yourself instead of using the OSAScript class. However, that's not much additional code.
Failing that, it's possible to make the "choose application" fail:
- Make the process not allow user interaction. osascript(1) does this, simply by virtue of being a command-line app; I'm not sure how you'd arrange this from a normal app, if indeed you can.
- Add an application handler for the "choose application" command (event code syso/ppcb), which will override the one from Standard Additions, and have it simply return errAEEventNotHandled.
- Install a custom Send function (use OSASetSendProc([[myScript language] componentInstance], mySendProc, ...)) that checks for syso/ppcb and immediately fails. (Anything else is, of course, passed through as-is.)
Hello list
Whilst compiling/executing against an application (say "duff") that cannot be found ie:
tell application "duff"
end tell
the "Choose Application" dialog appears.
I know why it appears and that it wants the application "duffs" dictionary, without which not much can happen.
But is it possible to request that in such cases compilation/execution simply fails?
I am compiling my scripts from within a cocoa app using the OSAScript class of the OSAKit:
OSAScript - (BOOL)compileAndReturnError:(NSDictionary **)errorInfo;
I don't mind digging down further into the OSA if a solution is in there somewhere.
Regards
Jonathan