Sometimes it is useful to perform different actions for each item in a set of files. For example, if you do the following:

# Connect to server
OPENHOST("ftp.myhost.com","joe","123456")
 
# Download all files
GETFILE(*.*)
 
# Delete the downloaded files
DELETEFILE(*.*)
 
# Close the connection
CLOSEHOST
 
# Connect to server
OPENHOST("ftp.myhost.com","joe","123456")
 
# Change the current local directory. All files
# will be downloaded here.
LOCALCHDIR("C:\users\carlos\desktop\localftp")
 
# Get the remote file listing, store it in $list
GETLIST($list,REMOTE_FILES)
 
# For each file in $list...
FOREACH $item IN $list
    # Download the file
    $result=GETFILE($item)
 
    # If the file has been downloaded successfully
    # delete the remote copy. Else stop the script.
    IF($result=="OK")
        DELETEFILE($item)
    ELSE
        STOP
    END IF
END FOREACH
 
# Close the connection
CLOSEHOST

GETLIST commands are usually followed by FOREACH loops. See GETLIST for further reference about parameters and options.