handling_errors_2.ftp
This script retries to connect to the FTP server for three times, downloads some files and disconnects.
# Set the connection attempts counter to 0 $attempts=0 # This is a label. It marks a point in the script. # We will use it to return to this point if a # connection attempt fails. :connect # Display a message PRINT("_____Connecting_____") # Connect to server. The return value of OPENHOST # is stored in $result $result=OPENHOST("myserver.com","me","13579") # Increment the connection attempts counter $attempts=$attempts+1 # Check if $result is different from "OK" IF($result!="OK") # If this is the third attempt stop execution IF($attempts==3) STOP ELSE PRINT("Cannot connect! Trying again.") # Jump to the label :connect to retry # the connection GOTO :connect END IF END IF # Once this point is reached ScriptFTP # is connected to the server. # Transfer the files. GETFILE("*.*") # Close connection CLOSEHOST