I am using several variables which have the same value all over the database in several form-events, view-events, actions and agents.Where can I create such variable, so that they are available in alle the design-elements in the database?
I am using Lotus Script. The variables are for instance two several db-names, the servername.
Subject: Declaring variable when opening a dabatase
A “global” variable with the scope you require needs to be stored on-disk somewhere rather than in memory: that’s the only way your script is going to consistently get at it.
The obvious choice is the Notes ini file: you can read and write to the environment via the relevant NotesSession methods. You may want to do the initial “write” in the database’s Postopen event.
Alternatively, if you don’t mind the overhead, you can write to a document within your database: beware profile documents, as these get cached (this may or may not be an issue, depending on the nature of your code).
Subject: RE: Declaring variable when opening a dabatase
Thanks for your suggestions.I think I had a sort a blackout. For I already use profiledocuments for several issues. The variables I need here are constant, so I could write them in a profiledocument.
If the variables are persistent, the Notes.ini or a document (profile if caching isn’t a problem) is the place to get it from. You could load it in the Postopen event.My suggestion: Do not use a bunch of global variables, use ONE object instead. It is a bit of overhead to get there, but it pays of. The object could be global or local… and the object would shield the code from where it gets it’s values from. OO in LotusScript is possible (but a pain). Give it a shot.