Search DominoPower's 11,420 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
PROGRAMMING POWER
Tips and tricks in LotusScript
By Mick Moignard

Long before I was a Lotus Notes geek, I was employed as a mainframe programmer. I wrote applications in PL/I (Programming Language One), which ran on IBM's MVS (Multiple Virtual System) and used database systems like IMS (Infrastructure Managed Services) and DB2. In fact that's where I learned the art of programming, and most of what I learned then about how to go about writing programs is still valid when writing LotusScript code for Notes now. There are, for sure, some differences. The object oriented access to Notes is different, and the data types are certainly somewhat different. So I thought that in this article I'd present a small collection of LotusScript programming tips and tricks I've worked out and remembered over the last couple of years and compare them to "the good old days."

Array lookups
Arrays are some of the most useful things in any programming language for keeping track of lookup values, conversions of coded data to human-readable values for presentations, and so on. Notes, unlike many database systems, actually makes use of this with the concept of multivalue fields. I know it calls them lists, but what is stored is actually an array.

One application I did a year or two back was designed to collect, in a Notes database, the error reports that came from printers around the organization so that we could do an analysis of the different sorts of errors and exceptions that occurred. The printer messages contained the printer name and a code that indicated what the problem was. In my application I had a couple of profile documents, one that held a table of printers and their physical location data, and the other which had a three column table that translated the error code both to text and to a severity code. These tables were actually implemented as multivalue text fields, and as they were static data maintained by an administrator, I felt that the only validation necessary was to ensure that the multivalue fields on each document had the same number of entries.

Back in the past, to look up items in an array, the usual method was to loop around the array with PL/1's equivalent of a for/next loop until we found a value that matched, or if the array was big, to do a binary search on it. It wasn't difficult code, but it had to be typed and tested every time. LotusScript makes doing this completely redundant with the ArrayGetIndex function, which does all that for you. Consider this code fragment:

index = Arraygetindex(Printerprofdoc.printer_name, doc.subject(0))
If Isnull(index) Then
doc.location = "Not in profile"
doc.printer_site = "Not in profile"
Else
doc.location = Printerprofdoc.printer_location(index)
doc.printer_site = Printerprofdoc.printer_site(index)
End If


1  ·  2  ·  3  ·  4  ·  Next »
Other articles you might like
Home > Lotus Technologies > LotusScript (64 articles)
   When the debugger won't debug hidden code that isn't hidden
   What to do if the LotusScript debugger won't single-step over code
   Little known traps about Lotus Notes fields
Home > Tips & Techniques (102 articles)
   More about Domino log files
   Why your log.nsf might not be purging properly
   A faster way to repair corrupted server files
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
Application development, William Shatner, and the origin of the universe
The (near) future of Sametime, Quickr, Connections, and Symphony
Inside the IBM Innovations lab
Lotusphere 2010: Hot fixes and cool news for Notes, Domino, and LotusLive
Lotusphere 2010: mobility and collaboration
2010: A Lotusphere of change
Five trends for 2010
Latest Lotus Headlines
New Notes/Domino Technotes published about Chile's extended daylight saving time
SnnT: How to prevent Google from listing your Sametime Server
How to send someone an email that shows your calendar availability
"The collection has become invalid"
More XPages onclick event weirdness...
Domino 8.5.1 Fix Pack 1 Interim Fix 1 (8.5.1 FP1 IF1) - DAOS Fixes
Domino Designer 8.5 Tip: Where Working Sets Are Stored
>> Read all the news
More from the ZATZ journals
Computing Unplugged: Make Mafia Wars an offer it can't refuse
David Gewirtz Online: CNN commentary and analysis
OutlookPower: Removing an Office installation that doesn't want to go away
-- Advertisement --

Learn Notes and Domino 8 at your place and pace!
Learn Notes and Domino in your office and/or home! TLCC's highly acclaimed distance learning courses for users, developers, and admins will enhance your career and your resume.

The many included activities and demos will make you a pro! Expert instructor help is a click away.

Click here to try a FREE demo course!!

-- Advertisement --

Struggling with exporting Notes data to spreadsheets? No More!
Try IntelliPRINT, The world's leading Reporting, Dashboards, and Analysis solution for Notes & Domino

  • Don't spend unproductive time maintaining different versions of the same spreadsheet
  • Preserve data integrity and security in multi-user environments
  • Create reports in minutes INSIDE Notes
  • Get freedom from iterative report requests, deliver self-serve capabilities

Experience Reporting, Dashboards, and Analysis INSIDE Notes.

Try IntelliPRINT NOW!

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login