LOOPIF        Test result code and conditionally branch using looping

Top  Previous  Next

Syntax:

LOOPIF

goto  [ label1 ]  else  goto  [ label2 ]

Arguments:

[ label1 ]

A valid label within the current script file which is branched to if the conditional test fails.

 

[ label2 ]

A valid label within the current script file which is branched to if the conditional test is successful.

Options:

none

 

 

 

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 dial command is repeated up to three times or until it is successful (whichever comes first).

 

LOOPCOUNT 3

:retry_dial

DIAL "1-555-1212"

LOOPIF goto retry_dial else goto connected

;; Dialing failed

EXIT

:connected

 

Related Command(s): LOOPTO, GOTO, LOOPCOUNT