TrueGUI Developers Notebook

 

FtpTransfer

Page history last edited by Mike Talbutt 3 yrs ago

---

FTP Transfer

 

Some terminal emulators have included a number of customized client access methods. A common one is file transfers via FTP. Here is one of many possible ways of doing this with TrueGUI:

 

On the "Run AMOS Samples", "Form 1 With 3 Pages", there is an "FTP Transfer" tab page, thus:

 

 

Each of these fields has been preset to a file on our AM-8000.AlphaMicro.com. When the Get File button is pressed, the file is copied to the current directory, typically TrueGUI.

 

When the Get File button is pressed, the server collects the data from the form (or it could use data from some other source) thus:

 

Event sent: Click,MyForm.FtpGetFile
***Queued 25 bytes to be sent to the server***
***Transmitted 25 bytes to the server***
***Received 136 bytes from server***
! Got TypeCode 3="Click,MyForm.FtpGetFile", length: 24
!   Event: "Click"   Control: "MyForm.FtpGetFile"
! Dispatching in TgGetInput based on Event
Command: <== { FtpRemoteIP.Text? }
Data: 66.166.1.38
***Queued 13 bytes to be sent to the server***
Command: <== { NextEvent? }
***Transmitted 13 bytes to the server***
***Received 188 bytes from server***
! Got TypeCode 2="66.166.1.38", length: 12
! Len:11
Command: <== { host1 = `66.166.1.38` }
Command: <== { FtpUserID.Text? }
Data: GuiSam
***Queued 8 bytes to be sent to the server***
***Transmitted 8 bytes to the server***
Command: <== { NextEvent? }
***Received 116 bytes from server***
! Got TypeCode 2="GuiSam", length: 7
Command: <== { user1 = `GuiSam` }
Command: <== { FtpPassword.Text? }
Data: GuiSam
***Queued 8 bytes to be sent to the server***
Command: <== { NextEvent? }
***Transmitted 8 bytes to the server***
***Received 97 bytes from server***
! Got TypeCode 2="GuiSam", length: 7
Command: <== { pass1 = `GuiSam` }
Command: <== { FtpFile.Text? }
Data: GuiTst.txt
***Queued 12 bytes to be sent to the server***
***Transmitted 12 bytes to the server***
***Received 93 bytes from server***
Command: <== { NextEvent? }
! Got TypeCode 2="GuiTst.txt", length: 11
Command: <== { file1 = `GuiTst.txt` }
Command: <== { client1? }
Data: AlphaMicrosystems.Net.Ftp.FTPClient
***Queued 37 bytes to be sent to the server***
Command: <== { NextEvent? }
***Transmitted 37 bytes to the server***
***Received 97 bytes from server***
! Got TypeCode 2="AlphaMicrosystems.Net.Ftp.FTPClient", length: 36

 

Here is a trace of the actual transfer:

 

Command: <== { client1 = new FTPClient(host1) }
Command: <== { client1.Login(user1, pass1) }
Command: <== { client1.TransferType = FTPTransferType.BINARY }
Command: <== { client1.ConnectMode = FTPConnectMode.ACTIVE }
Command: <== { client1.Get(file1,file1) }
Command: <== { client1.Login(user1, pass1) }
Command: <== { client1.Quit() }
Command: <== { NextEvent? }

 

There is the code section in GUITST.BAS that The variables were previous

 

! =============================================================================
! ===========  FTP Example  ===================================================
FTP'Get'File:
task$ = "FTP RemoteIP"
print "{ FtpRemoteIP.Text? }"
call TgGetInput
? "! Len:"+len(TgText$)
!!              if len(TgText$ = 0) GOTO FTP'Parameter'Error
print "{ host1 = "sd$+TgText$+sd$+" }"
task$ = "FTP User ID"
print "{ FtpUserID.Text? }"
call TgGetInput
!!              if len(TgText$ = 0) GOTO FTP'Parameter'Error
print "{ user1 = "sd$+TgText$+sd$+" }"
task$ = "FTP Password"
print "{ FtpPassword.Text? }"
call TgGetInput
!!              if len(TgText$ = 0) GOTO FTP'Parameter'Error
print "{ pass1 = "sd$+TgText$+sd$+" }"
task$ = "FTP File"
print "{ FtpFile.Text? }"
call TgGetInput
!!              if len(TgText$ = 0) GOTO FTP'Parameter'Error
print "{ file1 = "sd$+TgText$+sd$+" }"
task$ = "Clean from last time"
print "{ client1? }"
call TgGetInput
!!              if TgText$ # "null" then print "{ FTPClient client1 = null }"
print "{ client1 = new FTPClient(host1) }"
print "{ client1.Login(user1, pass1) }"
print "{ client1.TransferType = FTPTransferType.BINARY }"
print "{ client1.ConnectMode = FTPConnectMode.ACTIVE }"
print "{ client1.Get(file1,file1) }"
print "{ client1.Login(user1, pass1) }"
print "{ client1.Quit() }"
GOTO TgGetInput      ! continue waiting
FTP'Parameter'Error:
print "{ MessageBox.Show("+sd$+task$+" is required - please complete all fields!"+sd$+", "+sd$+"Guitst Message"+sd$+") }"
GOTO TgGetInput      ! continue waiting
! =============================================================================

 

As you may have noticed, some of the data validation has been commented out (!!...) - it currently does not work - but the file transfer does work. Right now, there is no error checking.

 

This example is using the FTP software we added to the TrueGuiInterface.DLL. It is documented "FTP Developers Manual" included with the TrueGUI release.

Comments (0)

You don't have permission to comment on this page.