My question is in regards to scope and performance. I'd like to know when is the right time to use script libraries vs. global form scripts vs form events. I want to use scripts in the places that make the most sense, but also make don't have a negative impact on performance. I have never been able to find any guidelines on this type of thing.
To be honest, it's mostly a matter of style.
If it's something that is a base unit (something that might be useful in more than one place, either in the database or in more than one database), I put it in a Script Library.
If it's something that has impact only to a particular form, but may be used in more than one place on the form, I make it a global reference.
If it's something that will be used by a particular piece of code on a form, but nowhere else on the form, I put it in the form's code.
Within each piece of code, I try to declare my variables as specifically as I can (in the subroutines vs. the global declarations, for instance), unless the same variable is going to be passed around from subroutine to subroutine, because LotusScript (like VB) is occasionally "leaky" when trying to clean these references up, plus it's quicker. And. let's face it, code running on a form usually runs a couple of times, whereas code running in an agent may run hundreds of thousands of times before the memory buffer is cleared.