Page 1 of 1

Multi-line Do script as AppleScript broken?

Posted: Mon Dec 07, 2015 1:59 pm
by PaulDaMacMan
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

Re: Multi-line Do script as AppleScript broken?

Posted: Mon Dec 07, 2015 3:10 pm
by Martin Koob
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

Re: Multi-line Do script as AppleScript broken?

Posted: Mon Dec 07, 2015 3:26 pm
by Martin Koob
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

Re: Multi-line Do script as AppleScript broken?

Posted: Mon Dec 07, 2015 6:25 pm
by PaulDaMacMan
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.

Re: Multi-line Do script as AppleScript broken?

Posted: Tue Dec 08, 2015 3:10 pm
by PaulDaMacMan
Strange, I couldn't nail it down and it seems to be working fine now.
Anyway, thanks.