Page 1 sur 1

Replication Formula Settings

MessagePublié: 01 Août 2005 à 12:26
par Stephane Maillard
[syntax="ls"]Const APIModule = "NNOTES" ' Windows

Declare Function OSPathNetConstruct Lib APIModule Alias "OSPathNetConstruct" _
( Byval NullPort As Long, Byval Server As String, Byval FIle As String, Byval PathNet As String) As Integer

Declare Function NSFDbOpen Lib APIModule Alias "NSFDbOpen" _
( Byval PathName As String, DbHandle As Long) As Integer
Declare Function NSFDbClose Lib APIModule Alias "NSFDbClose" _
( Byval DbHandle As Long) As Integer

Declare Function NSFNoteOpen Lib APIModule Alias "NSFNoteOpen" _
( Byval DbHandle As Long, Byval NoteID As Long, Byval F As Integer, hNT As Long) As Integer
Declare Function NSFNoteClose Lib APIModule Alias "NSFNoteClose" _
( Byval hNT As Long) As Integer
Declare Private Function NSFNoteUpdate Lib APIModule Alias "NSFNoteUpdate" _
( Byval hNT As Long, Byval F As Integer) As Integer

Declare Function OSMemFree Lib APIModule Alias "OSMemFree" _
( Byval Handle As Long) As Integer
Declare Function OSLockObject Lib APIModule Alias "OSLockObject" _
( Byval H As Long) As Long
Declare Sub OSUnlockObject Lib APIModule Alias "OSUnlockObject" _
( Byval H As Long)

Declare Private Function NSFItemAppend Lib APIModule Alias "NSFItemAppend" _
( Byval hNT As Long, Byval F As Integer, Byval N As String, Byval nN As Integer _
, Byval T As Integer, Byval V As Long, Byval nV As Long) As Integer
Declare Function NSFItemDelete Lib APIModule Alias "NSFItemDelete" _
( Byval hNT As Long, Byval N As String, Byval nN As Integer) As Integer

Declare Function NSFFormulaCompile Lib APIModule Alias "NSFFormulaCompile" _
( Byval N As Long, Byval nN As Integer, Byval F As String, Byval nF As Integer, hFL As Long, nFL As Integer _
, eE As Integer, eL As Integer, eC As Integer, eO As Integer, eN As Integer) As Integer

Declare Private Sub Poke Lib "MSVCRT" Alias "memcpy" _
( Byval P As Long, S As Any, Byval N As Long)


Sub Click(Source As Button)
Const ButtonTitle = "Replication Formula"
Const dbName = "test.nsf"
Const noteID = &HFFFF0800&
Const itemName = "$ReplFormula"
Const formula = {SELECT @IsNotMember(Form; "Herring")}

db$ = String$(1024, " ")
OSPathNetConstruct 0, "", dbName, db$

Dim hDB As Long
NSFDbOpen db$, hDB
If hDB = 0 Then Exit Sub

Dim hNT As Long
NSFNoteOpen hDB, noteID, 0, hNT
If Not hNT = 0 Then
Dim hF As Long
NSFFormulaCompile 0, 0, formula$, Len(formula$), hF, nF%, eE%, eL%, eC%, eO%, eN%
If Not hF = 0 Then
NSFItemDelete hNT, itemName, Len(itemName)
p& = OSLockObject(hF)
Poke p& + nF% - 2, &HFFFE, 2
NSFItemAppend hNT, 4, itemName, Len(itemName), &H0600, p&, Clng(nF%)
OSUnlockObject hF
OSMemFree hF
NSFNoteUpdate hNT, 0
End If
NSFNoteClose hNT
End If

NSFDbClose hDB
End Sub[/syntax]