- Jun
- 568
- 4
What are the relative merits of the following two forms of a conditional test?
if condition (
command1
command2
...
lastcommand
)
iff condition then
command1
command2
...
lastcommand
endiff
In most situations, both forms would produce identical results. Is there anything to favor one over the other?
When processing of the command separator is turned off by setdos /x-5, command grouping will not work, since (as I discovered by tripping over it) TCC converts the entered text into a single command line with the command separator between the individual commands.
That, I discovered, is also a problem with the FOR command when one wants to execute multiple commands. However, I have now verified that one can overcome the problem by making the command run by FOR be a subroutine call. The subroutine can have mulitple commands.
The first form also has a problem if the closing parenthesis character appears in one of the commands in an unbalanced form, e.g., "echo (a or )" works but "echo A)" terminates the group.
if condition (
command1
command2
...
lastcommand
)
iff condition then
command1
command2
...
lastcommand
endiff
In most situations, both forms would produce identical results. Is there anything to favor one over the other?
When processing of the command separator is turned off by setdos /x-5, command grouping will not work, since (as I discovered by tripping over it) TCC converts the entered text into a single command line with the command separator between the individual commands.
That, I discovered, is also a problem with the FOR command when one wants to execute multiple commands. However, I have now verified that one can overcome the problem by making the command run by FOR be a subroutine call. The subroutine can have mulitple commands.
The first form also has a problem if the closing parenthesis character appears in one of the commands in an unbalanced form, e.g., "echo (a or )" works but "echo A)" terminates the group.