Subject: Function To Replace Array Element in LotusScript?
do not know if this works but I had it stored in my code db
Public Function RemoveEntries( ValuesToRemove, arrayToRemoveFrom, compMethod As Integer ) As Variant
'=== Removes entries from arrayToRemoveFrom whos value is in the ValuesToRemove array
'=== Returns a variant that contains an array value
'=== ValuesToRemove and arrayToRemoveFrom can be either a Variant that contains an array
'=== or an Array ( this is the reason there is no data type defined )
'=== compMethod is used as defined in the StrCompare function;
’ A number designating the comparison method. Use 0 for case-sensitive and pitch-sensitive,
’ 1 for case-insensitive and pitch-sensitive, 4 for case-sensitive and pitch-insensitive,
’ 5 for case-insensitive and pitch-insensitive. Use 2 to specify string comparison in
’ the platform’s collation sequence. If 2 is specified, strings are compared bit-wise.
’ … see help for details
If Not Isarray( arrayToRemoveFrom ) Then Exit Function
'— Store this return value in a variant to it can be converted into an array
Dim IndexList As Variant
Dim newList As Variant
Dim i As Integer
Dim checkList List As Integer
Dim ctr As Long
Dim lowVal As Integer, highVal As Integer
Dim numToRemove As Integer
Dim foundFlag As Integer
lowVal = Lbound( arrayToRemoveFrom )
highVal = Ubound( arrayToRemoveFrom )
'— Initialize array, we are about to use Redim preserve to incrment array size
Redim newList( 0 )
'— Loop through entries
ctr = 0
For i = lowVal To highVal
'— If this index position is not in the checkList then
foundFlag = False
'— Loop through vals to remove and if there is a match flag it
Forall aValueToRemove In ValuesToRemove
If Strcompare( aValueToRemove, arrayToRemoveFrom( i ), compMethod ) = 0 Then
foundFlag = True
Exit Forall
End If
End Forall
'— If not found in list of entries to remove, then add to new array
If Not foundFlag Then
'— Increment array, preserving existing value
Redim Preserve newList( ctr )
'— Set value to current value
newList( ctr ) = arrayToRemoveFrom( i )
'— increment counter for next time 'round
ctr = ctr + 1
End If
Next
'— Return value
RemoveEntries = newList
End Function