HPlogo ALLBASE/SQL Pascal Application Programming Guide: HP 3000 MPE/iX Computer Systems > Chapter 2 Using the ALLBASE/SQL Pascal Preprocessor

The Preprocessor and Program Development

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Pascal ALLBASE/SQL application programs have the same stages of development as any application program. They originate as Pascal source code files that are subsequently compiled with the Pascal compiler and linked by the system linker to create an executable program file. The development of ALLBASE/SQL programs, however, requires that you preprocess those portions of the program that contain SQL commands before compilation.

In the case illustrated in Figure 2-1 “Developing a Pascal ALLBASE/SQL Program”, the ALLBASE/SQL Pascal program consists of one source file and, optionally, one or more include files. The preprocessor merges any user include file into the source program, and preprocesses it. The result is a modified source code file and several preprocessor-generated include files. These preprocessor include files contain all of the definitions of variables used by any Pascal statements in the modified source code file. These two files are then compiled to produce an object code file, and linked to produce an executable program file, in the same manner as any other Pascal program.

Figure 2-1 Developing a Pascal ALLBASE/SQL Program

[Developing a Pascal ALLBASE/SQL Program]
NOTE: The parts of Figure 2-2 “Developing a Pascal ALLBASE/SQL Program with Subprograms” shown with diagonal lines show subprogram processing.

In other cases, the ALLBASE/SQL application program might consist of a main program and one or more subprograms in separate files. In these cases, only source files containing embedded SQL code need to be preprocessed, as illustrated in Figure 2-2. However, each program file which contains embedded SQL code must be preprocessed and compiled before the next program file is preprocessed. Separately preprocessed program files that are not immediately compiled will write over each other's preprocessor created include files and consequently create an error when compiled. You invoke the Pascal compiler as many times as necessary to create the desired number of object code modules. The files output by the Pascal preprocessor are treated just as any other compiler input files at compile time.

Figure 2-2 Developing a Pascal ALLBASE/SQL Program with Subprograms

[Developing a Pascal ALLBASE/SQL Program with Subprograms]

During any invocation, the Pascal preprocessor can access only one DBEnvironment. Therefore programs that access multiple DBEnvironments must be divided into multiple subprograms, each of which accesses only one DBEnvironment. Subprograms that access the same DBEnvironment may be preprocessed and compiled separately or jointly. The preprocessor stores a module in each DBEnvironment accessed for each preprocessor invocation.

You can also create separate subprograms that all access the same DBEnvironment. Each subprogram may again be preprocessed and compiled separately or jointly. In this case, the preprocessor stores multiple modules in one DBEnvironment. Each module consists of sections with each section representing one SQL command.

The criteria governing the division of an application program into subprograms is very application-dependent. As in the development of any application program, factors such as program size, program complexity, expected recompilation frequency, and number of programmers affect how a program is subdivided. In the case of ALLBASE/SQL Pascal application programs, the only additional factors are as follows:

  • All code containing embedded SQL commands must be preprocessed.

  • The preprocessor can access only one DBEnvironment at a time.

  • Each separately preprocessed program or subprogram that accesses the same DBEnvironment must have a unique OwnerName.ModuleName. The module name defaults to the program or subroutine name if the user does not provide one. The owner name defaults to the user's logon if the user does not provide one.

  • The preprocessor can process only one file per invocation.

  • Each preprocessed subprogram must be compiled before the next subprogram is preprocessed.

  • User include files cannot contain duplicate host variable type declarations sections.