While/End_While

Reference:        Script Editor Program
                        Alphabetical Command List 

                        Topical Command List

Open Syntax Window

MoveNextBrowseTypeExpressionVariable

The While command implements loops in Beyond FTP scripts.  There are four forms of this command.  The first simply evaluates a conditional expression and stops when this expression is false.  The only parameter is the conditional expression contained with parentheses.

The second form includes a variable name and the keyword Next followed by a fully qualified file name or mask.  It performs a file expansion and loops for each name in the expansion.  The file name (without the path) is placed in the named variable on each pass.  This variable is a string type, and is valid ONLY within the while loop.  This allows the results of a single expansion to be used in multiple commands.  The advantage of this approach is that only those files included in the expansion will be processed.  New files arriving after the expansion will be processed the next time the script is run.  The disadvantage is that each file is processed individually.  There is no parallel processing for multiple files.  This can increase the total run time for the script.

The third form includes a variable and the keyword Folder followed by a fully qualified path name or mask.  It performs a folder expansion and loops for each folder name returned in the expansion.  The folder name (without the preceding path) is placed in the named variable on each pass.  This variable is a string type, and is valid ONLY within the while loop.  This provides a way to process folders that are unknown at the time the script is written. 

The fourth form includes a variable and the keyword List followed by the name of the file to read.  It reads sequentially through this text file and loops for each line in the file.  Lines are terminated by carriage returns and line feeds.  The entire contents of a line are placed in the named variable on each pass.  There is a single special case.  Lines that begin :Server: are assumed to be from a server list, and only the portion of the line following the :Server: command are returned.  This allows you to easily parse a server list.

While commands may be nested.  The Break command may be used to exit a while loop at any time.  Break exits only the loop within which it occurs.