Lotus Notes — рабочий инструмент программиста.

Обсуждения программирования на Lotus Notes/Domino

Archive for Ноябрь 12th, 2008

Change fields position in a flat text file

без комментариев

‘—: Option Declare ‘ ‘ FieldName TAB Length TAB Position ‘ Const FormatFileInput=|
USR-IDAZE 8 36
USR-MAZEAT 7 44
USR-TIAZETRE 4 51
USR-NAZEOM 25 55 | ‘ ‘ FieldName TAB Length TAB Position ‘ Const FormatFileOutput=|
USR-IDAZE 8 501
USR-MAZEAT 7 509
USR-TIAZETRE 4 516
USR-NAZEOM 25 520 | Const FileNameInput = "IN.TXT"
Const FileNameOutput = "OUT.TXT" Type LineFileFormat
Name As String
Length As Long
Position As Long
End Type Type FormatConv
In As LineFileFormat
Out As LineFileFormat
End Type Dim LineOutTotalLength As Long Sub Initialize Dim FormatConvertion List As FormatConv
Dim V As Variant
Dim FormatFile_Tmp As Variant
Dim LineFileFormat_Tmp As LineFileFormat ‘ IN
FormatFile_Tmp = Split( FormatFileInput , Chr$(10) )
Forall Champ In FormatFile_Tmp
V = Split( Champ , Chr$( 9 ) )
If Trim$( V(0) ) <> "" Then
LineFileFormat_Tmp.Name = Trim$( V( 0 ) )
LineFileFormat_Tmp.Length = Val( V( 1 ) )
LineFileFormat_Tmp.Position = Val( V( 2 ) )
FormatConvertion( LineFileFormat_Tmp.Name ).IN = LineFileFormat_Tmp
End If
End Forall ‘ OUT
FormatFile_Tmp = Split( FormatFileOutput , Chr$(10) )
Forall Champ In FormatFile_Tmp
V = Split( Champ , Chr$( 9 ) )
If Trim$( V(0) ) <> "" Then
LineFileFormat_Tmp.Name = Trim$( V( 0 ) )
LineFileFormat_Tmp.Length = Val( V( 1 ) )
LineFileFormat_Tmp.Position = Val( V( 2 ) )
FormatConvertion( LineFileFormat_Tmp.Name ).OUT = LineFileFormat_Tmp
If LineFileFormat_Tmp.Position + LineFileFormat_Tmp.Length > LineOutTotalLength Then LineOutTotalLength = LineFileFormat_Tmp.Position + LineFileFormat_Tmp.Length
End If
End Forall ‘ ‘ Format Control ‘ Forall OneFieldConvertion In FormatConvertion
If OneFieldConvertion.In.Name = "" Then
Print OneFieldConvertion.Out.Name + Chr$(9) + Chr$(9) + " The ouput file do not contains this field"
Elseif OneFieldConvertion.Out.Name = "" Then
Print OneFieldConvertion.In.Name + Chr$(9) + Chr$(9) + " The ouput file do not contains this field"
Elseif OneFieldConvertion.In.Length > OneFieldConvertion.Out.Length Then
Print OneFieldConvertion.In.Name + Chr$(9) + Chr$(9) + " This field size will be reduced to " + Cstr(OneFieldConvertion.Out.Length) + " instead of " + Cstr(OneFieldConvertion.In.Length)
End If
End Forall ‘ ‘ Convertion ‘ Dim FileNumInPut As Long
FileNumInPut = Freefile
Open FileNameInput For Input Access Read As FileNumInPut Dim FileNumOutPut As Long
FileNumOutPut = Freefile
Open FileNameOutput For Output Access Write As FileNumOutPut Dim S As String
Do Until Eof(FileNumInPut)
Line Input #FileNumInPut, S
Print #FileNumOutPut, LineConvert( S , FormatConvertion )
Loop Close #FileNumOutPut
Close #FileNumInPut End Sub Function LineConvert( LineIn As String, FormatConvertion List As FormatConv ) As String Dim S As String Dim LineOut As String
LineOut = Space$( LineOutTotalLength ) Forall AFieldToConvert In FormatConvertion
If (AFieldToConvert.IN.Name <> "") And (AFieldToConvert.OUT.Name <> "") Then
S = Mid$( LineIn , AFieldToConvert.IN.Position , AFieldToConvert.IN.Length )
If Len(S) < AFieldToConvert.OUT.Length Then
S = S + Space$( AFieldToConvert.OUT.Length – Len(S) )
End If
LineOut = Left$( LineOut , AFieldToConvert.OUT.Position-1 ) + Left$( S , AFieldToConvert.OUT.Length ) + Mid$( LineOut , AFieldToConvert.OUT.Position + AFieldToConvert.OUT.Length )
End If
End Forall LineConvert = LineOut End Function

Original source : http://www.openntf.org/projects/codebin/codebin.ns…

Написано lotusnotes

Ноябрь 12, 2008 в 5:25

Опубликовано в Lotus Notes

Export all group members in CSV file

без комментариев

Dim FileNum As Long
Dim LogError As String Sub Initialize Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments Set doc = collection.GetFirstDocument()
While Not(doc Is Nothing) Call InitExport( Doc.ListName(0) )
Call GroupExport( Doc.ListName(0) )
Call TerminateExport( ) Set doc = collection.GetNextDocument(doc)
Wend
print LogError
End Sub Sub TerminateExport( ) Close #FileNum End Sub Sub GroupExport( GroupName As String ) Dim Session As New NotesSession
Dim DB As NotesDatabase
Set DB = Session.CurrentDatabase Dim AllUsersView As NotesView
Set AllUsersView = DB.GetView( "($Users)" ) Dim Doc As NotesDocument
Set Doc = AllUsersView.GetDocumentByKey( GroupName , True ) If Doc Is Nothing Then
LogError = LogError + " Groupe/User introuvable : " + GroupName + Chr$(10)
Exit Sub
End If If Doc.Type(0) = "Group" Then Forall OneMember In Doc.Members
GroupExport( OneMember )
End Forall Elseif Doc.Type(0) = "Person" Then Print #FileNum, |"| + Doc.FullName(0) + |"| End If End Sub Sub InitExport( GroupName As String ) FileNum = Freefile() Open "c:\TEMP\Export CSV of " + GroupName + ".CSV" For Output Access Write As FileNum End Sub

Original source : http://www.openntf.org/projects/codebin/codebin.ns…

Написано lotusnotes

Ноябрь 12, 2008 в 5:24

Опубликовано в Lotus Notes

is application on local or not (function)

без комментариев

this function checks if the current application is on the server or local. true = is on local
false = is on a server Its a very small and easy function. But sometimes useful ;-)

Original source : http://www.openntf.org/projects/codebin/codebin.ns…

Написано lotusnotes

Ноябрь 12, 2008 в 7:28

Опубликовано в Lotus Notes

Display Lotus Notes user group membership details in a tree view

без комментариев

Determining which groups a Lotus Notes user belongs to is important, but difficult if you don’t have access to the proper databases. This tip explains how to display a tree view of the groups and nested groups to which a user belongs with just the click of a button.

Original source : http://feeds.feedburner.com/~r/techtarget/Searchdo…

Написано lotusnotes

Ноябрь 12, 2008 в 7:28

Опубликовано в Lotus Notes

Open database listed in an email ( like GSX errors )

без комментариев

Sub Initialize
‘ posted to http://www.openntf.org/projects/codebin/codebin.nsf/CodeByDate/BB07663266C769D2862574F60054154B
‘ written by Mike Mortin, 20070830 Dim ws As New NotesUIWorkspace
Dim uiDoc As NotesUIDocument
Dim nServer As NotesName
Dim tempStr As String, fileList As String, server As String
Dim tempVar As Variant
Dim index As Integer
Const kDelim = " " ‘ get email content
Set uiDoc = ws.CurrentDocument
tempStr = uiDoc.FieldGetText("body") ‘ split and join to remove unwanted characters
tempVar = Split(tempStr, Chr(13)) ‘ new line characters
tempVar = Join(tempVar, kDelim)
tempVar = Split(tempVar, "’") ‘ single quotes
tempVar = Join(tempVar, kDelim) ‘ lastly, split into words
tempVar = Split(tempVar, kDelim) ‘ spaces ‘ server name is the next entry
Set nServer = New notesName(tempVar(3))
server = nServer.Common ‘ then parse through remaining entries to get all mailfiles listed
For index = Lbound(tempVar) To Ubound(tempVar)
Print tempVar(index)
If Instr( tempVar(index), ".nsf" ) > 0 Then
‘ add it to the list
tempStr = Left( tempVar(index), Instr( tempVar(index), "nsf") +2 )
fileList = fileList & tempStr & ","
End If
Next index ‘ now, did we find any mail files? If Len(fileList) > 0 Then
‘ make the list and tighen it up
tempVar = Split( fileList, "," )
tempVar = Arrayunique(tempVar)
tempVar = Fulltrim(tempVar) ‘ present and open the db
tempStr = ws.Prompt(4, "Select the database on " & server & " that you want to open.", "Click ‘Cancel’ to exit.", "", Split( fileList, "," ))
If tempStr <> "" Then Call ws.OpenDatabase(server, tempStr)
Else
Msgbox "No mailfiles detected"
End If
End Sub

Original source : http://www.openntf.org/projects/codebin/codebin.ns…

Написано lotusnotes

Ноябрь 12, 2008 в 7:27

Опубликовано в Lotus Notes

Clear the Recent Contacts

без комментариев

Here is a quick little code that I added to the R8 Mail template to quickly purge the Recent Contacts in R8. It removes the documents from the local NAB & clears the Metadata from the local PC.

Original source : http://www.openntf.org/projects/codebin/codebin.ns…

Написано lotusnotes

Ноябрь 12, 2008 в 7:27

Опубликовано в Lotus Notes

PromptMailTemplateUsed – Get information about the template your mail database inherits from.

без комментариев

[<pre>
Sub PromptMailTemplateUsed()
‘Written by John Smart John.Smart@GreyDuck.com
‘Submitted to OpenNTF on 30 Oct 2008
‘http://www.openntf.org/projects/codebin/codebin.nsf/CodeByDate/660570790A3B977B862574F2006E3E4F
Dim db As New NotesDatabase("", "")
Dim doc As NotesDocument
Dim strMsg As String
Dim strTemplateName As String
Dim strTemplateServerName As String
Dim strTemplateFileName As String Print "Finding your email database…"
Call db.OpenMail() Print "Verifying that your email database inherits from a template…"
strTemplateName = db.DesignTemplateName
If Len(strTemplateName) = 0 Then
Error 1000, "Your mail database doesn’t inherit it’s design from a template."
End If Print "Getting information about where your mail template inherits from…"
Set doc = db.GetDocumentByID("FFFF0010") ‘icon design element. Thanks to http://www.nsftools.com/tips/NotesTips.htm#defaultelements ‘Get template information stored in the icon design element. Thanks to http://www.notesninjas.com/#TemplateFileName
strTemplateServerName = doc.GetItemValue("$TemplateServerName")(0)
strTemplateFileName = doc.GetItemValue("$TemplateFileName")(0) strMsg = |Design Template Name: | + strTemplateName + |
Server: | + strTemplateServerName + |
File Path: | + strTemplateFileName + | NOTE: File Path is based on the server’s operating system, so a File Path of "/local/notes/data/mail8.ntf" would imply that your template is probably "mail8.ntf" in the root data directory on your server.| Print ""
Messagebox strMsg, 0, "Hints on where to find your mail template."
End Sub
</pre>]

Original source : http://www.openntf.org/projects/codebin/codebin.ns…

Написано lotusnotes

Ноябрь 12, 2008 в 7:27

Опубликовано в Lotus Notes