Easiest way to call a Xojo app from AppleScript with one text argument

Want to call from within Filemaker a Xojo app and pass just one text parameter.
What is the easiest way?
Some background. I have a Point-Of-Sale Filemaker app and an Epson networked receipt printer. When I use the printer driver from Epson all works fine but it takes 4 sec between pushing the receipt button and the printing of the receipt. To long.
When I use Xojo and a TCPsocket, it prints immediately. So I can make a simple Xojo app just to receive a string with all ESC/POS codes (the codes that Epson uses) and print the receipt.
I can call from within Filemaker an external app with an AppleScript command but how do I send the data to the Xojo app? By passing an argument? Or another method?
It’s a networked printer with an IP address and no server available.
I’m no Xojo expert. It needs to be simple and quick.
Any ideas?

If you are on the Mac, you should be able to do something like this from the command line:


echo "data" | nc 0.0.0.0 port#

…substituting the proper address and port numbers and data of course. You will use the Send Event script step, I believe.

Thanks Eric, but I don’t understand very well what you want to do. Execute a command line script from Filemaker that starts the Xojo app?
It is no problem to start the Xojo app, it is also no problem to send data from the Xojo app to the printer (using the TCPsocket) but how can I pass a text argument from Filemaker to the Xojo app?

Now I see. This could be a way to send the data from Filemaker directly to the printer.
Mmm… interesting. I’m going to try it out. Thank you!

You can send AppleEvents to your Xojo app. Look at the “AppleEventReceived” (or “HandleAppleEvent” in earlier versions) in the app class.
You don’t even need a dictionary, as you can pass raw data in AppleScript:

tell application “MyApp” to «event aevtstrs» “test”

In Xojo, with this example, you’ll get an AppleEventReceived event where eventClass=“aevt”, eventID=“strs” and theEvent.StringParam(“----”)=“test”.

2 Likes


What can be the cause of this error?
The Xojo-app is called PrintEpson.app.
I created an AppleEventReceived eventhandler that takes the StringParam and sends it to the Epson printer.

Do you

return true

in the Xojo-AppleEventReceived-Event?

1 Like

In previous times I used an AppleEvent to communicate between my main app and a helper app. I don’t remember why I changed that. IPC sockets never did it for me. I found it the easiest way to use a custom url handler. This works reliably but it requires fiddling a bit with a build script:

'scheme for clicking links
dim SchemeName as String = ConstantValue("MimeURLHandler.SchemeName")
call DoShellCommand("/usr/libexec/PlistBuddy -c ""add :CFBundleURLTypes:0 dict"" " + CurrentBuildLocation + "/" + appNameForShell)
call DoShellCommand("/usr/libexec/PlistBuddy -c ""add :CFBundleURLTypes:0:CFBundleURLName string '" + BundleID + "." + SchemeName + "'"" " + CurrentBuildLocation + "/" + appNameForShell)
call DoShellCommand("/usr/libexec/PlistBuddy -c ""add :CFBundleURLTypes:0:CFBundleURLSchemes array"" " + CurrentBuildLocation + "/" + appNameForShell)
call DoShellCommand("/usr/libexec/PlistBuddy -c ""add :CFBundleURLTypes:0:CFBundleURLSchemes:0 string '" + SchemeName + "'"" " + CurrentBuildLocation + "/" + appNameForShell)

I probably should remove the dependence of plistbuddy.

1 Like

It works with this Filemaker calculated AppleScript in Filemaker:

image

Thank you very much! It is easy and quick, exactly what I needed :pray:

1 Like