Hallo zusammen, ich soll mich mit einem Agenten beschäftigen. Nur ich komm mit dem Quellcode nicht klar, ich hab schon in Büchern nachgeschlagen und leute gefragt, nichts konnte mir weiter helfen. Vielleicht könnte mir einer den Quellcode kommentieren, das würde mir wirklich weiter helfen.
Options:
Option Public
Option Declare
Declarations:
Dim session As notessession
Dim db As notesdatabase
Dim doc As notesdocument
Dim dc As notesdocumentcollection
Dim i As Integer
Dim rtitem As notesrichtextitem
Dim item As NotesItem
Dim plainText As String
Dim pos1 As Integer
Dim pos2 As Integer
Dim tmp As String
Dim datetime As notesdatetime
Initialize:
Sub Initialize
Set session = New notessession
Set db = session.currentdatabase
Set dc = db.UnprocessedDocuments
If dc.count = 0 Then Exit Sub
For i% = 1 To dc.count
Set doc = dc.GetNthDocument(i)
Set rtitem = doc.GetFirstItem("Body")
plainText$ = rtitem.GetFormattedText( False, 0 )
'Zeilenumbruch durch ~ ersetzen
plainText$ = ReplaceChar( Chr(10) , "~", plainText$)
plainText$ = ReplaceChar( Chr(13) , "", plainText$)
pos1% = Instr(1, plainText$, "Urlaub von:")
pos2% = Instr(pos1%, plainText$, "~")
tmp$ = Mid(plainText$, pos1%, pos2% - pos1%)
pos1% = Instr(1, tmp$, ":")
tmp$ = Trim(Mid(tmp$, pos1% + 1, Len(tmp$) - pos1%))
Set datetime = New notesdatetime(tmp$)
doc.StartDate = datetime.LSLocalTime
Call doc.save(True, False)
pos1% = Instr(1, plainText$, "Urlaub bis:")
pos2% = Instr(pos1%, plainText$, "~")
tmp$ = Mid(plainText$, pos1%, pos2% - pos1%)
pos1% = Instr(1, tmp$, ":")
tmp$ = Trim(Mid(tmp$, pos1% + 1, Len(tmp$) - pos1%))
Set datetime = New notesdatetime(tmp$)
doc.EndDate = datetime.LSLocalTime
doc.Form = "Appointment"
Call doc.save(True, False)
Next
End Sub
ReplaceChar:
Function ReplaceChar( Byval SearchChar As String , Byval ReplaceWithChar As String , Byval Text As String ) As String
On Error Goto Err_ReplaceChar
Dim pos As Integer
Dim svalue
If (SearchChar <> ReplaceWithChar) Then ' OK, something to do (avoid replace "x" with "x")
Text = Trim( Text )
pos = Instr( Text , SearchChar)
While Pos ' (<> 0)
Text = Left( Text , pos-1 ) & ReplaceWithChar & Mid( Text , pos+1 ) ' replace SearchChar with ReplaceWith
pos = Instr( Text , SearchChar )
Wend
End If
ReplaceChar = Cstr( Text )
Exit Function
Err_ReplaceChar:
'suppress all errors so far in here....
Select Case Err
Case 1
' nothing
Case Else
Msgbox Error$ & Chr(10) & Err , 16 , "SLIBStringTools.ReplaceChar"
End Select
Exit Function
End Function