LotusScript for the VB Developer
So, you’re a VB developer and you need to modify a Notes app without much Notes knowledge? Hopefully you are not just a .Net programmer and have either some experience with VBScript because that will help quite a bit with LotusScript. If so, here are a few tidbits that may lessen your pain as you dig into the code…
- Notes is extremely flexible! (Maybe too flexible?)
If you come from a structured data background, Notes can be a bit disconcerting. Notes documents are designed to mimic a real-world document; you may have a pre-defined structure but, if necessary, you can mark in some other information. If you run across a field in a script that you can’t seem to locate no matter how hard you look, it is quote possible that the field and data were created on-the-fly. Check your document events and shared scripts; chances are you’ll eventually find what you are looking for.
- Beware the variables
If you work in an environment that demands explicit declaration of variables, you may find areas where implicit variable types exist. In Notes, Option Declare (or Option Explicit) must be speified to enforce explicit declarations. Without, you may find a script peppered with Variant types that “just show up.” (And, just in case, LotusScript is not case-sensitive.)
LotusScript will also let you declare multiple variables on a single line, each with a different (or no) datatype. If you run across a scenario where the data type appears not to be defined, there may be two possibilities:
- The variable is implicitly cast as a Variant (Object) type or,
- The variable may be cast using shorthand declaration (e.g., aString$, anInt%, etc.):
Keyword Suffix Data Type Range Integer % Integer -32,768 to 32,767 Long & Integer -2,147483,648 to 2,147483,647 Single ! Floating-point -3.402823E38 to 3.402823E38 Double # Floating-point -1.7976931348623158E308 to 1.7976931348623158E308 Currency @ Currency -922,337,203,685,477.5808 internal format to 922,337,203,685,477.5807 String $ String ~16k characters Variant NONE Can contain any of the preceding, plus Date/Time, Boolean,and objects
- LotusNotes documents and mail are tightly integrated
Need to send an email? There is no “special” e-mail function in Notes because it is inherent in the design. Simply tack a “To” and “From” to a document (at a minimum), invoke “Send” and, voila, you’ve sent an e-mail (assuming your mail is configured correctly). OK, maybe it’s not just that easy, but pretty close so, if you see a document with this going on, it’s becoming mail.
- A lot of (if not all) fields have indices
When is a checkbox not a checkbox? When it’s in Notes! Don’t expect to find a “checked” property available to your script. Instead, a checkbox may have multiple values set and, if checked, you will need to check the value of the control. If multiple options are selected, they will be accessible by index (e.g., if a checkbox “LightColors” has options “Red”, “Yellow”, and “Green”, and each is selected, LightColors(0) will be “Red”, LightColors(1) will be “Yellow, etc.) if NO options are selected, index 0 will evaluate to an empty string (“”).
Textboxes, too, may have indices. Index 0 will return the text in the box. If the textbox is multi-line, the indices will refer to each line, as defined by the delimiter (space, new line, comma, semi-colon or a blank line).
More to come…