FROM : jonathan@mugginsoft.com
DATE : Fri Jan 04 21:56:27 2008
Hi
I am trying to call as wide as possible a variety of AppleScripts from
cocoa using NSAppleScript and am having trouble
finding a way of calling a script with a parameterised run handler.
eg: a script called beepn.scpt and containing
on run (n, interval)
repeat n times
beep
delay interval
end repeat
end run
can be executed from the terminal as:
osascript beepn.scpt 2 1
As yet I have been unable to call such a script from NSAppleScript.
So far my approach has been.
1. If the script has no specified run handler or a run handler without
parameters then
use the NSAppleScript - executeAndReturnError method.
This works for scripts such as:
beep
or
on run
beep
end run
2. if the script contains a specified handler then I construct an
NSAppleEventDescriptor
specifying the handler and parameters and call the NSAppleScript
- executeAppleEvent method.
This works for scripts such as:
on beep(n, interval)
repeat n times
beep
delay interval
end repeat
end beep
Unfortunately neither of these methods can handle a script with run
handler parameters.
Calling NSAppleScript -executeAndReturnError gives no output - as may
be expected.
Calling the run handler explicitly by name with NSAppleScript -
executeAppleEvent results in:
Error -1708 occured the run(Hello) call: (null)
which evaluates to errAEEventNotHandled -1708 Event wasnt handled
by an Apple event handler.
Passing an empty or nil handler name also does not work.
Of course I can change the run handler name but that means editing the
script, which I would like to avoid if at all possible.
Any thoughts would be welcome.
DATE : Fri Jan 04 21:56:27 2008
Hi
I am trying to call as wide as possible a variety of AppleScripts from
cocoa using NSAppleScript and am having trouble
finding a way of calling a script with a parameterised run handler.
eg: a script called beepn.scpt and containing
on run (n, interval)
repeat n times
beep
delay interval
end repeat
end run
can be executed from the terminal as:
osascript beepn.scpt 2 1
As yet I have been unable to call such a script from NSAppleScript.
So far my approach has been.
1. If the script has no specified run handler or a run handler without
parameters then
use the NSAppleScript - executeAndReturnError method.
This works for scripts such as:
beep
or
on run
beep
end run
2. if the script contains a specified handler then I construct an
NSAppleEventDescriptor
specifying the handler and parameters and call the NSAppleScript
- executeAppleEvent method.
This works for scripts such as:
on beep(n, interval)
repeat n times
beep
delay interval
end repeat
end beep
Unfortunately neither of these methods can handle a script with run
handler parameters.
Calling NSAppleScript -executeAndReturnError gives no output - as may
be expected.
Calling the run handler explicitly by name with NSAppleScript -
executeAppleEvent results in:
Error -1708 occured the run(Hello) call: (null)
which evaluates to errAEEventNotHandled -1708 Event wasnt handled
by an Apple event handler.
Passing an empty or nil handler name also does not work.
Of course I can change the run handler name but that means editing the
script, which I would like to avoid if at all possible.
Any thoughts would be welcome.
| Related mails | Author | Date |
|---|---|---|
| jonathan@mugginsof… | Jan 4, 21:56 | |
| has | Jan 4, 23:46 | |
| jonathan@mugginsof… | Jan 5, 01:02 |






Cocoa mail archive

