Progress
Programming
Handbook
Example Using &GLOBAL-DEFINE
After you define a preprocessor name, you can reference it within your source code. Wherever a reference appears, the preprocessor substitutes the string of characters that you defined:
In this example, MAX-EXPENSE is the preprocessor name. Once it is defined, you can reference MAX-EXPENSE from anywhere within your compilation unit (including internal procedures and include files). A reference to a preprocessor name is specified in the form {&preprocessor–name}. (For more information on referencing preprocessor names, see the "Referencing Preprocessor Names" section.) Wherever you reference MAX-EXPENSE in your source code, Progress substitutes the text “5000” at compile time. For example, your source code might contain a line like this:
Before the Compiler analyzes your source code, the preprocessor performs the text substitution. The line of code that the Progress Compiler analyzes and compiles is as follows:
You can see how the preprocessor makes your source code easier to maintain. A preprocessor name like MAX-EXPENSE might be referenced many times in your source code. You only have to change one line of code (the definition of MAX-EXPENSE) to change the value of all of the references. In addition, you can see how preprocessor references make your code easier to read: {&MAX-EXPENSE} is more readable and understandable than 5000. Note that the characters in the name MAX-EXPENSE are all uppercase; this is not required, but it makes your source code more readable. Preprocessor names are case insensitive.
If you want to use a preprocessor name as a text string within an application, you must put quotes around it:
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |