The Unofficial Newsletter of Delphi Users - by Robert Vivrette


Picking Global Variables From A List!

by ??? - AISSSoft@aol.com and Robert Vivrette - RobertV@csi.com

From Delphi 3 and up it is a good idea to put all the global variables that you will use in your program (ex isfilesave:Boolean,Username:String) into a record. This is because a lot of times one cannot remember the names of the globals he has declered and the only way to remember the name is to scroll back to the pas where you declared the variable.  However in D3 if you add the variables to a easylly rememberd record. delphi will pop up a listbox with all the
records available to that record and all you have to do is scroll up and down to find the variable that you want!

Editors Note: This is a pretty cool trick... All you need to do is to declare a record type in a globally accessed unit like this:

Followed of course by a variable of that type. Now, whenever you want to use a global variable, all you need to do is type the word "Global" followed by a period, and Delphi will automatically use its code completion feature to show you the fields (global variables) you have defined. Just pick one from the list and hit enter. It also reminds you of the exact type that each variable is... a nice added bonus.

But wait, there is more! If you are using the global variable on the right side of an assignment statement, the list will automatically restrict the list to variables that are type compatible. For example, if you were assigning to a labels caption, only the string variables (Username & DBName) would be in the list.

Keep in mind that this feature will work only with Delphi 3 and 4.