ReplicateWithServer LS to API code problem

Hi all,

I have no experience in LS to NotesAPI programming, but have located some documentation to assist.

But in order to use the documentation, I need to understand how to Declare and Call in the code.

I am trying to create a Replica on a server so it appears in the Replication Page.

But the following compile error occurs -

Illegal Function Return Type for : REPLICATEWITHSERVER

Declarations

'STATUS LNPUBLIC ReplicateWithServer(char far *PortName,char far *ServerName,WORD Options,WORD NumFiles,const char far *FileList,REPLSERVSTATS far *retStats);

Declare Function ReplicateWithServer Lib “nnotes.dll” (Byval PortName As String, Byval ServerName As String, Byval Options As Integer, Byval NumFiles As Integer, Byval FileList As String, retStats As String)

LotusScript code**

Sub Initialize

Dim Result As Long	

Dim PortName As String

Dim ServerName As String

Dim Options As Integer

Dim NumFiles As Integer

Dim FileList As String

Dim retStats As String



Dim session As New NotesSession



PortName = "0"

ServerName = "CN=bacon/OU=servers/O=glen"

Options = "0"

FileList = "names.nsf"

result = ReplicateWithServer( PortName,ServerName, Options,1,FileList, retStats)

End Sub

Any help to get me started would be appreciated. I am looking to get a book, but I need to complete this code asap for a rollout.

Subject: ReplicateWithServer LS to API code problem

Try this. Notice options and declare statement changes. Also for simplicity, I am not trying to capture the “retStats” data.

Option Public

Option Declare

'Declarations*

'STATUS LNPUBLIC ReplicateWithServer(char far *PortName,char far *ServerName,WORD Options,WORD NumFiles,const char far *FileList,REPLSERVSTATS far *retStats);

%REM

#define REPL_OPTION_RCV_NOTES 0x00000001 /* Receive notes from server (pull) */

#define REPL_OPTION_SEND_NOTES 0x00000002 /* Send notes to server (push) */

#define REPL_OPTION_ALL_DBS 0x00000004 /* Replicate all database files */

#define REPL_OPTION_CLOSE_SESS 0x00000040 /* Close sessions when done */

#define REPL_OPTION_ALL_NTFS 0x00000400 /* Replicate NTFs as well */

#define REPL_OPTION_PRI_LOW 0x00000000 /* Low, Medium, & High priority databases*/

#define REPL_OPTION_PRI_MED 0x00004000 /* Medium & High priority databases only*/

#define REPL_OPTION_PRI_HI 0x00008000 /* High priority databases only*/

%END REM

'LotusScript code**

Declare Function W32_ReplicateWithServer Lib “nnotes.dll” Alias “ReplicateWithServer” _

(Byval PortName As Lmbcs String, _

Byval ServerName As Lmbcs String, _

Byval Options As Integer, _

Byval NumFiles As Integer, _

Byval FileList As String,_

Byval retStats As Long) As Integer

Public Const REPL_OPTION_RCV_NOTES& = &H00000001

Public Const REPL_OPTION_SEND_NOTES& = &H00000002

Sub Initialize

Dim Result As Long

Dim PortName As String

Dim ServerName As String

Dim Options As Integer

Dim NumFiles As Integer

Dim FileList As String

Dim retStats As Long



PortName = "TCPIP"

ServerName = "CN=bacon/OU=servers/O=glen"





Options =  REPL_OPTION_RCV_NOTES Or REPL_OPTION_SEND_NOTES

FileList = "names.nsf"

result = W32_ReplicateWithServer( PortName,ServerName, Options,1,FileList, 0&)

If (result <> False) Then

	Msgbox "Error: " & result

End If

End Sub

edit

However, if repStats is important (if you wish to log the number of replication exchanges somewhere), this would work:

Type REPLSERVSTATS

Pull As Variant

Push As Variant

StubsInitialized As Long

TotalUnreadExchanges As Long

NumberErrors As Long

LastError As Integer

End Type

Type pREPLSERVSTATS

Pull As REPLSERVSTATS

Push As REPLSERVSTATS

End Type

Declare Function W32_ReplicateWithServer Lib “nnotes.dll” Alias “ReplicateWithServer” _

(Byval PortName As Lmbcs String, _

Byval ServerName As Lmbcs String, _

Byval Options As Integer, _

Byval NumFiles As Integer, _

Byval FileList As String,_

retStats As pREPLSERVSTATS) As Integer

Dim repStats As pREPLSERVSTATS

result = W32_ReplicateWithServer( PortName,ServerName, Options,1,FileList, repStats)

Subject: RE: ReplicateWithServer LS to API code problem

Hi Timothy,

I keep getting an error 5646 when run.

But not sure how I can troubleshoot this error message.

Any ideas?

Subject: RE: ReplicateWithServer LS to API code problem

Check your port name. On location document, under ports.

Also, verify replica exists on that server.

Refer to the OSLoadString function to convert the error into something more meaningful.

-Brian