• Browse Blogs
  • My Blog
  • My Updates

+Tags Get help with tags?

  • View as cloud  | list

+ Similar Entries

photo

Implementing getItem...

Blog:  Beyond The Ye...
Peter Presnell
Updated 
No RatingsRatings 0     No CommentsComments 0
photo

How to Add Spaces an...

Blog:  Beyond The Ye...
Peter Presnell
Updated 
No RatingsRatings 0     CommentsComments 1
photo

Bringing The Power O...

Blog:  Beyond The Ye...
Peter Presnell
Updated 
No RatingsRatings 0     No CommentsComments 0
photo

8.5.1 UNFAIL - Part ...

Blog:  Erik Brooks
Erik Brooks
Updated 
RatingsRatings 2     No CommentsComments 0
photo

8.5.1 UN-FAIL! The F...

Blog:  Erik Brooks
Erik Brooks
Updated 
No RatingsRatings 0     CommentsComments 6

+ Blog Authors  

Simple but effective code

Karl-Henry Martinsson |   | Tags:  development lotusscript | Comments (0)  |  Visits (475)

The other day I was writing some code where I had to check a value against a list of potential values. I was importing a file as XML, and checking a number of transactions, each in their own node. If the Trans-ID tag had one of several values, the whole node was supposed to be discarded and not used.
I am sure many already use this method, but hopefully someone will learn something new.
In my example below, I am reading a field in a Notes document instead of data from an XML file, but the principle is the same:

tranType = Ucase(doc.GetItemValue("txn-type"))
If Instr("PD;DR;RP;NSFNF;RD;CRT;RCT;VCK;TPD;RCK;", tranType & ";") Then

End If

What I do is to use Instr() to check a string (the first argument) for the presence of a particular string (the second argument). To make sure I don't get any false matches, I add a semicolon to the end of the tranType as well as use the same character to separate the values in the first argument.

The Instr() function returns the position of the string found (1 or higher if found, 0 if not found). Since 0 is "False" and everything else is "True", if the tranType string is found, a value greater than 0 is returned, which is considered "True".


This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.
No RatingsRatings 0

Comments (0)

There are no comments to display Add a Comment Add a Comment

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