BUG? AppleScript do script in standalone broken?

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
PaulDaMacMan
Posts: 145
Joined: Wed Apr 24, 2013 4:53 pm

BUG? AppleScript do script in standalone broken?

Post by PaulDaMacMan » Thu Feb 01, 2018 9:22 am

I have an applescript applet that talks to back & forth with a liveCode stack.
It works fine running with the IDE but breaks after being saved as a standalone and redirecting the do script scriptText to the standalone.app. It does however respond to the normal system wide default AppleScript commands (open & quit). Going in the other direction works fine, I can execute scripts in the AppleScript applet from the LiveCode standalone with do as applescript. It seems Apple's Script Editor does not see "do script" as valid for the standalone, but it compiles fine when pointed at the LC IDE.
I know this has broken in the past, could it be broken again? Is the (rather sparse LC) AS dictionary not being copied to the standalone?

PaulDaMacMan
Posts: 145
Joined: Wed Apr 24, 2013 4:53 pm

Re: BUG? AppleScript do script in standalone broken?

Post by PaulDaMacMan » Thu Feb 01, 2018 9:53 pm

Hmm, may have been related to trying to do a custom signature / info.plist for my app (because I wanted this app to run in the background and not show in the Dock)
OSAScriptingDefinition & key TestStack.sdef was missing from the Standalone .app's info.plist, once I added that the script compiled in Apple's Script editor... still didn't work, then I rebuilt the standalone and now it's working as expected.
Was pulling what's left of my hair out for a day on that one! Shwew! :mrgreen:

bwmilby
Posts: 74
Joined: Wed Jun 07, 2017 5:37 am
Contact:

Re: BUG? AppleScript do script in standalone broken?

Post by bwmilby » Thu Feb 01, 2018 11:25 pm

That should have been fixed. What version are you using? I’ll dig up the PR and check that nothing has changed.
----
Edit:

Just checked... in DP11 the .sdef file is in the standalone app but is getting stripped out for some reason. The .plist file is also missing the key needed to reference the file. The first key is already there, but the second needs to be added. If you don't specify a .sdef file or specify one that is missing, then you get no dictionary support. The app can still respond to events, you just need to dispatch them using the special code (I'd have to look up the specifics, but I think they are here in the forums).

Code: Select all

	<key>NSAppleScriptEnabled</key>
	<string>YES</string>
	<key>OSAScriptingDefinition</key>
	<string>terminology.sdef</string>
Edit2:

I finally read your second post correctly... Yes, defining a custom plist could cause an issue. What you need to ensure is present are the keys listed above. And also that the terminology.sdef file is located in the Resources folder which is in the same spot as the plist in the app (App/Contents/Resources).

PaulDaMacMan
Posts: 145
Joined: Wed Apr 24, 2013 4:53 pm

Re: BUG? AppleScript do script in standalone broken?

Post by PaulDaMacMan » Fri Feb 02, 2018 4:45 am

Yes I had already had those files in my resources folder, updated to match the binaries name, and the keys set correctly in the plist (plus extra keys I added)

I don't know what it was but Apples Script Editor wasn't seeing it as valid keywords and refused to compile "do script" for the script that pointed to my standalone stack on the AppleScript side, but did recognize them for the "tell" scripts that pointed to the IDE/Stack. Perhaps it was because I was editing those files after building the standalone? I pointed the standalone settings to my edited .plist, rebuilt, and it's all good now!

I'm doing some pretty fun / hairy experiments, mixing LiveCodeScript, AppleScript and Cocoa-AppleScript (AppleScriptObjC). Somehow I missed it when AppleScript became that powerful, why didn't anyone tell me!
I'm building a customizable NSStatusMenu Cocoa-AppleScript that communicates with my stack.app that's embedded in it's bundle. Already hit some gotcha's though where an AppleScript triggers a LCS Script that triggers another AppleScript... aaaaand CRASH! Fun!

I wish the "do as AppleScript" in LC supported scripts with cocoa-AppleScriptObjC mixed in, it doesn't seem to work (which is why my project is really 2 Apps that appear to be one, working together in the background). I see that SuperCard recently added an AppleScript() function that can handle cocoa infused scripts. It would be awesome if LC could do that, or just update existing capabilities...but working full-on on LiveCode Builder is probably better for LiveCode's future anyway.

Post Reply

Return to “Mac OS”