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
Multi-line Do script as AppleScript broken?
Moderator: Klaus
-
- Posts: 683
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
-
- VIP Livecode Opensource Backer
- Posts: 256
- Joined: Sun May 27, 2007 8:19 pm
Re: Multi-line Do script as AppleScript broken?
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
These are all working in LC8 DP10 but running Yosemite.
So It looks like it is not an LC 8 problem with applescript.
Martin
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
So It looks like it is not an LC 8 problem with applescript.
Martin
-
- VIP Livecode Opensource Backer
- Posts: 256
- Joined: Sun May 27, 2007 8:19 pm
Re: Multi-line Do script as AppleScript broken?
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
So perhaps it is something is your applescript itself. Perhaps try compelling it in script editor to see if it will work there.
Martin
-
- Posts: 683
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: Multi-line Do script as AppleScript broken?
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.
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.
-
- Posts: 683
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: Multi-line Do script as AppleScript broken?
Strange, I couldn't nail it down and it seems to be working fine now.
Anyway, thanks.
Anyway, thanks.