Extract Items in an Array (Find and Remove one Item from List)

Author: Tripp W Black

Created: 03/07/2001 at 08:18 PM

 

Category:
Notes Developer Tips
LotusScript

Title: Extract Items in an Array
Author: Thejaswi Gurumurthy, Syven Technologies

There are many situations in which you need to extract
certain values from an item using Lotus Script. A simple
example is a multivalue authors field where you need
to remove an author from the document. The following
SubRoutine will help you remove the value in the item
and also push the values below it upwards so that you
do not have any blank values in the item.

Sub Extract(ID_Item As Notesitem, Value_To_Replace
As String)
'Two Temporary arrays to hold the values
Dim Temp_Arr1() As String
Dim Temp_Arr2() As String

'Get the No of Values in the Item
Dim No_Of_Entries As Integer
No_Of_Entries=0
Forall i In ID_Item.values
No_Of_Entries=No_Of_Entries+1
End Forall

'Now that we know the number of values in the
item, Redim both the arrays
Redim Temp_Arr1(No_Of_Entries-1) As String
Redim Temp_Arr2(No_Of_Entries-2) As String

'Fill all the values in the item into an array
For v=0 To (No_Of_Entries-1)
Temp_Arr1(v) = ID_Item.Values(v)
Next

Count%=0

For v=0 To No_Of_Entries-1
If Temp_Arr1(v) = Value_To_Replace
Then Goto Here
Temp_Arr2(Count%) = Temp_Arr1(v)
Count%=Count%+1
Here:
Next
ID_Item.values = Temp_Arr2
End Sub


previous page