Bundle an application with mine?

Hi.

I’m relatively new to AS Studio, and I was making a frontend for the GNU calc calculator program. To get the output, I used a “do shell script”. It works fine, but only when I run it on my computer, which already has calc in the /usr/bin directory. How do I bundle the program with mine so that it works on other people’s computers as well?

In other words, I want to have the calc executable inside my application bundle in a way that my app can access it. How?

Thanks!

Assuming that the third-party stuff’s license doesn’t prohibit it, I would copy the executable to your bundle’s Resource folder and then use one of the following to get the path to it (changing to a POSIX path if needed).

Different methods of getting the path to a resouce in a bundle…

Most compatible:

set theResource to ((path to me as Unicode text) & "Contents:Resources:filename") as alias
--> alias

Only on Mac OS X 10.4 or later:

set theResource to (path to resource "filename")
--> alias

Only with AppleScript Studio’s bundle class (Technical Q&A QA1493):

set theResource to (resource path of main bundle) & "filename"
--> POSIX path

See also: Call a CLI executable in the Resources directory?

Thanks!

(btw, the license doesn’t prohibit it, it’s open source)