Principal Characteristics of Procedure-Based Languages

Procedure-based languages have the following characteristics:
  • Locally scoped variables

    Locally scoped variables are known only within the procedure that defines them. The equivalent of locally scoped variables is the ability to define two variables with the same name that refer to two separate pieces of data. For example, the variable COUNT might have a length of 4 digits in subroutine CALCYR and a length of 6 digits in subroutine CALCDAY.

    Locally scoped variables provide considerable benefit when you write subroutines that are intended to be copied into several different programs. Without locally scoped variables, the programmers must use a scheme such as naming variables based on the name of the subroutine.

  • Automatic variables

    Automatic variables are created whenever a procedure is entered. Automatic variables are destroyed when the procedure is exited.

  • External variables

    External data is one way of sharing data between programs. If program A declares a data item as external, program A is said to export that data item to other programs that want to share that data. Program D can then import the item without programs B and C being involved at all. For more information about imports and exports, see Module Object.

  • Multiple entry points

    OPM COBOL and RPG programs have only a single entry point. In a COBOL program, it is the start of the PROCEDURE DIVISION. In an RPG program, it is the first-page (1P) output. This is the model that OPM supports.

    Procedure-based languages, on the other hand, may have multiple entry points. For example, a C program may consist entirely of subroutines to be used by other programs. These procedures can be exported, along with relevant data if required, for other programs to import.

    In ILE, programs of this type are known as service programs. They can include modules from any of the ILE languages. Service programs are similar in concept to dynamic link libraries (DLLs) in Microsoft Windows. Service programs are discussed in greater detail in Service Program.

  • Frequent calls

    Programs written in procedure-based languages can be very call intensive.