I was trying to check, if a correct form name was passed to a function. Did it at first by iterating over the elementNames
of all form documents like so:
Function frmDocExists(frmName As String) As Boolean
Dim sFrmDocs() As String
Dim sFrmDoc As String
Dim bFound As Boolean
sFrmDocs = ThisDatabaseDocument.FormDocuments.ElementNames
For Each sFrmDoc In sFrmDocs
bFound = (sFrmDoc = frmName)
If bFound Then Exit For
Next
frmDocExists = bFound
End Function
But then I noticed that the API already has a method that helps with the specific case:
API method:
Function frmDocExists(frmName As String) As Boolean
frmDocExists = ThisDatabaseDocument.FormDocuments.hasByName(frmName)
End Function
But the question still stands for arrays in general:
Is there any existing array utility function to check if an array contains an item? Would I have to cast the array into something else first?