Search DominoPower's 11,441 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
Learn Domino Designer 8.5 for free
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
Latest Lotus Headlines
Xpages not loading? JVM errors? - Solution
How to implement an iCalendar feed into your Notes calendar with XPages
DWA Hotfixes for Domino 8.5.1FP1 - A Gotcha
IBM Adds DB2 to Lotus Foundations SMB Package
SNTT : XPages onclick Ghosts in the machine
Ports used by Lotus Sametime 8.5 servers
Exploring a Domino Date Bug
>> Read all the news
More from the ZATZ journals
Computing Unplugged: The iPad defenders have spoken
David Gewirtz Online: CNN commentary and analysis
OutlookPower: More about disappearing text
-- Advertisement --

Find unused Lotus Notes groups and clean up your address book
Have you ever wanted to get rid of old Lotus Notes groups that were cluttering up your address book, but you weren't sure if they were used? Find Unused Groups can help.

Find Unused Groups will check your ACL, mail, multi purpose and server groups to help you determine if they are used, and who uses them.

Learn how to easily clean up your address book.

-- Advertisement --

Integrate your Notes Applications with Microsoft Office and Symphony
Integra for Notes Integrates Microsoft Office and/or IBM Lotus Symphony
Requires NO change to the design of the appliation or Installations of DLL's and EXE's
  • Integra is a ready to use solution, enhance static reports with Excel data analysis, pivot tables, macros
  • User friendly aproach, using a point and click access to features
  • Reports from any Lotus Notes databases
  • Runs reports through a Notes client, web browser and scheduled basis
  • Allows use of LotusScript for advanced data manipulation
  • Enables self service reporting capabilities to end-users


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