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:\"
Script command to ignore script errors?
-
nas8e9
- Posts: 2232
- Joined: 21 Jun 2008 14:50
Re: Script command to ignore script errors?
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:
Edited: missing closing semicolon after status added.
Code: Select all
if exists("T:\") == 2 {
goto "T:\";
}
else {
status "Drive T: not available.";
}-
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?
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.
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.
XYplorer Beta Club