Contact TLCC

New Array function in Notes Domino 6

Date tip published:11/03/2003
Description:Notes Domino 6 has a new LotusScript function to remove duplicate entries from an array. This function, ArrayUnique, will return a new array with any duplicate values stripped out. An optional parameter can define if the search for duplicates is case sensitive or case insensitive. Another nice array feature (and this one was in R5) is FullTrim. This function takes an array as input and returns an array that has no empty members. Read this tip for more information on these two array functions!


To learn more about To learn more about using LotusScript in Notes Domino 6 use the following links:

Notes Domino 6 Application Development Update
Notes Domino 6 LotusScript Package



ArrayUnique Function


ArrayUnique will take an array as input and return a new array with all duplicate entries removed.

The syntax of ArrayUnique is:

ArrayUnique(sourceArray [,compMethod ])

The first parameter is the input array. This can be an array of any type but it has to be one dimensional. It also can not be:

  • a list
  • an array that is not initialized
  • an array of classes
  • an array of NotesDocuments
  • an array containing arrays as the elements
  • an array that contains nothing as an element

The second parameter is an integer value of either 0,1,4 or 5. This value determines how the values in the array are compared. The default is zero, which means that the compare will be case and pitch sensitive.

NumberComparison Mode
0case sensitive, pitch sensitive
1case insensitive, pitch sensitive
4case sensitive, pitch insensitive
5case insensitive, pitch insensitive

This function returns a new array. You can not assign returned value to the same variable holding the sourceArray. Create a variant to hold the returned array since you will not know the actual size.

If Array1 contains:
Red
red
Green
Blue
green

Then ArrayUnique will return the following:
FunctionReturned value
ArrayUnique(Array1)RedredGreenBluegreen

FunctionReturned value
ArrayUnique(Array1,1)RedGreenBlue


Below is a simple use of the ArrayUnique function.

'Create the source array
Dim array1(0 To 4) As String
array1(0) = "Red"
array1(1) = "red"
array1(2) = "Green"
array1(3) = "Blue"
array1(4) = "green"
'Declare a variant to hold the returned value
Dim array2 As Variant
'Trim the duplicate entries, case insensitive used here
array2 = Arrayunique(array1,1)
'Display the new array
Forall a In array2
msg = msg + a + Chr(13)
End Forall
Msgbox msg






FullTrim Function

The FullTrim function can take an array and remove any empty entries. It will also work on a string. If you pass in a string it will remove any leading and trailing spaces as well as any duplicate spaces. When used with a string it works just like the @Trim function.

The syntax of ArrayUnique is:

FullTrim(sourceArray) or FullTrim(sourceString)

This function returns variant containing the new array or string depending on what was passed in as input. You can not assign returned value to the same variable holding the sourceArray. Create a variant to hold the returned array since you will not know the actual size.

If array1 contains:
"Red""""Green"

Then FullTrim will return the following:
FunctionReturned value
FullTrim(Array1)"Red""Green"


Below is a simple use of the FullTrim function.

'Create the source array
Dim array1(0 To 4) As String
array1(0) = "Red"
array1(1) = ""
array1(2) = "Green"
'Declare a variant to hold the returned value
Dim array2 As Variant
'Use fulltrim to remove the empty entry
array2 = FullTrim(array1)
'Display the new array
Forall a In array2
msg = msg + a + Chr(13)
End Forall
Msgbox msg