Check for an Element in an Array

The FoundElement function is used to search for a specified element in an array. For example, the function could be used to check if an email address or person's name is already included in an array of values.

How It Works

The function loops through each element in the array and compares the current element to the target value. It returns Boolean TRue if the element is found and False if the element is not found.

Implementation

This code should be added to a LotusScript library so that it can be invoked from multiple design elements without being duplicated. However, it could also be added directly to a form, view, or other design element. Two parameters must be specified to utilize this functionan array of values and a search string.

Function foundElement (varFromList As Variant, varTarget As Variant) As Boolean '----------------------------------------------------------------------- ' Check for the existence of an element in an array. '----------------------------------------------------------------------- foundElement = False Forall varElement In varFromList If varElement = varTarget Then foundElement = True Exit Forall End If End Forall End Function

The following illustrates how this function could be called from a form, view, or other design element.

If (foundElement (doc.FIELD, "SEARCHSTRING")) Then msgbox "Element found in the array." Else msgbox "Element not found in the array." End If

Note

The ArrayGetIndex function could also be used to achieve a similar result. Refer to the Domino Designer help for additional information pertaining to this function.

Категории