UDM - if Statement - Nested Conditionals
UDM - if Statement - Nested Conditionals
For complex and powerful operations, if statements can be nested inside of each other.
Example
For example:
copy src=$(filename) if $(_lastrc) EQ 0 delete src=$(filename) if $(_lastrc) NE 0 print msg="The source file could not be deleted." end else print msg="The copy operation failed." end print msg="The operation completed with a return code of $(_rc)."
A Stonebranch Tip
Indenting lines underneath conditionals by putting spaces at the front of them, although not necessary, provides a visual cue that those lines are to be executed due to the evaluation of a conditional.
Using this technique with nested conditionals provides an easy way to tell at which 'level' each of the commands belong.
In addition, leaving a blank line before and after a conditional (not required by UDM) provides a way to visually indicate a block of related script commands.
This improves the readability and maintainability of scripts in the future.