Urgent count the elements in list in lotus script

Hi

I have a list i want to count the elements in list

the list is list1

i want to do it through lotus script i know there are ways in formula

can anyone help me

Subject: urgent count the elements in list in lotus script

Lists in formula are different form lists in LotusScript, more like arrays. So, are you talking about an LS array or a List variable?

Subject: RE: urgent count the elements in list in lotus script

Set item = doc.GetFirstItem( “txtformname” )Forall v In item.Values

			list1 = Split(v, delim)

			

		End Forall

some how i have to compare the value of a field with a string

that field is txtformname which contains many values together i mean its multivalued field

i have to compare its all values with a string

so i thought if i split its values and get count so with a loop i can compare all its values with the string

Subject: RE: urgent count the elements in list in lotus script

’ 1. case-sensitive Set item = doc.GetFirstItem( “txtformname” )

if item.contains(“a string”) then

end if

’ 2. case-insensitive

dim tmp as string

dim i as integer

tmp = lcase$(“String of Interest”)

Set item = doc.GetFirstItem( “txtformname” )

for i = 0 to ubound(item.values)

if lcase$(item.values(i)) = tmp then

'do something

exit for

end if

next i

’ 3. Use ArrayGetIndex() using case-insensitive switch (5)

dim v as variant

dim item as notesitem

Set item = doc.GetFirstItem( “txtformname” )

v = arraygetindex(item.values,“String of Interest”,5)

if not isnull(v) then

end if

’ 4. Use Instr

You can also use Instr() to see if item.text contains your string. However this will turn up false positives if your string happens to occur as part of some other value in the item, for example if you are looking for “Stoli” in an item that contains “stolid”.

Subject: RE: urgent count the elements in list in lotus script

item.Values does already contain an array of all values in the multi-value field. Why are you trying to further split each value into an array?

In fact, if you have a string in a String variable and want to check if this string equals one of the values in txtformname, all you need is

forall v in doc.GetItemValues(“txtformname”)

if (v = stringVariable) then

  ' do something

end if

end forall