Hi all,
does someone if it is possible to detect an uninitialized Lotus Script dynamic array ?
For instance, you have
Dim s() As String
Call MySub(s)
Sub MySub(myArray As Variant)
If IS_INITIALIZED(MySub) Then
DoSomething
End If
End Sub
Thanks in advance for your response
Subject: How to know if a Lotus Script dynamic array has been initialized ?
Probably you can try out the IsArray() function on the array you are trying to initialise… it should return false if the array is not initialised.
Subject: How to know if a Lotus Script dynamic array has been initialized ?
I can’t think of anything that will work in place of:If IS_INITIALIZED(MyArray) Then
*NB assume you wanted to test on myArray and not mySub!
The best you could probably do is to try doing something valid only on an initialized array and then trapping with an error handler i.e.
Sub MySub(myArray As Variant)
dim testArray as Integer
On Error ErrUninitDynArray goto UninitDynArrayErrHandler
testArray = ubound(myArray)
DoSomething
Exit Sub
UninitDynArrayErrHandler:
DoSomthingElse
Exit Sub
End Sub
FYI ErrUninitDynArray = 200
HTH - Rufus.
Subject: RE: How to know if a Lotus Script dynamic array has been initialized ?
Maybe a better way:
Function ArrayIsEmpty(Arr As Variant) As Integer
Dim b As Variant
Forall entry In Arr
Let b = entry
End Forall
If Isempty(b) Then
Let ArrayIsEmpty = True
End If
End Function
Subject: RE: How to know if a Lotus Script dynamic array has been initialized ?
An easy workaround is - set a counter to 0 and incriment this whenever the array is initialized. Check for the counter before using the array.
If g_EmailIdsCount > 0 Then
'arrayunique will throw error if the array is not initialized
resultArrEmail = Arrayunique(g_aryEmailIds,5)
Call gemail.ReplaceItemValue(“SendTo”, resultArrEmail)
End If