Passing Values To AppleScript

Is there a way to pass values from Xojo to AppleScript? For instance, if I have a variable in Xojo with the value of 2, is it possible to pass the value 2 to AppleScript?

Thanks!

Check out the section “Passing Parameters” at Using AppleScripts in your app — Xojo documentation

If you have more complex AppleScript or want to create them in Xojo code have a look at Xojo + Alfred . The code uses the MBS plugin.

In Xojo you have to enter:
MyAppleSCript(MyText) ' You can only send text
in your script:
on run {MyTextFromXojo}
set MyNumber to MyTextFromXojo as integer

1 Like

Thanks, Beatrix! The documentation is the first place I went to, but it doesn’t seem to be organized very well. I did a search for AppleScript and read everything that came up. But there was nothing in my search results about “Passing Parameters.” Anyways, I’m glad you knew where to find it!

Also check setting properties here

Tip of the day: AppleScript with Properties to pass file path

Also check NSAppleScriptMBS and the property methods there.

1 Like

Often i use a Google-Search to find something in the Xojo-Documentation:
xojo documentation applescript does show infos about parameters and return values in the first link.

Search inside the Xojo documentation is a mess much too often.

1 Like