So in one of my scripts I am trying to set the clipboard to some information during a repeat loop. Everytime I run it I get a -619 error. It seems to set it correctly the first time, but the second time through the loop it gives me the error.
Here is some scripting that will duplicate the problem…the real script obviously does more
<------ SCRIPT ------>
set i to 1
repeat until i > 10
tell application “Finder”
activate
end tell
set the clipboard to i
set i to i + 1
end repeat
<------ END SCRIPT ------>
Any ideas what’s wrong? The only way I’ve been able to remove the error is by adding a dialog box… display dialog i giving up after 1 (don’t ask me why that removes the error)
What is displayed in the dialog? I just tested your script snippet in OS 9 and OS X and it didn’t produce an error. I wonder if, for some reason, your numbers are being converted to text when passed to/from the clipboard. If your dialog displays 11, this probably isn’t the issue.
I should add that I ran this from Script Debugger.
Opps…sorry…OS9.2.2. I tried it in OS X and it worked correctly also. I’m running it from Script Editor.
I don’t think it’s because the numbers are being converted to text. The error is being produced at the “set the clipboard to i” line…not the “set i to i+1” line.
That sucks that you can’t reproduce the error. I’ve tried it on two OS 9.2.2 Macs with the same results.
There are some versions of AppleScript that are outright buggy. The AppleScript Sourcebook is a great place to get information on various releases of AppleScript. It might be worth your time to check it out.
At the risk of confusing things more, ( I am running OS 8.6 at home), I was able to get this to work. The clipboard is kind of fussy and wants to ignore certain data types.
If the variable “i” is coerced to text for the clipboard, then set back to integer for adding to it - it works fine. But again, I am on an earlier version of everything here - Maybe I should finally upgrade huh?
I am also running this on Script DeBugger (v2)
This works for me:
set i to 1
repeat until i > 10
tell application "Finder"
activate
set i to i as string--coerce to text
set the clipboard to i
end tell
set i to i as integer--back to integer
set i to i + 1
end repeat