IBM®
Skip to main content
    Country/region select      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

One thing that comes as an unpleasant surprise to folks who've grown up thinking in ASCII, is the default collation sequence in LotusScript. Because, you see, "A" < "b" < "C". This is nice when you're sorting a list of strings and like the de Veres to be somewhere in the neighborhood of the Dexters, but it has side effects you might not be aware of. For example, you might expect these expressions:

Case "A" To "Z"

If keyID Like "[A-Z][A-Z]###-## Then

to match only uppercase letters. In fact, they match all the lowercase letters also (except "a", which is less than "A").

There are probably a lot of applications out there that use expressions of this sort with the expectation that they're insuring the letters are the right case. It seems so obvious that it should that way, that people might not even think to test it. This is an example, if it were needed, of why one should test the obvious...

If you really want to check for just uppercase or just lowercase, you'll have to do one of two things:

  • List each separate character (keyID Like "[ABCDEFGHIJKLMNOPQRSTUVWXYZ][ABC...")
  • Use Option Compare Binary, which switches the collating sequence to one that groups all the uppercase letters in one bunch, and all the lowercase in another bunch.

Andre Guirard | 18 April 2008 10:59:59 AM ET | Home, Plymouth, MN, USA | Comments (9)


 Comments

1) From A to Z (%$#@!!)
Kendall | 4/18/2008 12:09:16 PM

Since there's a switch to fix this, it doesn't bother me. ;-)

What I dislike about N/D sorting is that view sorting doesn't sort punctuation like ASCII. ;-( I'd love a view property to make it do so (though I'm guessing this would hurt performance for those views). This was a minor issue for me in a project where folks complained about N/D sorting wrong (i.e., differently from all other software they used with the same data) for court case short names (e.g., "Smith, John v. IRS," "Smith Publishing v. IRS," etc.). I forget the combinations that missorted, prompting the complaints.

2) From A to Z (%$#@!!)
Gerald Mengisen | 4/18/2008 1:24:12 PM

"Option Compare Binary" also makes the tags of lists case-sensitive - that's maybe not what you'd want.

3) From A to Z (%$#@!!)
Peter Presnell | 4/18/2008 2:02:29 PM

Another option might be to use:-

If keyID Like "[A-Z][A-Z]###-## And @UpperCase(KeyID) = KeyID Then

4) From A to Z (%$#@!!)
Devin Olson | 4/18/2008 2:13:56 PM

@3) There you go mixing languages again.

I think what you meant to write was something like this:

If (keyID$ Like "[A-Z][A-Z]###-##") And (Ucase(keyID$) = keyID$) Then

5) From A to Z (%$#@!!)
Andre Guirard | 4/18/2008 2:49:34 PM

Gerald, list tags are case-sensitive by default.

6) From A to Z (%$#@!!)
Werner Götz | 4/19/2008 4:03:20 AM

Andre, is this a bug or a feature?

Shouldn't the behaviour respect the "Option Compare Case/NoCase"?

7) From A to Z (%$#@!!)
Werner Götz | 4/19/2008 4:06:11 AM

My question refers to your article not the case-sensitivity of the list tags ...

8) From A to Z (%$#@!!)
harkpabst meliantrop | 4/21/2008 2:51:28 AM

@1) Kendal, I think there actually is a property to force views into sorting like ASCII (on the database level). When I remember right, choosing "Default sort order: Universal" on the design tab, multilingual options section, does take care of that.

9) Bug or feature
Andre Guirard | 4/21/2008 9:18:16 PM

Werner, it's an unexpected feature.

I believe it does respect Option Compare (No)Case; what makes you think it does not? It's just that whether "C" = "c" makes no real difference on whether "c" is between "A" and "Z" -- the answer is yes either way.

10) Inconsistent sorting in client UIs
Scott Leis | 4/22/2008 12:57:29 AM

I've just noticed this collation sequence is applied inconsistently to other areas of Notes/Domino (at least in 8.0.1). See two examples below. I've only tested these when looking at directories on a Domino server. I assume the behaviour is the same for Local, but haven't checked.

E.g. 1: When opening a database in the Notes client, directories in the "Open Application" dialogue-box are sorted in a case insensitive way. I see the sequence tca,TFL,TPT,tptl.

E.g. 2: On the Files tab in Domino Administrator, directory sorting places lower-case letters before upper-case. The same directories from E.g. 1 are now in the sequence tca,tptl,TFL,TPT.

 Add a Comment
Subject:
   
Name:
Comment:  (No HTML - Links will be converted if prefixed http://)
 
Remember Me?     Cancel

Search this blog 

Disclaimer 

    About IBM Privacy Contact