LOOPIF Test result code and conditionally branch using looping |
Top Previous Next |
This script command checks the result of the previous command and performs a conditional branch to [ label1 ] if the command failed (the result code is non-zero). The branch to [ label2 ] is taken if no error was encountered.
If LOOPCOUNT is non-zero, the error path is taken LOOPCOUNT times. If the error condition persists after taking the error path the specified number of times, then the command immediately after the LOOPIF is executed. If LOOPCOUNT is zero, the error path is taken indefinitely.
Consider the following where the DIALNET command is repeated up to three times or until it is successful (whichever comes first).
LOOPCOUNT 3 :retry_dial DIALNET "My Connection" LOOPIF goto retry_dial else goto connected ;; Dialing failed :connected
Related Command(s): LOOPTO, GOTO, LOOPCOUNT
|