Select tidbit from LotusScript
Mon 3 May 2004, 09:07 AMTweet
by Ben Langhinrichs
Eric Wilson mentioned this in the BP forum, and I thought it was worth repeating.
All these years I've been thinking that Case statements in Select blocks can take only single values. But lo! They take lists AND comparison expressions, as shown in this example from Help!Actually, I knew you could use comma delimited lists of values, but I don't think I ever knew you could use ranges or formulas. Pretty awesome!
Single values and comma separated lists and value ranges and comparison expressions are all supported!
Select Case MyValue
Case 0 : Print "0"
Case 1, 2 : Print "1, 2"
Case 3 To 5 : Print "3 TO 5"
Case Is >= 6 : Print ">=6"
Case Else : Print "Else"
Of course, maybe all of you knew this, but if Eric and I didn't, it at least seems worth mentioning in case we are not the only two to have missed this. It seems to have been true since R4, so there shouldn't even be any nasty version dependent worries (if you have figured out how to use LotusScript pre-R4, you don't need need my help. Of course, if you are still using R3, you probably do need some professional help).
Copyright © 2004 Genii Software Ltd.
What has been said:
154.1. jonvon (05/03/2004 11:07 AM)
ya know, this is one of those things that most of us *did* know the first time we looked up how to do a select case statement thingy in lotusscript. i know i did. but i never use it like that. i can't remember ever needing that much power, so to speak.
and every time i reread that help entry (which hardly ever happens, i think its only happened once since my original read, except that now its happened twice ;-), i'm always a little bit astounded.
154.2. Stan Rogers (05/03/2004 05:22 PM)
If only switch() worked the same way....
154.3. Ben Poole (05/04/2004 03:19 AM)
Amen to that Stan...
154.4. Ben Langhinrichs (05/04/2004 04:33 AM)
That would indeed by cool.
154.5. Joe Litton (05/04/2004 06:35 PM)
OK, This will sound either really sensible or really sad. Or maybe it's that my aging brain only remembers things for about 16 seconds. ...ANYWAY... I try and read through the yellow books or random chunks of the help file or read through the object hierarchy charts a little bit each day. It's amazing all the stuff in there! This particular tidbit I did know of, but I literally find something new every week :-)