API
@-Formulas
JavaScript
LotusScript
Reg Exp
Web Design
Notes Client
XPages
 
Remove Element From Array
This tip is a pretty quick one. In LotusScript, you can remove an element from an array pretty quickly. Let's say you have an array of Greek letters and you want to remove in the list. You can do it in just one statement. Here's an example:

Dim array(6) As String
array(0) = "Alpha"
array(1) = "Beta"
array(2) = "Gamma"
array(3) = "Delta"
array(4) = "Epsilon"
array(5) = "Zeta"
array(6) = "Eta"

Let's say you want to remove "Delta" from the array and leave yourself with an array of 5 elements:

Dim result As Variant
result = Fulltrim(Arrayreplace(array, "Delta", ""))

After running through this code, the variable result will have 6 elements (element 0 through element 5). The Arrayreplace function replaces the element "Delta" with an empty string, and then the Fulltrim function removes the empty string and shortens the array.

Obviously, if you're hard-coding the array like I am in this example, the replace doesn't make much sense. But if the array is coming from a document, then it makes more sense. For example, something like this:

result = Fulltrim(Arrayreplace(doc.GetItemValue("GreekLetters"), "Delta", ""))

will make a little more sense.