Fields in Forms Matrix
When cleaning up existing applications it is good to have an overview what fields are used across forms. Unfortunately the synopsis isn't very helpful there. However with a few lines of LotusScript one can create a matrix that serves as an overview. It is a comparison by name only and doesn't tell you anything about computation mode or data-type. But it is a start. YMMV
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.
'CreateFieldMatrixReport: Option Public Option Declare Dim fieldList List As Integer 'The row for a specific field name Dim fieldCount As Integer 'How many unique fieldnames do we have 0 based Sub Initialize Dim db As NotesDatabase Dim s As New NotesSession Dim out As NotesStream Dim curForm As NotesForm Dim filename As String Dim formList List As Variant 'A list with arrays of fiields Dim formCount As Integer 'How many forms do we have 0 based Dim fieldArray ( ) As Boolean On Error Goto Err_Initialize fileName = Inputbox ( "Where to store the result" ) If fileName = "" Then Exit Sub End If Set out = s .CreateStream Call out . Open (fileName ) Call out .Truncate formCount = -1 fieldCount = -1 Set db = s .CurrentDatabase 'Extract all the fields and forms Forall f In db .Forms formCount = formCount + 1 Set curForm = f formList (curForm . Name ) = curForm .Fields Call extractFields (curForm .Fields ) End Forall 'Now size the array Redim fieldArray (fieldCount ,formCount ) 'Header out .WriteText ( |<html><head><title>Field Matrix</title></head><style>.yes {background-color : red; color : white }| ) out .WriteText ( | .no { color : white} table {width : 100%} td {text-align : center}</style></head><body><table>| ) 'Now fill the array Dim i As Integer Dim j As Integer 'Now fill the array and the first table out .WriteText ( |<tr><th>Field/Form</th>| ) i = -1 'Reset i as Rowcounter Forall curFields In formList i = i + 1 For j = 0 To Ubound (curFields ) fieldArray (fieldList (curFields (j ) ) ,i ) = True Next Call out .WriteText ( |<th>| ) out .WriteText Listtag (curFields ) Call out .WriteText ( |</th>| ) End Forall Call out .WriteText ( |</tr>| ) 'Now the matrix in its full beauty Forall curFields2 In FieldList out .WriteText ( |<tr><td>| + Listtag (curFields2 ) + |</td>| ) 'curFields2 has the row, we loop through the columns For j = 0 To formCount If fieldArray (curFields2 ,j ) Then 'it is boolean after all out .WriteText ( |<td class="yes">+</td>| ) Else out .WriteText ( |<td class="no">-</td>| ) End If Next out .WriteText ( |</tr>| ) End Forall 'Footer out .WriteText ( |</table></body></html>| ) Exit_Initialize : On Error Resume Next Call out . Close Exit Sub Err_Initialize : Msgbox Error$ Resume Exit_Initialize End Sub Sub extractFields (allFields As Variant ) 'fieldList, fieldcount are globla Forall curFieldName In allFields If Not Iselement (fieldList (curFieldName ) ) Then 'We only add fields we don't have in the list fieldcount = fieldCount + 1 fieldList (curFieldName ) = fieldCount End If End Forall End Sub
provided by Julian Robichaux at nsftools.com.
Posted by Stephan H Wissel on 15 September 2008 | Comments (3) | categories: Show-N-Tell Thursday