CA-Clipper 5.2's language introduced many new constructs, built-in functions, and facilities. In this article, I talk about two new concepts, INIT and EXIT procedures, which aren't entirely new, but have not been previously documented.
Clipper's INIT and EXIT procedures provide a way to automatically call one or more subprograms at startup and/or termination of an application without explicity calling the routines. An INIT provides a mechanism for transparently initializing autonomous modular subsystems using Clipper code so developers can gain entry into the startup sequence and perform various processes before control is passed to the application's main entry point. Relegating these initialization module no longer needs to carry one-time-only function calls. The application doesn't need to know the existence of these procedures, nor their name or composition. INIT and EXIT procedures are similar to "prolog" and "epilog" routines found in many diverse languages.
Nothing is new about the need for the INIT/EXIT procedure concept. Netlib (a network library from Pinnacle Publishing) requires a special function N_READY() containing initialization code to be called before any other Netlib function. The main difference is that with INITs, the execution of this initialization code is done automatically and invisibly. The former method requires the programmer to remember to call the special function first.
There are two general types of INITs: Clipper system INITs and user-defined INITs. I show examples of both later. The distinction is that Clipper has certain internal INITs it uses for various initialization tasks. User-defined INITs are primarily for third-party libraries and subsystems.
INIT procedures are used to perform required initialization tasks such as establishing a configuration environment, checking files, or completing network administration functions. INITs and EXITs are best used with third-party libraries and black-box subsystems that need to perform their own setup and/or shutdown processes. Many …