Give it a TRY
Last Monday, I talked about Simple filters - easy to use and easy to script. After showing how to
add the filter to the script, I mentioned that it was important to check that the script user has
the Simple filter available on their computer. Today, I'll show you the simplest way I know to do that.
Python has a very handy command called
try. If you "
try" a command and it doesn't work, it won't
cause errors in your script. Even better, you can specify an action or actions to take, which
will replace the command which didn't work. Here's what it looks like:

In the example, I've told Python to substitute Colorize and Blinds, if the HorizontalGrain effect
doesn't work. It will also print a message to the Script Output Palette.
(Note: I'm not showing the substitute effect settings in this example, but you would want your
script to include these.)
Notice how the HorizontalGrain effect is indented under
try: and the
substitute effects are indented under
except:. The indentation tells Python which commands are
included in the
try and
except processes.
When the indentation stops (line 17), Python will continue executing the commands
regardless of whether the HorizontalGrain or substitute effects were used.
If you didn't want to use a substitute, you might include a Message dialog box in the
exception section. You
could show where to download the effect, then cancel the script. If you haven't ever used a Message
box or cancelled a script, keep checking back. I'll be showing how to do that in future blogs.
I'll be back tomorrow with Tuesday Tips.