HELP! -- Why does LotusScript sometimes return item names in caps but they are lower case in doc?

Hi

For some reason two items’ names are converted to uppercase when I check what the debugger lists for NotesDocument.Items.

On the form that created the document, they are in lower case.

I’ve searched the entire design and they are not listed anywhere in uppercase.

If I look in the field list for the form they are in lower case.

In the document design properties they are listed in lower case.

If I delete the items and recreate them by open the document and resave it, they are listed in lower case but LotusScript still shows them in caps.

If I delete the items, change the case on the form, open the document and resave it, they are listed in lower case but LotusScript still shows them in caps.

This is a real problem for me if field name case is randomly convert to upper case because I test for item names.

HELP!!

TIA

Mohib

Subject: HELP!! – Why does LotusScript sometimes return item names in caps but they are lower case in doc?

Are you using shorthand item assignment in lotusscript somewhere?

If you assign a value to a doc item using the shorthand method, the item name gets uppercased, since lotusscript converts all member/property names to uppercase.

IE:

set doc=db.createDoc

doc.form=“test form”

doc.SomeField=“test content”

doc.replaceItemValue(“OtherField”,“another test”)

will yield a doc with the items “FORM”, “SOMEFIELD” and “OtherField”.

This is something you need to be aware of when using shorthand notation for item assignments.

cheers,

Bram

Subject: HELP!! – Why does LotusScript sometimes return item names in caps but they are lower case in doc?

Doug, Bram, Benpoole for all the responses. Let me respond to all here:

Let me prefix my comments with these points:

This only happens with 2 of my item names and one default item name (Form).

Both are used hundreads of other item names in my code and forms in thousands of places: in lotus script, in formulas, in Execute statements, and in lotus script shorthand assignments, etc. etc.

The item name, as listed in the design properties of the documents alway shows them in lower case, no matter what method was used to set the item value last, but when debugging lotus script these 2 names, and only these 2 names, sometimes appear listed in NotesDocument.Items in uppercase and sometimes in lowercase, even if I do nothing with the documents between debugging sessions.

Doug,

I have lots of comparisons that are case sensitve, and lots of comparisons of item names (which don’t need to be case sensitive) all intermixed that why NoCase won’t be suitable.

WRT to field not being on the form, both fields are on the form.

Benpoole,

the problem is not when I get an item it’s when I compare the value in NotesItem.Name. Sometimes NotesItem.Name is uppercase, and at othertimes its lower case.

Bram,

now that’s interesting I didn’t know that, but I use the shorthand method very extensively in thousands of places with hundreds of items and never noticed that, and like I mentioned above, this happens randomly with only 2 item names.

Subject: RE: HELP!! – Why does LotusScript sometimes return item names in caps but they are lower case in doc?

When you look from within the document properties, the field from the form is used to determine case. Loom at the same document from the view and you will see the stored name. As for your comparison, you are going to have to make the comparisons case-insenstive, because you simply won’t be able to control these well enough. I hate to say it, but it is true.

Subject: RE: HELP!! – Why does LotusScript sometimes return item names in caps but they are lower case in doc?

I think you’re right about the NoCase option. I think I’ll need to make string compare routines CompareNoCase and CompareCase each with their own Compare options and when I need to be sure, I’ll push the compare through them.

When you look from within the document

properties, the field from the form is used

to determine case

Not when you look at the properties when in a view – you see the ondisk version of the document. I.e. don’t open the document, select the document in a view and look at the properties.

Try this:

Open a document, edit but don’t save.

Now look at the properties with the form the active window shows your edits in the properites.

Now still don’t save the form, switch to the view and call up the properties and your edits and (computed for display fields) etc are gone and you see the on-disk versoin of the form.

Subject: RE: HELP!! – Why does LotusScript sometimes return item names in caps but they are lower case in doc?

As a followup to BenPoole,

I did some testing and noticed the following:

Only if an item does not exist in a document when you use the shorthand method (to create the itme for the first time) does the name get converted to upper case, as you say.

HOWEVER, and get this:

Once an item is in a document, regardless of how it got there, it keeps its case, regardless of what you do afterwards.

For ex:

If I do:

CrntUnProcessed.Garbage = “garbage lower”

JunkV = CrntUnProcessed.Save(True,False)

The item name becomes UpperCase if Garbage never existed in the document. It shows in upper case even in the documents design properites. It Garbage existed, it retains it’s existing case.

However if I now continue and try:

Call CrntUnProcessed.RemoveItem(“Garbage”)

JunkV = CrntUnProcessed.Save(True,False)

quit the debugger and then do:

Set JunkV = CrntUnProcessed.ReplaceItemValue(“Garbage”,“garbage lower from replace item value”)

JunkV = CrntUnProcessed.Save(True,False)

The item name stays in uppercase, even in the design properties!!!

This is strange.

However my problem is that between debugging sessions, and doing nothing to the document, 2 of my items randomly switch to uppercase in the debugger, even though the design properties show them in lower case.

Subject: RE: HELP!! – Why does LotusScript sometimes return item names in caps but they are lower case in doc?

i>HOWEVER, and get this: Once an item is in a document, regardless of how it
got there, it keeps its case, regardless of what you do afterwards.]

Is this related only to that specific document, or to all documents? My guess
is that it may be using whatever is in the Database Field List (which you get
to use when designing views)?

Oh, and is debugging of the code doing the same as actual execution (ie: no
debugging?)… In the debugger, the lotusscript/object code seems to be
interpreted differently than in usual execution…

cheers,
Bram

Subject: RE: HELP!! – Why does LotusScript sometimes return item names in caps but they are lower case in doc?

It’s specific to that document.

What shows up in the field list in views is not necessarily what goes into a document. It’s as you pointed out earlier vis a vis the short cut method, etc. But once the item’s in the document the case stays the way it went in first, even if you delete it and recreated.

With respect my issue of it randomly converting to upper case, its the same whether I’m debugging or not and when it’s decided to start converting to upper case it does it for all documents (what ever “it” happens to be!) – very weird.

BTW, I meant to say in that post as follow up to “Bram”, sorry about that.

Subject: HELP!! – Why does LotusScript sometimes return item names in caps but they are lower case in doc?

This is a real problem for me if field name case is randomly convert to upper case because I test for item names.

I don’t understand what you mean. Lotusscript isn’t case sensitive with regards item names, so it shouldn’t matter what case they’re in. For example, say I have a form with a field in it called “Field2”. I can access this NotesItem with any of the following, no problem:

Set itm = doc.GetFirstItem(“FIELD2”)

Set itm = doc.GetFirstItem(“fIEld2”)

Set itm = doc.GetFirstItem(“field2”)

… and so on.

Subject: HELP!! – Why does LotusScript sometimes return item names in caps but they are lower case in doc?

Have you tried Option Compare NoCase?

Subject: RE: HELP!! – Why does LotusScript sometimes return item names in caps but they are lower case in doc?

Yes. Use the NoCase option. I don’t know why you don’t like that suggestion.

Anyway, the cause is that the field is not on the form. I have noticed the pattern – if you save a field that is not on the form, you get a field named in all uppercase letters. The same is not true if you are using formulas. Are you using LScript sometimes and @Formulas other times? Also, if you save a back-end document, the form does not apply, obviously.

Subject: RE: HELP!! – Why does LotusScript sometimes return item names in caps but they are lower case in doc?

Thanks for your response.

Good idea, but it won’t work because I’ve got other string comparing that’s case sensitive.

Funny thing about this problem is that it’s totally random and its conconsistent. Right after I made the post it stopped happening I went for a coffee, came back, and it’s started again!!

I quit Notes and restarted and it’s still uppercase.

Always the same 2 field names (actually 3 – I just noticed Form sometimes comes in as FORM which I hadn’t payed attention to)