Chapter 2 Variables, Constants,
and Data Types
This chapter describes a variety of strategies for managing data storage that enhance different aspects of macro performance:
- Using constants, variables, or structured groups of variables instead of literal values in code. This technique allows you to make single-point changes, and it makes code easier to read, modify, and debug.
- Specifying the parts of a program where specific data is available by defining the scope of the data. This technique reduces the number of procedures from which data can be manipulated and therefore reduces both the possibility that the data can be corrupted and the number of places you must look for the cause of a particular problem.
- Specifying the length of time to keep data in a variable or constant by defining the lifetime of the data. This technique prevents unexpected reinitialization of variables and allows retention of a variable's value between calls to a procedure.
- Specifying the amount of space to allocate in memory for the data and how to organize the data by declaring the data type. This technique makes your macros use less memory and run faster.
- Grouping related data together by creating an array or user-defined data type. Grouping data makes it easier to work with many related variables at once. User-defined types can also make your code easier to read and modify.
This chapter first discusses the basic data storage concepts mentioned above and then describes in detail how to put these concepts to work in your macros.
Contents
- Variables
- Constants
- Data Types