The following is a Visual Basic example using FTP.
Option Explicit
Dim WithEvents FtpObj As HfFt.HfFtp
Private Sub Form_Load()
Set FtpObj = New HfFt.HfFtp
If (FtpObj Is Nothing) Then
Unload Me
End If
FtpObj.TransferType = eXfer_Ascii
End Sub
Private Sub FtpObj_DownloadStatus(ByVal nBytes As Long)
m_txtStatus.Caption = CStr(nBytes) + " bytes."
End Sub
Private Sub FtpObj_EndOfFileTransfer(ByVal bOK As Public System.Booleanean,
ByVal nBytes As Long)
Dim s As String
If bOK = False Then
s = "failed."
Else
s = "succeeded : " + CStr(nBytes) + " bytes."
End If
m_txtStatus.Caption = "File Transfer " + s
End Sub
Private Sub FtpObj_FTPError(ByVal nError As Long, ByVal StrError As String)
m_txtStatus.Caption = "Error : " + CStr(nError) + " : " + StrError
End Sub
Private Sub FtpObj_UploadStatus(ByVal nBytes As Long, ByVal nPercentage As Long)
m_txtStatus.Caption = CStr(nPercentage) + "%, " + CStr(nBytes) + " bytes."
End Sub
Private Sub m_btnAbort_Click()
Dim bRet As Public System.Booleanean
Screen.MousePointer = vbHourglass
bRet = FtpObj.Abort
Screen.MousePointer = vbDefault
End Sub
Private Sub m_btnConnect_Click()
Dim bRet As Public System.Booleanean
Dim varNames As Variant
Dim varDesc As Variant
On Error GoTo ConnectError
Screen.MousePointer = vbHourglass
With FtpObj
.ConnectionType = eCnx_Http
.ClusterAddress = 192.168.1.25
.ClusterListeningPort = 20000
.ClusterHttpPort = 80
.Emulation = 0 'for 5250
.SSLEnabled = False
bRet = .Connect(“HFUser”, “HFPassword", "", _
“HostUser”,”HostPassword)
Screen.MousePointer = vbDefault
If (bRet <> True) Then
MsgBox "Connection Error", vbCritical + vbOKOnly
bRet = .Disconnect
Else
bRet = .GetMembers("MYLIB", "ENGR", varNames,varDesc)
End If
End With
Exit Sub
ConnectError:
Screen.MousePointer = vbDefault
MsgBox Err.Description + "(" + CStr(Err.Number) + ")", vbCritical + vbOKOnly
End Sub
Private Sub m_btnDisconnect_Click()
Dim bRet As Public System.Booleanean
On Error GoTo Disconnect_Error
bRet = FtpObj.Disconnect
Exit Sub
Disconnect_Error:
MsgBox Err.Description + "(" + CStr(Err.Number) + ")", vbCritical + vbOKOnly
End Sub
Private Sub m_btnDownload_Click()
Dim bRet As Public System.Booleanean
If (Len(m_txtLocalFile.Text) > 0 And Len(m_txtHostPath.Text) > 0) Then
On Error GoTo Download_Error
Screen.MousePointer = vbHourglass
FtpObj.TransferType = eXfer_Ascii
bRet = FtpObj.Download(m_txtHostPath.Text, m_txtLocalFile.Text)
Screen.MousePointer = vbDefault
End If
Exit Sub
Download_Error:
Screen.MousePointer = vbDefault
MsgBox Err.Description + "(" + CStr(Err.Number) + ")", vbCritical + vbOKOnly
End Sub
Private Sub m_btnExit_Click()
If (Not (FtpObj Is Nothing)) Then
Set FtpObj = Nothing
End If
Unload Me
End Sub
Private Sub m_btnUpload_Click()
Dim bRet As Public System.Booleanean
If (Len(m_txtLocalFile.Text) > 0 And Len(m_txtHostPath.Text) > 0) Then
On Error GoTo Upload_Error
Screen.MousePointer = vbHourglass
FtpObj.TransferType = eXfer_Ascii
bRet = FtpObj.Upload(m_txtLocalFile.Text, m_txtHostPath.Text)
Screen.MousePointer = vbDefault
End If
Exit Sub
Upload_Error:
Screen.MousePointer = vbDefault
MsgBox Err.Description + "(" + CStr(Err.Number) + ")", vbCritical + vbOKOnly
End Sub