ignoring errors?

is it possible to like, ignore this error. so it doesnt pop up.

AppleScript Error NSReceiver EcaluationScriptError: 4 (1)
cause like… the program that im using with this script works fine, it does what its suppose to but also pops up this error. so if there was a way to just make it so the program would ignore the error, that would be great heh.

Hi. Just put a “try” block around the code that’s giving you the error. A try block has this form:

try
	-- try to do something ie. your code goes here
on error
	-- if there's an error then do something else
	-- display dialog "There was an error!"
end try

But in your case you don’t want to do anything if you get an error so just use it like this:

try
	-- try to do something
end try

Here’s a tip in case you never knew this…

If you highlight some code in the script editor window and then right-click on the highlighed code a menu will pop up. In the bottom section of that menu are a bunch of applescript shorcuts for you to use. Basically whatever you choose will put the appropriate code around the stuff you have highlighted in the Script Editor. You can see a folder full of “error” handlers in that menu that you can choose from… there’s lots of code in there to help you like display dialogs for different situations. I always use the “comment tags” one when I want to quickly comment out some code so I can debug my script. Note that this one is special because if you highlight code thats already commented out then it will uncomment the code for you. It’s a handy menu.

At least you can experiment with the different choices and see the different ways to do things.

ah ok thanks for your help guys.

Huh? What version of AS or Script Editor are you using? If I control click selected text, I get some options, but not those you’re talking about.

What’s the secret?

Would very much like to have (at least) an easy way to comment/uncomment code.

Thanks.

Peter B.


Works for me, Peter, in both the Script Editor and in Script Debugger 4.

:lol: I had a feeling there were people who didn’t know about that. You get this with the standard install of any version of applescript.
You have to have a folder called “Script Editor Scripts” in /Library/Scripts. Maybe you moved it or changed it.

You have to have a folder called “Script Editor Scripts” in /Library/Scripts. Maybe you moved it or changed it.

Aha. Yes, I had moved all to my user Library/Scripts folder…

Thanks much.

Peter B.