Progress
Portability Guide


Using Preprocessor Directives

Progress provides a language preprocessor that allows you to write applications that are easy to read, modify, and transport to other operating systems. The preprocessor is a component of the Progress Compiler. Before the Compiler analyzes your source code and creates r-code, the preprocessor examines your source code and performs text substitutions.

You control the preprocessor by placing preprocessor directives throughout your source code. A preprocessor directive is a statement that begins with an ampersand (&) and is meaningful only to the preprocessor.

The preprocessor recognizes a built-in preprocessor constant that identifies the window system where a file is being compiled, called &WINDOW-SYSTEM. The possible values include “MS-WINnn” and “TTY.” You can use this constant to direct the preprocessor to determine which code to run on each window system, as follows:

FORM
  fld1
  fld2
&IF "{&WINDOW-SYSTEM}" = "MS-WIN97" &THEN
  fld3 AT 20
&ELSE
  fld3 AT 15
&ENDIF
   WITH FRAME XYZ. 

The SESSION system handle also has a WINDOW-SYSTEM attribute. Your application can use this to test the current window system while it is running:

IF SESSION:WINDOW-SYSTEM = "MS-WIN97" THEN
                    .
                    .
                    . 

Both the &WINDOW-SYSTEM preprocessor constant and the SESSION handle WINDOW-SYSTEM attribute perform the same basic function. The &WINDOW-SYSTEM preprocessor constant allows you to write code that is conditionally compiled, while the WINDOW-SYSTEM attribute is a run-time function.

The WINDOW-SYSTEM attribute evaluates as follows:

Progress supports an override option that enables applications that require a WINDOW-SYSTEM attribute to return the value of MS-WINDOWS for all Microsoft operating systems. To establish this override capability, define the Window System key in the Startup Section of the current environment, which might be in the registry or an initialization file. If the Window System key is located, the WINDOW-SYSTEM attribute returns the value associated with the Window System key on all platforms.

You can also specify offsets and ROW and COLUMN specifications using preprocessor constants, then define the constants separately for different environments. Progress allows you to specify fractional character units so that you can specify precise locations for objects in a graphical environment. In a character environment, the ROW and COLUMN values are truncated to integer values, as follows:

&IF "{&WINDOW-SYSTEM}" = "TTY" &THEN
&GLOBAL-DEFINE COL3 20
&ELSE
&GLOBAL-DEFINE COL3 15
&ENDIF
FORM
  fld1
  fld2
  fld3 AT {&COL3}
  WITH FRAME XYZ. 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095