Hi George > >I tend to declare variables at the beginning. Most often, the process is: > >First, I declare the variables I know I'm going to need. > >Second, as I work further, if there are variables I didn't anticipate, I go back and add them to the declaration.
You don't have to. In January 2002 FaxTalk article b>An Independence of Declaration Andy Kramek and Marcia Akins published DeclVar program which allows to declare a variable LOCAL using a hot key.
> Third, and I think most importantly, I initialize the variables as close to when they're first referenced as possible. This prevents another programmer later coming in and using the same variable for another purpose. IOW, if I don't use the variable until the end of the code, that's where I initialize it. If, at a later date, someone else modifies the code and uses that variable earlier, no unknown results will occur. >