Declares a value for a substitution variable within the body of the report (rather than using ASK).
#DEFINE substitution_variable value
Variable to use as the substitution variable. The substitution variable is used to substitute any command, argument, or part of a SQL statement at compile time.
#DEFINE is useful for specifying constants such as column locations, printer fonts, or any number or string that is used in several locations in the program. When the value of the number or string must be changed, you need only change your #DEFINE command. All references to that variable change automatically, which makes modifying programs much simpler.
If ASK is used to obtain the value of a substitution variable that has already been defined, ASK uses the previous value and the user is not prompted. This gives you the flexibility of being able to predefine some variables and not others. When the report runs, ASK requests values for only those variables that have not had a value assigned.
You can use #DEFINE commands inside an include file. This is a method of gathering commonly used declarations into one place, and reusing them for more than one report.
The value in the #DEFINE command can have embedded spaces, and needs no enclosing quotes. The entire string is used as is.
The #DEFINE command cannot be broken across program lines.
The following code defines several constants:
#define page_width 8.5 #define page_depth 11 #define light LS^10027 #define bold LS^03112 #define col1 1 #define col2 27 #define col3 54 #define order_by state, county, city, co_name
The following excerpt from a report uses the preceding definitions:
begin-setup declare-printer contacts type=hp paper-size=({page_width}, {page_depth}) end-declare end-setup
begin-heading 5 print 'Company Contacts' (1,1) center print 'Sort: {order_by}' (2,1) center print 'Company' (4,{col1}) print 'Contact' (4,{col2}) print 'Phone' (4,{col3}) end-heading
begin-procedure main begin-select company (1,{col1}) print '{bold}' (0,{col2} ! Print contact in boldface. contact () print '{light}' () ! Back to lightface. phone (0,{col3}) ! Note:There must be enough next-listing ! space between col2 from customers ! and col3 for both order by {order_by} ! font changes and the end-select ! contact field. end-procedure