Subject: RE: Notes Curiosities: Script in an action button in a form …
the short syntax is not that reliable, which is why I avoid it.
What if you have a fieldname on a document that ends up being used as NotesDocument class property/method in a new release? (I’ve seen this in the past).
Subject: RE: Notes Curiosities: Script in an action button in a form …
Sorry, but I’m not wasting any memory at all cause I naturally have defined all variables as in my client Option Declare is automatically set and I can’t use variables which were not defined before ! I just don’t want to write unnecessary information and waste others space and attention in this forum, so that I don’t repeat it and it wouldn’t change the result of what I have found out. Thats why I have choosen the more convientient and obvious way.
Subject: RE: Notes Curiosities: Script in an action button in a form …
You are wasting memory by using all those implicitly defined variants. Use this syntax instead:
do you realise that notes will allocate memory for all variables, declared and undeclared, used in a script sub/function, so it’s impossible to ‘waste’ memory via the method you do or don’t declare variables - check the variables page on the debugger, every variable youre about to use is listed there, whether you dim’d it or not.
btw. the better choice is to use NotesDocument.HasItem(“fieldname”) before accessing the contents of any field, but that requires more code. it all really depends upon exactly how sure you are that a field will exist on your document at the time the script runs.
sort of like some C programmers and malloc(), you can add extra code to check if the memory allocation worked but if you’re out of memory it’s not like you can do anything about it anyway so why bother.
Subject: Notes Curiosities: Script in an action button in a form …
I would use the debugger to step through the code to see if the Doc-object still exists correctly. If it does - I would check the spelling on the field-name; I noticed that You in the last line used a capital ‘S’ in Subject instead of a small ‘s’ as You did in the previous lines.
Last; I wouldn’t recommend using underscore in fieldnames since I have had many bad experiences with that - for no appearent reason.
Subject: RE: Notes Curiosities: Script in an action button in a form …
I’ve stepped through it with the debugger and the Doc document seemed to exist correctly after the Refresh-command. The case of the first char had also no influence and the _ character is a valid char for fieldnames in Notes.
This example shows that the short command
Set Var=Doc.{fieldname}
and the long command version
Set Var=Doc.GetItemValue(“{fieldname}”)
are inside Notes not(!) the same routines and may deliver, like in this case, different results !