Progress Programming Tips
By Rod Gaither (rdg@worldinfo.com)
PPT-30 Using the preprocessor for readability
Tip:
An oldie but goodie, use the preprocessor to improve readability
when dealing with constant values. In the new world of interfacing to
DLL's, ActiveX's and other external environments where you do not have
control over the parameters, or support for their definition, take the
same approach the 3GL developers use.
For example -
The alignment property of the StatusBar ActiveX control (COMCTL32.OCX)
Panel object takes three possible values.
sbrLeft 0 Left justified and right of bitmap
sbrCenter 1 Centered and right of bitmap
sbrRight 2 Right justified and left of bitmap
Creating an include file for a host of these "Constants" will help
improve the readability of your communications with external
interfaces.
/** Sample preprocessor definitions **/
&GLOBAL-DEFINED sbrLeft 0
&GLOBAL-DEFINED sbrCenter 1
&BLOBAL-DEFINED sbrRight 2
/** Usage example - incomplete fragment only **/
DEF VAR chStatusBar AS COM-HANDLE NO-UNDO.
DEF VAR chMsgPanel AS COM-HANDLE NO-UNDO.
/** Set handle to real control - from loaded control container **/
ASSIGN chStatusBar = chCtrlFrame:CONTROLS:ITEM(1).
/** ITEM(1) ok for 8.2 where only one control per container **/
/** Probably should use the control name instead ?? **/
/** ASSIGN chStatusBar = chCtrlFrame:StatusBar. **/
/** Lookup specific panel, within panels collection, by key **/
ASSIGN chMsgPanel = chStatusBar:Panels('Message').
/** Set the desired alignment **/
ASSIGN chMsgPanel:ALIGNMENT = {&sbrLeft}.
Wisdom:
Premature optimization is a fools errand and denormalizing
database schemas without production data to justify the
denormalization is the work of the devil. (Tom Bascom)
Rod Gaither | rdg@worldinfo.com
World Information Systems | (910) 333-2580 Voice
Greensboro, NC | (910) 333-2584 Fax