Blogs

  • Browse Blogs
  • My Blog
  • My Updates

Tags Help

  • View as cloud  | list

Similar Entries

photo

Compile Problem fixe...

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

Sending Designer int...

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

I was wrong: plus is...

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

Should Private Views...

Blog:  A Coder From ...
John Jardin
Updated 
No Ratings 0     Comments 1
photo

Recompile in 8.0.2

Blog:  Urs Meli
Urs Meli
Updated 
No Ratings 0     No Comments 0

TexasSwede

Blog Authors:  Karl-Henry Martinsson  

Previous |  Main  | Next

Simple but effective code

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

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.

Comments

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.