About Me...

NotesRunningLogoRSmall.png

I'm Kathy Brown and I've been an application developer in Lotus Notes/Domino since 2005.

Prior to working in IT, I've had numerous careers including an Investment Analyst and even an Actress (long ago and far away).

And I (try to) love running!

me.jpg

kathy (at) runningnotes (dot) net

On Twitter, kjbrown13

Upcoming Races

Looking 4 Something?

Disclaimer

This is my personal blog. None of the opinions shown here represent those of my employer. In fact, forget I even have an employer. Any examples given here are strictly fictional and hypothetical and it is pure coincidence if they in any way seem like anything in real life.

08/27/2009

Fun with Lists!

Category Lotus Notes Newbies Development Lists
Lotusscript lists, that is. Frequently underutilized by developers (including me), but a very useful tool nonetheless. I had a need recently to loop through some documents, and create a unique list of names from those documents, and then count how many unique names I had. I needed to do it in Lotusscript. I would also need to do something with those names later in my code. Oh, and the number of names would depend on the document collection and how many were actually unique. Addtionally, I had more than one bit of data that I wanted to capture. For this example, we’ll say name and phone number. So, what to do?

Well, I *could* use an array, but not knowing how many names would be added to the array would mean having to ReDim the array, but that’s no fun. So enter Lists! Creating a list is super easy, and you don’t have to know how many items will be in the list. I added a little counter to count the number of items in my list as I added them. Yes, I could have added them, and then looped through afterward and counted them that way, but I actually had some other stuff to do, so did it when I added.

Dim clientList List As String ‘dim the list itself Dim n As Long ‘dim n as long for the counter n = 0 ‘start the count at 0 While Not entry Is Nothing ‘obviously prior code would have dimmed a view entry collection and 'provided a way to loop through it, this part of the code just insures we are acting on an actual entry ‘This next bit checks to see if the item is already in the list and if it is NOT, then increases the counter by 1, 'and adds the entry with column value 5 as the listtag and column value 6 as the value If Not (Iselement(clientList(entry.columnvalues(5)))) Then n = n + 1 clientList (entry.ColumnValues(5)) =entry.columnvalues(6) End If Print Cstr(n) ‘this prints the count of items added to the list ‘This just shows something we can do with the list, such as printing the listtag '(aka column value 5) for all of the entries in the list. Forall clients In clientList Print ListTag(clients) End Forall

ls2html was brought to you by nsftools.com

Pretty easy, huh? Easy to create and easy to use the data. So Lists! Use ‘em!