See How passing a variable from Shell to AppleScript? for an example how to use AppleScript from Xojo.