Multi-line Do script as AppleScript broken?

If you find an issue in LiveCode but are having difficulty pinning down a reliable recipe or want to sanity-check your findings with others, this is the place.

Please have one thread per issue, and try to summarize the issue concisely in the thread title so others can find related issues here.

Moderator: Klaus

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

Multi-line Do script as AppleScript broken?

Post by PaulDaMacMan » Mon Dec 07, 2015 1:59 pm

I have a multi-line AppleScript in a field I'm trying to run with do fld X as AppleScript and get compile error

If I run each line individually in a script (replacing quotes with "&qoute&" of course):
tell application "GarageBand" to activate
tell application "System Events" to keystroke "r"
it works.

What gives? Is AppleScript in LC broken? Should I file a bug report?

LC 8.0dp10 on Mac OX X 10.6.8
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 256
Joined: Sun May 27, 2007 8:19 pm

Re: Multi-line Do script as AppleScript broken?

Post by Martin Koob » Mon Dec 07, 2015 3:10 pm

Hi

I just testied some applescripts that I have in my application and they seem to work.

In some cases I construct the multiline using CR for the line breaks. For example

do "tell application" & quote & "Finder" & quote & CR & "activate" & CR & "end tell" as applescript

I have another that has nested tells and that works as well.

For another case I have a script stored as a custom property of a stack with a placeholder for a file path that I replace in a LiveCode script before executing it

customproperty cDeleteMacFolderScript
---------------
tell application "finder"
delete **foldertodelete**
end tell
-----------------

Livecode script

Code: Select all

put cDeleteMacFolderScript of stack "my stack" into tScript
replace "**foldertodelete** with tMacFolderPath in tScript
do tScript as applescript
These are all working in LC8 DP10 but running Yosemite.

So It looks like it is not an LC 8 problem with applescript.

Martin

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 256
Joined: Sun May 27, 2007 8:19 pm

Re: Multi-line Do script as AppleScript broken?

Post by Martin Koob » Mon Dec 07, 2015 3:26 pm

I just tried to do field X as applescript with a multiline applescript and it worked as well in LC 8 DP10 Yosemite.

So perhaps it is something is your applescript itself. Perhaps try compelling it in script editor to see if it will work there.

Martin

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

Re: Multi-line Do script as AppleScript broken?

Post by PaulDaMacMan » Mon Dec 07, 2015 6:25 pm

I did try the script in AppleScript editor first and then copied & pasted to an LC field, made LC button to run script in that field.
Also tried using it in an lc script inserting quotes & carriage returns just as you did. When I made the nested tells be separate do as applescript statements they worked. The only difference I see is I'm running Snow Leo. I'll take it to work and try it on 10.10.5.
Thanks for checking Martin.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

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

Re: Multi-line Do script as AppleScript broken?

Post by PaulDaMacMan » Tue Dec 08, 2015 3:10 pm

Strange, I couldn't nail it down and it seems to be working fine now.
Anyway, thanks.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

Post Reply