Integer iRetVal
Integer hoSFTP

Get Create (RefClass(cComChilkatSFtp)) to hoSFTP
Get ComUnlockComponent of hoSFTP "license" to iRetVal

Set ComConnectTimeoutMs of hoSFTP to 5000
Set ComIdleTimeoutMs of hoSFTP to 10000

String sHostName
Move "hostname" to sHostName
Get ComConnect of hoSFTP sHostName 22 to iRetVal
If (iRetVal<>1) Begin
    Send Info_Box (ComLastErrorText(hoSFTP))
    Send Destroy to hoSFTP
    Function_Return (False)                
End
                       
Get ComAuthenticatePw of hoSFTP "user" "password" to iRetVal            
If (iRetVal<>1) Begin
    Send Info_Box (ComLastErrorText(hoSFTP))
    Send Destroy to hoSFTP
    Function_Return (False)
End
    
Get ComInitializeSftp of hoSFTP to iRetVal            
If (iRetVal<>1) Begin
    Send Info_Box (ComLastErrorText(hoSFTP))
    Send Destroy to hoSFTP
    Function_Return (False)
End

Integer STatPnl
Move (Status_Panel(Self)) to StatPnl
//Set Allow_Cancel_State of StatPnl to false
Send Initialize_StatusPanel of StatPnl "Uploading File" "Please Wait" ""
Send Start_StatusPanel of StatPnl
        
Get ComUploadFileByName of hoSFTP "upload.txt" "c:\dx\upload.txt" to iRetVal
If (iRetVal<>1) Begin
    Send Stop_StatusPanel of StatPnl
    Send Info_Box (ComLastErrorText(hoSFTP))
    Send Destroy to hoSFTP
    Function_Return (False)
End
        
Send Stop_StatusPanel of StatPnl
        
Send ComDisconnect to hoSFTP
            
Send Destroy to hoSFTP