I have been using an AppleScript like this
repeat with ImageCounter from 1 to everyImageCount
set imagepath to item ImageCounter of everyImagePathList
tell my application "System Events" to if not (exists file imagepath) then
tell application "Capture One 11" to tell COPDocRef to tell thisCollection to set imageName to name of image ImageCounter
loq_Results2(0, false, ("Image " & imageName & " not found at " & imagepath))
set countImageNotFound to countImageNotFound + 1
end if
end repeat
I have just discovered that the line “tell my application “System Events” to if not (exists file imagepath) then”
causes an “unable to continue with loq_Results2” error when this line executes:
"loq_Results2(0, false, (“Image " & imageName & " not found at " & imagepath))”
Prefacing the second line with “my” clears the problem, as does separating the “tell” clause from the “If” clause
I don’t understand why there is an interaction. I thought the scope of the tell statement in this form was the one line only.
This works
repeat with ImageCounter from 1 to everyImageCount
set imagepath to item ImageCounter of everyImagePathList
tell my application "System Events" to if not (exists file imagepath) then
tell application "Capture One 11" to tell COPDocRef to tell thisCollection to set imageName to name of image ImageCounter
my loq_Results2(0, false, ("Image " & imageName & " not found at " & imagepath))
set countImageNotFound to countImageNotFound + 1
end if
end repeat
as does this
repeat with ImageCounter from 1 to everyImageCount
set imagepath to item ImageCounter of everyImagePathList
tell my application "System Events" to set theFlag to not (exists file imagepath)
if not theFlag then
tell application "Capture One 11" to tell COPDocRef to tell thisCollection to set imageName to name of image ImageCounter
loq_Results2(0, false, ("Image " & imageName & " not found at " & imagepath))
set countImageNotFound to countImageNotFound + 1
end if
end repeat
Can anyone point me to a good reference on the topic of using a tell statement and an if statement in the same line.