Blogs

  • Browse Blogs
  • My Blog
  • My Updates

Tags Help

  • View as cloud  | list

Similar Entries

photo

LS Version @WebDBNam...

Blog:  .Domino Frame...
Peter Presnell
Updated 
No Ratings 0     Comments 3
photo

Notes becomes strang...

Blog:  Jan Schulz
Jan Schulz
Updated 
No Ratings 0     Comments 3
photo

Fun with events

Blog:  Jan Schulz
Jan Schulz
Updated 
No Ratings 0     No Comments 0
photo

Quick tip: shorthand...

Blog:  Yellow is the...
Tim Tripcony
Updated 
No Ratings 0     Comments 2
photo

Reducing Programming...

Blog:  .Domino Frame...
Peter Presnell
Updated 
No Ratings 0     Comments 2

TexasSwede

Blog Authors:  Karl-Henry Martinsson  

Previous |  Main  | Next

SNTT: Lists - the forgotten gem in Lotusscript

Karl-Henry Martinsson  |    |  Tags:  programming show-and-tell-thursday sntt lotusscript  |  Comments (2)
OK, I know it is Friday already, but here is my Show-n-Tell-Thursday entry...

Lists are a data type that I don't think is used enough. Many Notes developers, even some that been programming in the environment for years, don't use this very powerful feature. In previous years, Bill Buchan have been talking about lists in some of his Lotussphere sessions, and when asking how many in the audience that used lists, less than 10% raised their hands.

So what are lists? They are a data type, similar to an array, but instead of using a numeric index, it uses a string as index, or tag as it is called.

This makes it easy to address items in the list, check if they exists, etc.

Here is a simple example:

Dim age List as Integer

Dim name as String

age( "karl" ) = 38

age( "erik" ) = 7

name = InputBox$( "Enter name:" )

If IsElement(age(Lcase(name))) = True Then

MsgBox name & " is " & age(lcase(name)) & " years old."

Else

MsgBox name & " does not occur in the list."

End If

This code define a list of integers, containing the age of two people. When a name is entered in the input box, IsElement is used to check if an item with that name is found in the list. If it is, the age is displayed, if not another message is displayed, saying that the name was not found.

Note that the list tag (name in this case) is case sensitive! 

To loop through a list and display all the values, use ForAll. Here is an example where we loop thorugh all the entries and display their list tags as well as the values:

Dim age List As Integer
age( "Karl" ) = 38
age( "Erik" ) = 7
Forall a In age
Msgbox Listtag(a) & " is " & a & " years old."
End Forall

Some of the things I use lists for are web agents, where I parse the URL passed for parameters, and build a list of them. Then it is very easy to write code that check for parameters and get the value if they exist.

I wrote an article about lists for The View, published in November/December 2006. You can find more details and examples there.

Comments

1 Chris Toohey      Permalink A hidden gem indeed - I'm using lists to evaluate stored formula strings against documents collections based on key-comparisons - and the results that I'm seeing are amazing!

2 Karl-Henry Martinsson      Permalink What is really cool is when you build a list of classes, then you can create a nice data structure and address it by name.


Previous |  Main  | Next
Skip to main content link. Accesskey S
IBM Lotus Connections Help Tools About

Tags

A tag is a keyword that is used to categorize an entry. To view the entries with a particular tag, click a tag name or enter a tag in the box.
The tag cloud indicates the frequency of tag use. Popular tags appear darkest. The slider control adjusts how many tags are displayed in the tag cloud.