DEC        Decrement a variable by one

<< Click to Display Table of Contents >>

Navigation:  Robo-FTP User's Guide > Script Programming > Script Commands > All Script Commands >

DEC        Decrement a variable by one

Syntax:

DEC

[ variable ]

Arguments:

[ variable ]

A variable containing from one to six numeric characters.

Options:

None

 

 

 

The INC and DEC commands are used mainly for modifying looping variables and sequentially naming files. For other purposes, use the SETNUM command instead.

 

This script command is used to decrement a variable by one. It is intended to be used mainly for looping and sequentially naming files. If each character in the variable is not numeric (e.g., digits 0 - 9), then the command fails.

 

Numeric strings used in the DEC (and INC) command are assumed to be a fixed length of one to six characters and contain leading zeros. When the value of a variable goes negative, the value wraps (i.e., a two character string is less than 00 after subtracting one then the value is set to 99; 0 wraps to 9; 000 wraps to 999; etc.)

 

Caution

This command is primarily intended to provide a mechanism for sequentially naming files, not as a simple numeric function. So its behavior of wrapping from 00 to 99, for example, may not be appropriate when doing simple arithmetic. The DEC command may be used for both purposes but you need to remain aware of the command’s behavior.

 

If the variable is not previously assigned, the variable is created and set equal to 000.

 

Consider the example below where a variable is used to retrieve sequentially named files (using an decrementing file extension - i.e., file.999, file.998, etc.) from an FTP site. Note: numeric values should be assigned enclosed in quotation marks when strings with leading zeroes are desired.

 

SET basename = "file."

SETNUM counter = "000"

:loop

DEC counter

SET FileName = basename & counter

DISPLAY FileName

RCVFILE FileName

GOTO loop

 

In another use, consider the example below where a variable is used as a decrementing loop counter.

 

SETNUM counter = 10

;; loop 10 times

:loop

DASHBOARDMSG "The current value is " + counter

PAUSE /for=1

DEC counter

IFNUM!= counter 0 GOTO loop

 

 

Related command(s): INC, IFNUM, SETNUM, SET