ReceiveFTPFile() has an Asynchronous feature and "I think" that AbortFTP() needs to be used to terminate the session on an ftp failure.
Can you check my code below to make sure my logic makes sense for ReceiveFTPFile() and AbortFTP() please? The help text does not give us an example of how to use ReceiveFTPFile() in Asynchronous mode.
Code: Select all
While NextFTPDirectoryEntry(0)
If FTPDirectoryEntryType(0) = #PB_FTP_Directory
Continue;
EndIf
;Added the Select Result code block below: 01/12/18 RJH
Repeat
Result = ReceiveFTPFile(0, FTPDirectoryEntryName(0), localchdir$ + "\" + FTPDirectoryEntryName(0), #True) ; True switch added...
Select Result
Case #PB_FTP_Started
Case #PB_FTP_Error
AbortFTPFile(0) ; AbortFTPFile Transfer on failure
LogFile("#PB_FTP_Error with connection to remote file: " + FTPDirectoryEntryName(0))
Break
Case #PB_FTP_Finished
LogFile("Copied remote file: " + FTPDirectoryEntryName(0))
Files = Files + 1
Result = DeleteFTPFile(0, FTPDirectoryEntryName(0))
If Result = 0
LogFile("Error deleting remote file: " + FTPDirectoryEntryName(0))
Else
LogFile("Deleted remote file: " + FTPDirectoryEntryName(0))
EndIf
Break
Default
;All is well!
EndSelect
Delay(1)
ForEver
Delay(100)
Wend