Article Preview
Buy Now
| Print: | |
| PDF: |
Ask The Experts
Article
Issue: 1.6 (June/July 2003)
Author: Seth Willits
Article Description: No description available.
Article Length (in bytes): 8,153
Starting Page Number: 32
RBD Number: 1616
Resource File(s):
1616.sit Updated: Friday, October 17, 2003 at 12:21 PM
Related Web Link(s):
tom-at-thezaz.net
http://www.tildesoft.com/
Known Limitations: None
Excerpt of article text...
I didn't have any trouble
Q: How can I execute a dynamic AppleScript directly from REALbasic?
This is a good question. Currently there are some issues with REALbasic 4.5 and AppleScripts under OS X (these issues have been resolved with later versions of OS X and RB, though). Thankfully, there are a few ways we can work around this. Other than doing the hokey-pokey wearing your clothes inside out, in OS X we can use a very simple shell call, and in Classic we can use a good chunk of code that utilizes declare statements to get the job done.
For OS X, the shell method is as simple as passing a few parameters to the command line utility osascript. To execute an AppleScript directly from a string variable, we use:
Sub RunAppleScript(script as string)
dim s as Shell
s = new shell
s.execute "/usr/bin/osascript -e '" + script + "'"//text of Applescript
msgBox s.result
// Notice the -e switch.
End Sub
To execute a script directly from a file, we use:
Sub RunAppleScript(UnixPathToScript as string)
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|








