Script command to ignore script errors?

Discuss and share scripts and script files...
Post Reply
ghost zero
Posts: 842
Joined: 26 Apr 2010 17:48

Script command to ignore script errors?

Post by ghost zero »

Is there a script command to ignore script errors? Example, I want this script to go to T: drive and not popup an error message if the drive can't be found. Is it possible?

goto "T:\"

nas8e9
Posts: 2232
Joined: 21 Jun 2008 14:50

Re: Script command to ignore script errors?

Post by nas8e9 »

I don't think XYplorer's scripting has explicit error handling yet, but you could in this case precede the goto with exists like so:

Code: Select all

if exists("T:\") == 2 {
   goto "T:\";
}
else {
   status "Drive T: not available.";
}
Edited: missing closing semicolon after status added.

PeterH
Posts: 2827
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Script command to ignore script errors?

Post by PeterH »

If I understand the initial question right the answer must be "no"!
Because it's not a "script error"!

Script errors are illegal commands, wrong number of operands, non-paired braces, maybe division by 0, ...

Here a formally correct script command leads to an exceptional situation during execution of that command - a path cannot be resolved. That must be handled by the command - not by the script! So the possible solution would be an operand for the command telling it to quietly ignore errors. An analog example is the "confirm-"switch of the delete command.

So this request shouldn't go to expansion of scripting, but to expansion of explicit commands, like "goto" in this case.

Post Reply