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: OptionPublicOptionDeclareDim fieldList ListAsInteger'The row for a specific field nameDim fieldCount AsInteger'How many unique fieldnames do we have 0 basedSubInitializeDim db AsNotesDatabaseDim s AsNewNotesSessionDim out AsNotesStreamDim curForm AsNotesFormDim filename AsStringDim formList ListAsVariant 'A list with arrays of fiields Dim formCount AsInteger'How many forms do we have 0 basedDim fieldArray ()AsBooleanOnErrorGoto Err_Initialize fileName =Inputbox("Where to store the result")If fileName =""ThenExitSubEndIfSet out = s .CreateStream Call out .Open(fileName )Call out .Truncate formCount =-1 fieldCount =-1 Set db = s .CurrentDatabase 'Extract all the fields and formsForall f In db .Forms formCount = formCount + 1 Set curForm = f formList (curForm .Name)= curForm .Fields Call extractFields (curForm .Fields )EndForall'Now size the arrayRedim 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 arrayDim i AsIntegerDim j AsInteger 'Now fill the array and the first table out .WriteText (|<tr><th>Field/Form</th>|) i =-1 'Reset i as RowcounterForall curFields In formList i = i + 1 For j = 0 ToUbound(curFields ) fieldArray (fieldList (curFields (j )),i )=TrueNextCall out .WriteText (|<th>|) out .WriteText Listtag(curFields )Call out .WriteText (|</th>|)EndForallCall out .WriteText (|</tr>|)'Now the matrix in its full beautyForall curFields2 In FieldList out .WriteText (|<tr><td>|+Listtag(curFields2 )+|</td>|)'curFields2 has the row, we loop through the columnsFor 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>|)EndIfNext out .WriteText (|</tr>|)EndForall'Footer out .WriteText (|</table></body></html>|) Exit_Initialize :OnErrorResumeNextCall out .CloseExitSub Err_Initialize :MsgboxError$Resume Exit_Initialize EndSubSub extractFields (allFields AsVariant)'fieldList, fieldcount are globlaForall curFieldName In allFields IfNotIselement(fieldList (curFieldName ))Then'We only add fields we don't have in the list fieldcount = fieldCount + 1 fieldList (curFieldName )= fieldCount EndIfEndForallEndSub
provided by Julian Robichaux at nsftools.com.
Posted by Stephan H Wissel on 15 September 2008 | Comments (3) | categories: Show-N-Tell Thursday