logo

LotusScript: Using Lists to Help Export Domino Names To Exchange

The other day I mentioned Lists in LotusScript. By coincidence yesterday I found myself using them again.

As part of helping a customer migrate from Domino to Exchange I've written them an agent to export all people from their NAB in to a CSV file, which will then be imported to Exchange's address book.

For reasons I'm not entirely clear on they needed an extra column adding to the CSV called "Initial". For most people this would simply be "1". If the export found a name that had already exported for another user then the "Initial" column needed to increment to 2 - even though there was a "unique ID" column in the CSV - and so on.

So the CSV would look like (ignoring lots of missing columns):

First Name, Last Name, Initial
Jake, Howlett, 1
John, Smith, 1
Karen, Howlett, 1
John, Smith, 2
Joe, Taylor, 1
John, Smith, 3
Karen, Howlett, 2

You get the idea, right?

It turned out doing this was really simple in LotusScript using Lists. Here's how:

Dim NameCount List As Integer
Dim NameFull As String

'this bit inside a loop of all Person documents (doc)
NameFull=LCase(Trim(doc.FirstName(0))+" "+Trim(doc.LastName(0)))
If IsElement(NameCount(NameFull)) Then
 NameCount(NameFull)=NameCount(NameFull)+1
Else
 NameCount(NameFull)=1
End If

Print #fileNum%, doc.FirstName(0)+{,}+doc.LastName(0)+{,}+ CStr(NameCount(NameFull))

In fact it turns out you can simplify that code even further to:

Dim NameCount List As Integer
Dim NameFull As String

'this bit inside a loop of all Person documents (doc)
NameFull=LCase(Trim(doc.FirstName(0))+" "+Trim(doc.LastName(0)))
NameCount(NameFull)=NameCount(NameFull)+1

Print #fileNum%, doc.FirstName(0)+{,}+doc.LastName(0)+{,}+ CStr(NameCount(NameFull))

There you go. LotusScript still standing the test of time...

Comments

  1. You sure that would work? I'm pretty sure that reading a listitem that does not exist yet causes an error. That is, I would always code the first example

      • avatar
      • Jake Howlett
      • Thu 1 Jul 2010 02:14 PM

      I know. Seems strange doesn't it. This is the behaviour you'd expect of JavaScript or some such. You'd expect LotusScript to throw a wobbly over that, but it does work.

      Show the rest of this thread

    • avatar
    • Hora_ce
    • Thu 1 Jul 2010 01:48 PM

    just missing the

    If Not IsElement(NameCount(NameFull)) Then NameCount(NameFull)=0

    after setting the NameFull

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Thu 1 Jul 2010

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content