Calling an applescript

I’m assuming that “executeapplescript” has replaced “startscript” in Panorama 6?

They don’t do exactly the same things, but executeapplescript works, and startscript does not, so I guess you could say that. Startscript would run a script that was in a separate file. ExecuteAppleScript will cause the result of its parameter to be compiled and executed as an AppleScript.

I may have misinterpreted. I was thinking this was a Panorama 6 question. To the best of my knowledge, StartScript has been non-functional since Panorama V.

It’s a Panorama X question. As far as I know, this is in use daily in a multiuser environment with Panorama 6 and Enterprise. They call an applescript using startscript to send emails after printing, multiple times a day.

So how does one start an Applescript from Panorama X? Is it the “applescript" statement?

Much like ExecuteAppleScript is the more capable AppleScript statement.

For example:

applescript ||| tell application "Calendar"
	       set theCalendarNames to title of every calendar
end tell |||,ScriptResult

You’ll find it under “AppleScript” in Panorama Help

Maybe (probably) I’m missing something. “startscript” in a procedure allowed you to start running an external Applescript in Pan 6. It did its own thing with no feedback needed. I need to do the same in Pan X. Is there a statement that does this?

I’m with Dave on this – the startscript statement has not worked, at least not reliably in a long, long time, over ten years. The Apple API it used would usually crash. If it worked for you, Jeff, you are a miracle worker.

I just did a google search and found this web site that says you can run an AppleScript from the command line.

If this web site is accurate you could run an AppleScript from either Panorama X (or 6) with a command like this.

shellscript {osascript `/example/path/to/AppleScript.scpt`}

Note: I have not tested this.

If it is verified that this works, perhaps I’ll add StartScript to Panorama X with a custom statement that uses this technique.

This is working for me, if I remove the back ticks.

shellscript {osascript /Users/dthmpsn1/Desktop/Testing.scpt}

ran a simple display dialog script, and the dialog appeared.

1 Like

The back ticks are needed if you are using a quoted osascript with the -e option like this:

shellscript {osascript -e 'display dialog "Hello" with title "Hello"'}
message "OK"

I added the separate message to see if that would popup before the applescript dialog was dismissed but it would not come up until I closed the script’s dialog. This was true using a path rather than a quoted script as well. If the script is run outside of Panorama I can leave the applescript dialog open and run a message statement in Panorama and it comes right up.

Most of this, I’m sure Gary knows, but for the sake of completeness, shellscript is a custom statement. It uses executeapplescript in its code. The executeapplescript is executing a script with the do shell script AppleScript command in its code, and we are putting an osascript command in the shell script.

osascript writes the AppleScript result to stdout. do shell script returns the value in stdout as its value. ExecuteAppleScript then returns that value to Panorama as its result. Panorama is waiting for executeapplescript to finish before it continues the procedure.

I’m not sure if startscript had to wait for the AppleScript to end, but I do remember some people were using it to start scripts that then turned around and told Panorama to do something. I think that would have gotten pretty awkward if Panorama had already resumed the procedure with the startscript command in it.

I just ran an experiment using openanything on a script saved as an application and it is able to run the applescript separate from Panorama. This is the code I used on a script app file in the same folder as my Panorama database file:

openanything ""   //script to simply open a "Hello" dialog
message "OK"

This actually had the Panorama message dialog come up first with the applescriipt dialog from the script app following right behind. This means that control was returned to Panorama as soon as the openanything statement fired off.