Tips Week 2.2 - Trimming Names in LotusScript
If you thought yesterday's tip was simple, check this out.
Have you ever written code of questionable quality like this?
FullName = doc.FirstName(0) if doc.MiddleInitial(0) <> "" then FullName = FullName + doc.MiddleInitial(0) end if FullName = FullName + " " + doc.LastName(0)
I know I've been guilty of coding like this in the past. There must be an easier way to work out full names for users? Well, yeah, you can use FullTrim() to remove duplicate spaces and so the following would do just fine:
FullTrim( doc.FirstName(0)+ " " + doc.MiddleInitial(0) + " " + doc.LastName(0))
More simple tips to follow...
However when you use fulltrim in a scheduled agent on many many documents, this function causes a memory leak
Really? Doh. The following would do too:
Trim( doc.FirstName(0)+ " " + doc.MiddleInitial(0)) + " " + doc.LastName(0)
Really -- in the R5 code stream (fixed in 5.0.9, if I recall correctly).