FTP Client Engine
Library for Visual dBase
Programmer's Manual
(FCE4DB)
Version 2.6
February 21, 2007
This software is provided as-is.
There are no warranties, expressed or implied.
Copyright (C) 2007
All rights reserved
MarshallSoft Computing, Inc.
Post Office Box 4543
Huntsville AL 35815
Voice : 1-256-881-4630
FAX : 1-256-880-0925
email : info@marshallsoft.com
web : www.marshallsoft.com
MARSHALLSOFT is a registered trademark of MarshallSoft Computing.
1 Introduction
1.1 Features2 Compiler Issues
1.2 Documentation Set
1.3 Example Program
1.4 Installation
1.5 Uninstalling
1.6 Pricing
1.7 Updates
2.1 Keycode3 Example Programs
2.2 INCLUDE Files
2.3 dBASE 5.6 and 5.7
2.4 dBASE 7.0 and above
2.5 Compiling dBASE Programs
2.6 Compiling dBASE Projects
2.7 Passing Strings to FCE
2.8 Null Terminated Strings
2.9 FTP Parameters
2.10 Compiling to an Executable
3.1 FCEVER4 Revision History
3.2 GET
3.3 LIST
3.4 FTP
3.5 FTP2
3.6 WINFTP
3.7 FIELDS
3.8 PROXY
3.9 MGET
3.10 MPUT
3.11 SPEED
The FTP Client Engine for Visual dBASE (FCE4DB) is a component library of functions providing direct control of the FTP protocol from a Visual dBASE application. The FCE component library can be used for both anonymous and private FTP sessions.
A simple interface allows connecting to a FTP server, navigating its directory structure, listing files, sending files, deleting files, and receiving files using the FTP protocol.
The FTP Client Engine for Visual dBASE supports and has been tested with Visual dBase 5.7 and 7.0. FCE4DB includes several example programs, including standard .PRG programs and .WFM forms based programs that demonstrate FTP processing to help software developers easily build software applications using FCE4DB.
Both Win16 and Win32 DLLs (Dynamic Link Libraries) are provided. FCE4DB can be used with Windows 95/98, Me, XP, 2000 and NT. The FTP Client Engine SDK DLLs (FCE16.DLL and FCE32.DLL) can also be used from any language (C/C++, WORD, ACCESS, EXCEL, PowerBASIC Console Compiler, Delphi, Visual FoxPro, Visual Basic, COBOL, Fortran, etc.) capable of calling the Windows API.
When comparing the FTP Client Engine library (FCE) against our competition, note that:
Check http://www.marshallsoft.com for the latest version of our FTP software.
Some of the many features of the FTP Client Engine component library are as follows:
The complete set of documentation consists of three manuals in three formats. This is the first manual (FCE4DB) in the set.
Each manual comes in three formats:
The FCE_4DB Programmer's Manual is the language specific (Visual dBase) manual dealing with compiler and programming issues such as installation and example programs. Read this manual first.
The FCE User's Manual (FCE_USR) discusses FTP in general as well as language independent programming issues such as application notes and includes purchasing and license information. Read this manual second.
The FCE Reference Manual (FCE_REF) contains details on each individual FCE function.
Use Microsoft Word or Microsoft WordPad to print the document files. All manuals can also be viewed online at http://www.marshallsoft.com/fce4db.htm
The following example demonstrates the use of some of the FTP Client Engine functions:
#INCLUDE C:\TEMP\FCE32.CC
#INCLUDE C:\TEMP\KEYCODE.CC
FTPserver = "ftp.marshallsoft.com" + Chr(0)
FTPuser = "anonymous" + Chr(0)
FTPpass = "msc@traveller.com" + Chr(0)
#define TEMP_SIZE 128
#define DATA_SIZE 5000
Code = fceAttach(1, FCE_KEY_CODE
if Code < 0
? "Cannot attach FCE ", Code
return
endif
? "Connecting to ", FTPserver
Code = fceConnect(0, FTPserver, FTPuser, FTPpass)
if Code < 0
TempBuffer = SPACE(TEMP_SIZE)
Code = fceErrorText(0,Code,TempBuffer,TEMP_SIZE)
? Left(TempBuffer,Code)
Code = fceRelease()
return
endif
? "Connected. Now getting file list."
DataBuffer = SPACE(DATA_SIZE)
Code = fceGetList(0, FCE_FULL_LIST, DataBuffer, DATA_SIZE)
if Code <= 0
TempBuffer = SPACE(TEMP_SIZE)
Code = fceErrorText(0,Code,TempBuffer,TEMP_SIZE)
? Left(TempBuffer,Code)
else
? Left(DataBuffer,Code)
endif
Code = fceClose(0)
Code = fceRelease()
? "Logged off."
return
In the example program above, fceConnect is called to connect to the FTP server as user "anonymous" and password "msc@traveller.com".
Next, a full file listing is requested. Lastly, the connection to the FTP server is closed and FCE is released.
Refer to the FCE Reference Manual (FCE_REF) for individual function details. Access online at http://www.marshallsoft.com/fce_ref.htm
Note that the Windows registry is not modified.
Uninstalling FCE4DB is very easy. FCE does not modify the registry.
First, run UNINSTAL.BAT, which will delete FCE16.DLL and FCE32.DLL from your Windows directory, typically C:\WINDOWS for Windows 95/98/Me/XP or C:\WINNT for Windows NT/2000.
Second, delete the FCE project directory created when FCE4DB was installed.
A developer's license for FCE4DB can be registered for $115 ($295 with ANSI C source code to the DLLs). Purchasing details can be found in Section 1.3, "How to Purchase", of the FCE User's Manual (FCE_USR). (http://www.marshallsoft.com/fce_usr.htm#Section_1.3)
When you register FCE4DB you will receive a set of registered DLLs plus a license file (FCExxxx.LIC) that can be used to update your registered DLL's for a period of one year from purchase. Updates can be downloaded from
http://www.marshallsoft.com/oem.htm
After one year, your license must be updated if you want to be able to download updates. Your license can be updated for $30 if ordered within one year of the original purchase (or previous update). After one year, licenses can be updated for $55.
Also see file UPDATES.TXT.
FCE4DB can be compiled with 16-bit Visual dBase (dBase 5.6 and 5.7) or with 32-bit Visual dBase (dBase 7.0 and above).
FCE16.DLL and FCE32.DLL have a keycode encoded within them. Your keycode is a 9 or 10 digit decimal number (unless it is 0), and will be found in the file KEYCODE.CC. The keycode for the evaluation version is 0. You will receive a new key code when registering.
If you get an error message (value -74) when calling fceAttach, it means that the keycode in your application does not match the keycode in the DLL. After registering, it is best to remove the evaluation version of the FCE DLL's from the Windows search path.
All example programs include two files: KEYCODE.CC and FCE32.CC (or FCE16.CC). The file FCE32.CC (or FCE16.DLL) contains all the necessary constants and function declarations for FCE4DB, while the file KEYCODE.CC contains your key code, as discussed in section 2.7 below.
There are three recommended ways to handle these INCLUDE files in dBASE programs.
Visual dBASE 5.6 and 5.7 create 16-bit applications, and use the 16-bit FCE DLL, namely FCE16.DLL. Copy the 16-bit CC file FCE16.CC to your compiler's INCLUDE directory.
Visual dBASE 7.0 and above create 32-bit applications, and use the 32-bit DLL, FCE32.DLL. Copy the 32-bit CC file FCE32.CC to your compiler's INCLUDE directory.
Visual dBase programs end with the extension ".PRG". Before compiling any of the example programs, edit each file with your Internet TCP/IP parameters. Programs can be edited within any text editor, and compiled from the VDB (Visual dBase) command window with the COMPILE command (e.g.: COMPILE LIST.PRG) or executed from the VDB command window with the DO command (e.g.: DO LIST.PRG).
To open a program within the Visual dBase source editor, choose "File", then "Open". When the "Open File" dialog box appears, choose "Programs" for "Files of Type", then choose the program (*.PRG) to open. Lastly, choose "Open in Source Editor" for "Action" and push the "Open" button.
After editing the source program with your internet (or TCP/IP) parameters, you are ready to compile. From the dBase menu bar, choose "Build", then "Compile". To run choose, "Run". The VDB command window must be displayed in order to see the output.
Visual dBase projects consist of several types of files such as forms, reports, data modules, etc. The project file itself ends with the extension of ".PRJ".
There is one example Visual dBase project WINFTP. Open WINFTP by choosing "File", then "Open Project" from the dBase menu bar. To compile WINFTP, choose "Build" from the menu bar, then "Rebuild All". This will create WINFTP.EXE, which can be executed by choosing "Execute winftp.exe" from the "Build" menu bar pulldown, or from the Windows command line prompt.
Strings passed to FCE functions must be terminated with Chr(0) since this is the way the Windows API (written in ANSI C) handles strings.
For example:
Server = "ftp.marshallsoft.com" + Chr(0)
All strings returned from FCE functions are null terminated. That is, the end of the string is delimited by a Chr(0) character. These strings may be converted for dBase in one of two ways: (1) if the length of the string is known, use the dBase LEFT function: For example,
* get server IP address
TempBuffer = SPACE(TEMP_SIZE)
Code = fceGetString(0, FCE_GET_SERVER_IP, TempBuffer, TEMP_SIZE)
if Code > 0
? "Server IP ", LEFT(TempBuffer, Code)
endif
If the length of the null terminated string is not known, use the dBase AT function to find the position of Chr(0). For example,
Offset = fceMatchFile(ListBuffer,Offset,NameBuffer,128,FTPpattern,1)
P = AT(Chr(0), NameBuffer)
? "Downloading file " + Left(NameBuffer, P-1)
There are two types of FTP connections: private and anonymous. However, some FTP servers do not accept anonymous connections.
Three parameters are necessary in order to connect to an FTP server, as follows:
For private connections, the users account name and password must be specified.
For anonymous connections, the user name is "anonymous" and the password is the user's email address.
These FTP parameters are hard coded in most of the examples. However, these parameters could be read from the keyboard, from a file, from a dialog box at runtime, etc., as well as being hard coded.
Refer to the FCE User's Manual (FCE_USR) for more information regarding FTP protocol parameters.
dBASE programs end in ".PRG". They can be compiled to an executable using the dBASE BUILD command.
For example, to create FCEVER.EXE from FCEVER.PRG in the C:\FCE4DB\APPS directory, type the following in the dBASE command window:
BUILD PROJECT C:\FCE4DB\APPS\FCEVER FROM C:\FCE4DB\APPS\FCEVER
BUILD EXE C:\FCE4DB\APPS\FCEVER FROM C:\FCE4DB\APPS\FCEVER
Several example programs are included in FCE4DB. Refer to Section 2 above for help in compiling the example programs.
All example programs end with ".PRG", except for the FORM example (WINFTP), which ends with ".WFM".
The FCEVER ("FCE Version") program (FCEVER.PRG) displays the DLL version, build number, and registration string. This is the first program to try. Its purpose is to display the current version of the FCE DLL as well as to verify that FCE32.DLL is being found and loaded by Windows. It does not require a TCP/IP (Internet) connection. Run FCEVER from the VDB command window with "DO".
GET is an FTP client that connects to our FTP server anonymously and downloads the file "fce-new.txt". After compiling, start GET from the command line.
The LIST program (LIST.PRG) connects to the MarshallSoft FTP site at "ftp.marshallsoft.com" as user "anonymous" with password "msc@traveller.com". Change the password to your email address before compiling. Run LIST.PRG from the command window.
After connecting, LIST gets the list of all files on the server at the base FTP directory level, then logs off.
The FTP program (FTP.PRG) is a generic FTP program that can perform the most basic FTP functions such as listing and downloading files. Note that there are many FCE functions not implemented in the FTP.PRG example. Run FTP.PRG from the VDB command window.
The FTP2 program (FTP2.PRG) is identical to FTP except that it uses fceDriver when downloading and uploading files. Refer to Section 4, "Theory Of Operation", in the FCE User's Manual (FCE_USR) (http://www.marshallsoft.com/fce_usr.htm#Section_4
Run FTP2.PRG from the VDB command window.
The WINFTP program (WINFTP.PRG) is similar to the FTP program, except that it uses the Visual dBase form. To compile WINFTP.FRM from dBase 5.6/5.7, choose "Open" from under "File" on the Visual dBase 5.7 menu bar. To compile WINFTP.FRM from dBase 7.0 and above, choose "Open Project" from under "File" on the Visual dBase 7menu bar.
Note that code at the beginning of WINFTP.WFM
#INCLUDE C:\TEMP\FCE32.CC
#INCLUDE C:\TEMP\KEYCODE.CC
#define TEMP_SIZE 128
#define DATA_SIZE 35000
must be re-inserted manually after modifying the file with the dBase form designer.
The FIELDS program (FIELDS.PRG) connects to the MarshallSoft FTP site at "ftp.marshallsoft.com" as user "anonymous" with password "msc@traveller.com". Change the password to your email address before compiling. Run FIELDS from the command window.
The FIELDS program is similar to the LIST program. After connecting, FIELDS gets the list of all files on the server at the base FTP directory level, and lists each field as a separate string.
The PROXY example program connects to a FTP server through a proxy server using the "USR@SERVER" protocol. Edit PROXY.PRG with your FTP server name (or IP address), user name, and password before compiling.
Refer to the FCE User's Manual (FCE_USR) for a discussion of proxy servers. Section 3.6 "Proxy Server", of the FCE User's Manual (FCE_USR). http://www.marshallsoft.com/fce_usr.htm#Section_3.6
The MGET example program downloads files according to a wildcard pattern (using '?' and '*' characters). Edit MGET.PRG with your FTP server name (or IP address), user name, and password before compiling.
The MPUT example program uploads files according to a wildcard pattern (using '?' and '*' characters). Edit MPUT.PRG with your FTP server name (or IP address), user name, and password before compiling.
The SPEED example program connects to the MarshallSoft FTP server at ftp://ftp.marshallsoft.com and downloads a test file from the MarshallSoft FTP server and displays the time required. Use this program to see how long it takes to download files from FTP servers.
The FTP Client Engine DLLs (FCE16.DLL and FCE32.DLL) are written in ANSI C. All language versions of FCE (C/C++, Delphi, Visual dBase, PowerBASIC, FoxPro, dBase, Xbase++, and COBOL) use the same identical DLLs.
Version 1.2: October 15, 1999
Version 2.0: May 11, 2000
Version 2.1: February 8, 2001.
Version 2.2: October 16, 2001.
Version 2.3: December 12, 2002.
Version 2.4: June 1, 2004.
Version 2.5: July 28, 2005.
Version 2.6: February 16, 2007
Check http://www.marshallsoft.com for the latest version of our FTP software.