When you get an error on connect - WeOnlyDo Discussion board

When you get an error on connect (General questions)

by Scots, Thursday, November 17, 2011, 17:51 (4753 days ago)

I am using powerbuilder with wodftpdlx
I use a clicked event on a button to connect and send a file
the putfile is on the connected event
but... if I get an errorcode, I do a return.. before
I try to do the put file
I'm getting an error when it returns back
which doesn't make a lot of sense
below is the code from the clicked event... and after
that on the connected event
shouldn't it just return to the connect call

clicked
ole_cer = CREATE oleobject
ole_cer.ConnectToNewObject( WeOnlyDo.Certificate.1 )

if override = 0 then
ole_cer.generatekey(0)
ole_cer.savekey(f_path)
end if

//ole_ftp.LicenseKey = XXXX-XXXX-XXXX-XXXX
ole_ftp.object.hostname = ftp_site
ole_ftp.object.login = ftp_acc
ole_ftp.object.password = ftp_pass
ole_ftp.object.authentication = 1
ole_ftp.object.transfermode = 0
ole_ftp.object.blocking = 1
ole_ftp.object.protocol = 1
ole_ftp.object.compression = 6
ole_ftp.object.passive = 1
ole_ftp.object.port = 22

p_state = 1
f_list = cuser_directory+'JS11_SEND*.*'
counter = 0
counter_tot = 0
destroy ole_cer

ole_ftp.object.connect()

if c_value = 0 then
messagebox('Complete','Stats Setup File Sent Sucessfully')
end if


connected
string local_send, remote_send, remote_file

If ErrorCode <> 0 Then
messagebox('ERROR','UNABLE TO CONNECT TO FTP SITE, CONTACT SUPPORT')
return
end if

//remote_file = ole_ftp.object.remotepath + filename
//ole_ftp.object.remotepath='/sstyer/'

ole_ftp.object.putfile(f_path)

Re: When you get an error on connect

by wodDamir, Thursday, November 17, 2011, 17:59 (4753 days ago) @ Scots

Scot,

You say you're using events, but I see that there is a Blocking property set to True in your code.

When you're using Blocking, no component methods should be called from events at all. Instead, if error occurs, it will throw an exception on the method that caused it.

You need to use some error handling technique available in PB, such as try...catch blocks.

Can you please try doing so?

Regards,
Damba

Re: When you get an error on connect

by Scots, Thursday, November 17, 2011, 18:21 (4753 days ago) @ wodDamir

Scot,

You say you're using events, but I see that there is a Blocking property set to True in your code.

When you're using Blocking, no component methods should be called from events at all. Instead, if error occurs, it will throw an exception on the method that caused it.

You need to use some error handling technique available in PB, such as try...catch blocks.

Can you please try doing so?

I guess I'm confused
I'm not sure what you mean by Catch blocks
The way I did this, works ok... if we get connected properly
but... if it fails to connect, that's when I have problems

Re: When you get an error on connect

by Scots, Thursday, November 17, 2011, 19:12 (4753 days ago) @ Scots

Scot,

You say you're using events, but I see that there is a Blocking property set to True in your code.

When you're using Blocking, no component methods should be called from events at all. Instead, if error occurs, it will throw an exception on the method that caused it.

You need to use some error handling technique available in PB, such as try...catch blocks.

Can you please try doing so?

I guess I'm confused
I'm not sure what you mean by Catch blocks
The way I did this, works ok... if we get connected properly
but... if it fails to connect, that's when I have problems


I think I worked it out, thanks