Connect - cFTPTransfer
Establishes an FTP connection with RemoteHost
Type: Function
Return Data Type: Integer
Syntax
Function Connect Returns Integer
Call Example
Get Connect to IntegerVariable
Description
The Connect function establishes an FTP connection with RemoteHost.
Note that despite the return data type being integer, this function returns True for a successul connection and False when the connection fails. Use a Boolean variable to hold its return value.
In case of failure, LastErrorCode will be set to a Windows Error Code.
Sample
Procedure DoDownloadFile String sDirectory String sFileSource String sFileDestination
Boolean bOk
Get Connect to bOk
if bOk Begin
If (sDirectory <>"") ;
Get ChangeDirectory sDirectory to bOk
If (bOk) Begin
Send Initialize_StatusPanel to ghoSentinel 'Download File From FTP Server' ('Copying: ' +sDirectory +"/" +sFileSource) ("To: " +sFileDestination)
Send Start_StatusPanel to ghoSentinel
Get DownloadFile sFileSource sFileDestination to bOk
Send Stop_StatusPanel to ghoSentinel
If (bOk) ;
Send Info_Box ("File " +sDirectory +"/" +sFileSource +" copied successfully") "FTP File Downloaded"
Else ;
Send Stop_Box "Failed to download file"
End
Else ;
Send Stop_Box ("Unable To Change To The '" +sDirectory +"' Directory") "FTP Failure"
Get Disconnect to bOk
End
Else ;
Send Stop_Box ("Connect to '" +psRemoteHost(self) +"' failed") "FTP Failure"
End_Procedure
Return Value
Returns True if successful, False otherwise.