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.


An Introduction to the Lotus Domino Tool Suite

Getting Started with Designer

Navigating the Domino Designer Workspace

Domino Design Elements

An Introduction to Formula Language

An Introduction to LotusScript

Fundamentals of a Notes Application

Calendar Applications

Collaborative Applications

Reference Library Applications

Workflow Applications

Web Applications

Design Enhancements Using LotusScript

Design Enhancements Using Formula Language

View Enhancements

Sample Agents

Miscellaneous Enhancements and Tips for Domino Databases

Data Management

Security

Application Deployment and Maintenance

Troubleshooting

Appendix A. Online Project Files and Sample Applications

Appendix B. IBM® Lotus® Notes® and Domino®Whats Next?



Lotus Notes Developer's Toolbox(c) Tips for Rapid and Successful Deployment
Lotus Notes Developers Toolbox: Tips for Rapid and Successful Deployment
ISBN: 0132214482
EAN: 2147483647
Year: N/A
Pages: 293
Authors: Mark Elliott

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net