I know that in an active server page, all includes are processed as if they were part of the original file. There are situations, though, where I would like to have the functionality of Private module-level variables. That is, in one .asp file (which I might include from somewhere else) I need a variable that is global to just that file, but not to the rest of the application, in order to retain a state. Is there a way to do this?
Do I code things in weird ways to always pass a variable in, and create my lookup values using the same function which returns them? For example, I have a "module" which reads various database connection strings from a file into an array (or a collection, I haven't decided yet). There will be another function which returns a connection object to the desired database. So when the .asp file is first included, I want it to read the connection strings once, then after that if the function is called, hand the selected one out.
So how do I retain the array of connection strings without a global variable that might collide with the name of another variable I wish to use somewhere else?
Is the answer to use classes? There's still a global variable to hold the instance of the class.
Do I code things in weird ways to always pass a variable in, and create my lookup values using the same function which returns them? For example, I have a "module" which reads various database connection strings from a file into an array (or a collection, I haven't decided yet). There will be another function which returns a connection object to the desired database. So when the .asp file is first included, I want it to read the connection strings once, then after that if the function is called, hand the selected one out.
So how do I retain the array of connection strings without a global variable that might collide with the name of another variable I wish to use somewhere else?
Is the answer to use classes? There's still a global variable to hold the instance of the class.