Hi, I’ve built an AppleScript application but everytime I run it, when I click one of my buttons, a dialog box always pops up saying “Can’t get end” why is this?
Model: MacBook Pro
AppleScript: 2.2
Browser: Safari 532.9
Operating System: Mac OS X (10.6)
maybe you forgot an end if, end tell, end repeat or something like that. It would be easier if you’d share the script with us, or at least a part of it.
Ah! That seems to have solved it, thanks! 
Model: MacBook Pro
AppleScript: 2.21
Browser: Google Chrome 5.0.307.9
Operating System: Mac OS X (10.6)
Hey guys
I’m brand new to apple script and ran into an error i can solve.
the script runs perfect but when i save it and run it as an application it comes up with the error can’t find end
can anyone see whats wrong with my script??
thanks in advance
tell application “iTunes” to play some track in playlist “temp”
tell application “iTunes”
repeat until player state is stopped
end repeat
end tell
end
tell application “iTunes”
if player state is stopped then delete tracks in playlist “temp”
end tell
end
Model: mid 2010 macbook pro 2.66 i7
AppleScript: 2.4.2
Browser: Safari 534.53.10
Operating System: Mac OS X (10.7)
Hi,
an end statement is not needed if the application tell block enfold only one line.
You can put the whole iTunes code into one single tell block.
I added a delay statement to avoid too frequently polling
tell application "iTunes"
play some track in playlist "temp"
repeat until player state is stopped
delay 5
end repeat
if player state is stopped then delete tracks in playlist "temp"
end tell
My script works fine (NO “can’t get end” message) when run as a script, but when saved as an application I get the “can’t get end” message when run.
The script simply allows me to select from mounted volumes, and store a small dateed text file at the root level of each selected volume. I use it so I know how recent a backup is.
Here is the script:
set CurrDate to date_time_to_iso(current date, “ymd”)
set CurrTime to date_time_to_iso(current date, “all”)
do shell script “ls /Volumes”
get paragraphs of result
set SelectedVolumes to choose from list (result) with title “Select Volumes to be time-tagged” with multiple selections allowed and empty selection allowed
set displist to “”
repeat with volname in SelectedVolumes
set displist to displist & return & volname
end repeat
display dialog CurrTime & return & return & "Volumes Selected: " & return & displist & return & "You have 15 seconds to cancel all … " with title “Selected Volumes will be time-tagged if OK” giving up after 15
repeat with xyz in SelectedVolumes
set SourceVolume to xyz
set SourcePath to “Volumes:” & SourceVolume
display dialog CurrTime & return & "Tagging Source Volume: " & SourceVolume & return & "SourcePath: " & SourcePath & return & "You have 2 seconds to cancel all … " with title “Tagging Source Volume” giving up after 2
set textFile to SourcePath & ": " & CurrDate & " " & SourceVolume -- & ".txt"
set dataPointer to open for access file textFile with write permission
try
set eof dataPointer to 0 -- erase anything there
write CurrTime to dataPointer
close access dataPointer
on error
try
close access file textFile
end try
end try
end repeat
end
on date_time_to_iso(dt, mode)
set {year:y, month:m, day:d, hours:h, minutes:min, seconds:s} to dt
set y to text 2 through -1 of ((y + 10000) as text)
set m to text 2 through -1 of ((m + 100) as text)
set d to text 2 through -1 of ((d + 100) as text)
set h to text 2 through -1 of ((h + 100) as text)
set min to text 2 through -1 of ((min + 100) as text)
set s to text 2 through -1 of ((s + 100) as text)
– return y & “-” & m & “-” & d & “T” & h & “:” & min & “:” & s – if colons wanted
if mode is “all” then return y & “-” & m & “-” & d & " @ " & h & min – returns YYYY-MM-DD @ HHMM
if mode is “ymd” then return y & “-” & m & d – & " @ " & h & min – returns YYYY-MMDD
if mode is “hm” then return h & min – returns HHMM
end date_time_to_iso
There’s an end statement after the 2nd end repeat, but there’s no matching tell.
I have no idea why it compiles, and then errors when run as applet.
This thread teach me something.
A script may compile even if it embed hundreds of useless “end”.
repeat 10 times
beep 1
end repeat
end
end
end
end
end
end
end
When I run it, the log report is :
tell current application
beep 1
beep 1
beep 1
beep 1
beep 1
beep 1
beep 1
beep 1
beep 1
beep 1
end tell
tell application “AppleScript Editor”
get end
get end
get end
get end
get end
get end
get end
end tell
When it’s saved as an application, I guess that what appears here as
tell application “AppleScript Editor”
will become
tell application “the_applet_name”
which will fail.
Yvan KOENIG (VALLAURIS, France) lundi 30 décembre 2013 16:39:27
Thanks, it was as simple as that extra “End”.
I had put it there for readability since the subroutine was below it.
I guess there is not a simple “end of code” or “stop” marker in Applescript?
If you wish to insert something marking the end of a piece of code, you may do that as a comment :
repeat 10 times
beep 1
end repeat
# end of code
Yvan KOENIG (VALLAURIS, France) mardi 31 décembre 2013 11:03:14