Skip to main content
Known Participant
April 24, 2012
Answered

Stop action if an error appears - CS5/Javascript

  • April 24, 2012
  • 1 reply
  • 952 views

Hey all!

Here's what I'm trying to do: I have an action that does lots of things then call one script then it closes the file.

When there's something wrong with the name of the file that the script is searching it pop's up an alert box.

Here's the thing, after the alert box I want the script to STOP running and then DONT close the file that is the next step of the action that calls the script.

(It occurred me that if necessary I can get that close action into the script to make it simple, then all I got to do is to stop the script, is that right?)

And if its possible that after this error occours PS brings me that dialog box asking if I want to keep it on working with the batch or stop, but this is optional.

Can anyone help me? :]

Ty for all, and plz forgive any grammatical errors, I'm brazilian.

This topic has been closed for replies.
Correct answer c.pfaffenbichler

What is supposed to be wrong exactly to trigger that?

You could set up either an if-clause to check for some condition or maybe a try-clause and determine what to do if that fails with a catch.

1 reply

c.pfaffenbichler
Community Expert
c.pfaffenbichlerCommunity ExpertCorrect answer
Community Expert
April 24, 2012

What is supposed to be wrong exactly to trigger that?

You could set up either an if-clause to check for some condition or maybe a try-clause and determine what to do if that fails with a catch.

Known Participant
April 24, 2012

Yes, I am doing a IF check. Its like this:

if (semtam >0 )

          {

              alert("O nome do arquivo não possui distinção de tamanho. Por favor, corrija-o. Este é o arquivo " + refvar + ".", "Erro na nomenclatura")

          }

"semtam" is a var that i created to check if the filename contains a certain word.

After the alert pop's up that's when the script has to break.

If the var is null then it just keep rolling and does like 5 different kinds of save and that's working just fine, I just don't know how to stop and i didn't wanted to get the whole script inside the "if (semtam <1 )" or something like that. I can do that, but i just think that's gotta be another way, right?

Ty for the attention.

Known Participant
April 26, 2012

So guys, any tips for stoping it or should I just get it all in a big "IF"?