NotesFTP Class

Hello folks,

I’ve been using the NotesFTP Class (from the Sandbox) successfully for a while now. We’ve recently changed the port on our FTP server from 21 to 5032.

I am able to hardcode the port number in the Const INTERNET_INVALID_PORT_NUMBER and it works, but I’d like to make it a parameter. This is where I run into problems.

I am calling Connect:

objFTP.Connect servername$, ftpPort%, username$, pswd$, 0

where ftpPort is Dimmed as Integer and set to 5032.

In the Class I have:

Sub Connect(server$, port%, user$, password$, flags&)

<>

Me.hConnection = InternetConnect(Me.hLib, server$, port%, user$, password$, INTERNET_SERVICE_FTP, flags&, 0)

I get a TypeMismatch of FTPPORT pointing to where I call “Connect” when I try to save my script. The Class saves fine. I have tried Integer, Double and Long… same results.

I’ve also tried just the hostname:5032, no luck.

Am I missing something obvious here?

Thx in advance.

Subject: NotesFTP Class

try this (bit of a hack but might work)…

create a private instance var portNum

create a new sub called ConnectOtherPort that has the same method signature as the connect plus the new port info. Inside the method call set the portNum instance var to the value passed in (psuedo…example below…)

public Class NotesFTPSession

private portNum as Integer

Sub ConnectOtherPort(server,port, user , password , flags)

me.portNum = port

Call me.Connect(…

make sure the Connect sub uses the me.portNum variable you just set… let me know if it works.

Mark

Subject: RE: NotesFTP Class

Hi, thanks for the response.

I tried as you suggested, but got the same result.

I assume when you said to “Call me.Connect”, you meant to call the new sub created “ConnectOtherPort”

Driving me bonkers.

Subject: RE: NotesFTP Class

See methods below… call ConnectOtherPort sub instead of connect from your agent or button. ConnectOtherPort is wrapping the old Connect and contains the extra portNum var. Me refers to the current instance (similar to java keyword this)

' opens socket and logs into FTP host

Sub Connect(server As String,user As String, password As String, flags As Long) 		

	

	' close any connections we may already have open		

	If Me.hConnection <> 0 Then

		apiInternetCloseHandle Me.hConnection

	End If

	

	' log into the FTP host and get a handle to the connection

	Me.hConnection = InternetConnect(Me.hLib, server$, Me.portNum, user$, password$, INTERNET_SERVICE_FTP, flags, 0)

	

	' raise error if we cannot login to the host

	If Me.hConnection = 0 Then

		Error NOTESFTP_CONNECT_FAILED, "Could not connect to host " & server$ & "."

	End If

	

End Sub

’ opens socket and logs into FTP host

Sub ConnectOtherPort(server As String,thePort As Integer, user As String, password As String, flags As Long) 		

	Me.portNum = thePort

	Call Me.Connect(server,user,password,flags)		

End Sub

Subject: RE: NotesFTP Class

Mark,I think I understand your last response much better. The one problem I’m having now is the new sub in my scriptlib when trying to save says, “Not a sub or function name: ConnectOtherPort”.

What’s wierd is the syntax is very similar for both, and both clearly exist. The original sub works fine, the new one doesn’t. If I make the new sub part of my scriptlib instead of in the Class, I get all kinds of Not a member errors because “Me.” is in the Class.

I still feel like I’m missing something obvious here.

In my scriptlib:

==============

.Connect “server.mydomain.com”, “johnsmith”, “mypassword”, 0 ’ This works

.ConnectOtherPort “server.mydomain.com”, 5032, “johnsmith”, “mypassword”, 0 ’ This returns the error

In the Class:

============

Sub ConnectOtherPort(server$, thePort%, user$, password$, flags&)

Me.portNum = thePort%

Call Me.Connect(server$, user$, password$, flags&)

End Sub

’ opens socket and logs into FTP host

Sub Connect(server$, user$, password$, flags&)

’ close any connections we may already have open

If Me.hConnection <> 0 Then

apiInternetCloseHandle Me.hConnection

End If

’ log into the FTP host and get a handle to the connection

Me.hConnection = InternetConnect(Me.hLib, server$, Me.portNum, user$, password$, INTERNET_SERVICE_FTP, flags&, 0)

’ raise error if we cannot login to the host

If Me.hConnection = 0 Then

Error NOTESFTP_CONNECT_FAILED, "Could not connect to host " & server$ & "."

End If

End Sub

Subject: RE: NotesFTP Class

John,Send me a note w/ your code (just a subset… the class and the caller)… I’ll take a look. BTW… I sent you a .txt file w/ the altered lotusscript class to your hotmail account.

Mark

Subject: RE: NotesFTP Class - It Worked!

Thanks Mark, received your code and tried one thing. Copied your ConnectOtherPort sub and pasted it over mine… worked perfectly.I can’t explain why I was getting the “not a sub or function…” error message. I love Notes.

Either way, I greatly appreciate your help.

My code was:

Sub ConnectOtherPort(server$, thePort%, user$, password$, flags&)

Me.portNum = thePort%

Call Me.Connect(server$, user$, password$, flags&)

End Sub

Your code:

Sub ConnectOtherPort(server As String,thePort As Integer, user As String, password As String, flags As Long)

Me.portNum = thePort

Call Me.Connect(server,user,password,flags)

End Sub