Nathan E. Pralle

Subscribe to Nathan E. Pralle: eMailAlertsEmail Alerts
Get Nathan E. Pralle: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


PowerBuilder: Article

Sybase PowerBuilder and FTP

Using WeOnlyDo! Software's FtpDLX Component in PowerBuilder

  • connected - Fires when the Connect() method is done connecting to the server.
  • disconnected - Fires when the Disconnect() method is done disconnecting from the server.
  • done - Fires every time some method is completed. Watch this one, if you script it and it does something extensive, you'll have it firing a lot...as in, after every single file of a multiple file transfer is completed.
  • ftpreply - This is fired whenever the component gets a response from the FTP daemon on the server. I used this event to add lines to a log file for the connection.
  • error - This is thrown when a major error occurs, usually big enough to stop your transfer.
  • looperror - When making multiple file transfers or looping through something, this fires if an error occurs.
  • loopitem - When running loops or multiple file transfers, this fires and lets you know what's happening on each iteration of the loop.
  • progress - Shows you how progress is being made on the file transfer. Hint: This is quite useful for setting up HorizontalProgressBars.
12.  Sending Files: There are two ways to send files, either one-by-one or with wildcards using PutFile(string localpath, string remotepath) or by sending multiple files and directories recursively with PutFiles(string localpath, string remotepath,int max_levels_recursion). PutFiles is by far the more powerful of the two but it depends on your application. PutFile (singular) allows wildcards; PutFiles (plural) does not. This is an important distinction, as you might guess that PutFiles("e:\*.*","/",0) would send all files from drive E: to the server. Instead, it will hang without error. Don't confuse these two, or many hours will be needlessly wasted banging your head against a wall. The correct format to send all files would be: PutFiles("e:\","/",0). The zero means "no limit" to the recursive transfer. (Watch how deep you let it go!)
13.  Getting Files: Getting files is very similar to sending files. GetFile(string localpath,string remotepath) is the function to get one file or multiples using wildcards; GetFiles(string localpath,string remotepath,int max_level_recusion) is the method to use to receive files and directories recursively. As with the Sending methods, GetFile allows wildcards; GetFiles does not.
14.  Disconnecting: Disconnecting is as simple as issuing the Disconnect() method as such: ole_wodftp.object.Disconnect(BOOLEAN) where BOOLEAN is TRUE to make it log out of the server correctly; FALSE drops the connection without another word.

This is the basic idea behind the component. There are a multitude of options and other methods to be run and events to catch; once you get the idea, you can expand as necessary. A day or two of work and you should have a functional and useful FTP/SFTP implementation in your PowerBuilder application without having to burn too many brain cells in the process. (See Listing 1)

Further Reading and Resources
WeOnlyDo! Software - www.weonlydo.com

More Stories By Nathan E. Pralle

Nathan Pralle is a programmer in the Research and Development department of Creative Solutions Unlimited, Inc. in Sheffield, IA. He programs daily in PowerScript, SQL, Perl, C, VC++, and InstallScript. On the side he is a partner in Binhost Technologies, an Internet service provider, and BinFone Telecom, a VoIP services provider, both out of Laurel, MD. In his spare time he is an avid barbershop singer, vintage computer collector, and philosopher. He shares his living space with his wife, Yolanda, and their cat, Leo.

Comments (7) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Mike Nardella 02/09/08 09:51:08 PM EST

Nathen,
How did you trap the events. If you use the ActiveX control notifications are not supported. It says this in the user guide and I confirmed that the events do not work. Only if you use the Com object and impliment the INotify interface.

-Mike

Declan Swayne 11/26/07 08:35:26 AM EST

Hi All,

I am trying to incorporate this in to my Powerbuilder app. Instead of inserting the control I created a new one from it. ( due to a pb error on msvcrt.dll in PB )
I associated all properties to the ole in the open event. I then call the connect event but keep getting the error "Error calling external object function connect etc )"

Am I doing something wrong here?

Thanks
Declan

Nathan Pralle 06/22/06 12:07:45 AM EDT

True, I could have used the WinInet API. However, after studying it for awhile, I decided that to implement all the options and so forth needed it would take me many more hours to implement than the WOD component; indeed, it would cost my business more money to pay me to write it than it would to just buy a license to the component. In the end, it was a no-brainer. No fuss, no muss, free updates, cheap price, royalty-free distribution, and minimal coding -- what is there to hate?

Alden 06/15/06 03:24:49 PM EDT

You can make it simple with WinInet API.

KW Thong 05/29/06 02:34:31 AM EDT

I'm wondering, what not using the winsock method, where power builder had been supported since version 5. I've not been using PW since version 6. Not so sure what's with the later release. They should be there.

PBDJ News Desk 05/21/06 05:58:41 PM EDT

Recently, I needed to have FTP support embedded in a PowerBuilder application that I was writing for my day job. Since PowerBuilder lacks the ability to natively manipulate sockets (a big negative, Sybase), a third-party solution had to be found or I was going to be tempting the wrath of the Windows API, something I wasn't looking forward to doing.

PBDJ News Desk 05/21/06 05:39:30 PM EDT

Recently, I needed to have FTP support embedded in a PowerBuilder application that I was writing for my day job. Since PowerBuilder lacks the ability to natively manipulate sockets (a big negative, Sybase), a third-party solution had to be found or I was going to be tempting the wrath of the Windows API, something I wasn't looking forward to doing.