LOOPCOUNT        Define loop counter

Top  Previous  Next

Syntax:

LOOPCOUNT

[ count ]

Arguments:

[ count ]

Numeric count value

Options:

none

 

 

 

This script command sets the number of times a command sequence is repeated. This command is commonly used together with the LOOPIF command to create a "retry loop" for failure-prone operations but may also be used with the LOOPTO command to repeat a series of commands a specific number of times.

 

Note: Robo-FTP returns an error and clears any existing LOOPCOUNT value when the [ count ] argument is set to zero.

 

Consider the following where the SENDFILE command is repeated up to five times or until it is successful. After five failures a email is sent:

 

LOOPCOUNT 5

:upload

SENDFILE "data.csv" /delete

LOOPIF GOTO upload ELSE GOTO done

;; fall through after five failures

SET email_body = "The upload failed FIVE times!   "

SET email_body &= %crlf & "Is something unplugged?"

CREATEMAIL "Robo-FTP" "[email protected]" "Upload failed" email_body "" /nocrlf

SENDMAIL "smtp.mydomain.com" "" "[email protected]"

:done

EXIT

 

Consider the following example in which the variable file name is displayed three times (for no meaningful reason).

 

LOOPCOUNT 3

SET file name = "test file"

:many_tries

DISPLAY file name

LOOPTO many_tries

:done

 

 

Related command(s): LOOPIF, LOOPTO, GOTO, IFERROR