Manage Learn to apply best practices and optimize your operations.

Extract Items In An Array

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
Forall i In ID_Item.values
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)


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

Review for: Extract Items in an Array
By: Jeff Cassens
Company: SOLARCOM, Inc.
There are ways to do this much more efficiently. For instance, you don't need
to count the items in an array, you just use UBound(). And PLEASE stay away
from GOTOs!

Here is my suggestion for a function that takes a passed array as a variant and
a text string to pluck out:

Function Extract(aryOld As Variant, txtReplace As String) As Variant

Dim aryNew() As String 'Placeholder for returned version
Dim i, j As Integer 'Loop counters

j = 0 'initialize new loop counter
For i = 0 To Ubound(aryOld) 'go through passed array
If aryOld(i) <> txtReplace Then 'if not skipped value
Redim Preserve aryNew(j + 1)' expand new array by one
aryNew(j) = aryOld(i) ' put value in last place
j = j + 1 ' add one to j for next value
End If

Extract = aryNew 'Return placeholder array as variant
End Function
Just my $.02,
Jeff Cassens
CLP Principal Application Developer (R5)
This was last published in November 2000

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...