LotusScript problem with strings ending in 1

I’ve searched the Lotus 8 discussion database and haven’t seen this mentioned anywhere.

LotusScript appears to be adding a space to any string that ends in the character 1. I’m trying to generate a key to read a view with the following code:

exerciseKeys(0) = memberDoc.Fitness_Team(0)

exerciseKeys(1) = empName.Common

For w = 1 To weekNo

exerciseKeys(2) = "Week " & Cstr(w)

Set exerciseDoc = exerciseList.GetDocumentByKey(exerciseKeys, True)

’ Process record

Next

The record is never found because key(2) is "Week 1 " instead of “Week 1”.

Later in the same code I have this statement:

itmName = “Week” & Cstr(w + 1) & “_Made_Goal”

In this case itmName does NOT have the extra space.

I even tried to get around the problem by creating an array with the week numbers in it (“Week 1”, “Week 2”, etc.). When I view the array in debugger every entry that ends in a 1 has a space following the 1, even though it was coded as a literal without it.

I tried Trim(Cstr(w)) without any difference in the way the script interprets in the runtime mode. I also tried to set another string field to Cstr(w) and then do Left(string, 1). That also fails to remove the space. This appears to be a script interpreter problem.

For now I’m making a copy of the view with a special character after the week number to work around this problem.

Subject: Wow…

…that sounds broken as hell.

Have you tried a FullTrim()?

What about using + instead of & to concatenate strings?

I find it hard to believe that got through testing, but I’d open a Lotus Support ticket ASAP to get that one looked at.

Subject: Of course it sounds broken

It would be broken. Of course, it’s also trivial to test his code as provided and try to reproduce the problem. And when I run his code as provided, there’s no mysterious space after the 1.

Then again, it’s not possible to run the code EXACTLY as he has, because we don’t have the actual database – nor do we know such things as the member Fitness_team on the document or the common name of the employee that are in the earlier part of the key. We don’t even know what weekNo is set to.

I suppose it’s possible that there’s some incredible corner case where some strange control characters processed earlier through the string buffer alter the behavior of the string append function later, but a bug in LS that simply enforced a space after every “1” would probably cause failures in 50 or 60% of Notes applications worldwide.

Color me skeptical, particularly after running his exact code and having it work perfectly.