Parts of CL Program

253 Views


Parts of a CL source program

PGM command

PGM PARM(&A)

Optional PGM command beginning the source program and identifying any parameters received.

Declare commands

(DCL, DCLF, COPYRIGHT, DCLPRCOPT)

Mandatory declaration of program or procedure variables when variables are used. 

INCLUDE command

CL command to embed additional CL source commands at compile time.

CL processing commands

CHGVAR, SNDPGMMSG, OVRDBF, DLTF, ...

CL commands used as source statements to manipulate constants or variables (this is a partial list)

Logic control commands

IF, THEN, ELSE, DO, ENDDO, DOWHILE, DOUNTIL, DOFOR, LEAVE, ITERATE, GOTO, SELECT, ENDSELECT, WHEN, OTHERWISE, CALLSUBR, SUBR, RTNSUBR, ENDSUBR

Commands used to control processing within the CL program or procedure.

Built-in functions

%SUBSTRING (%SST), %SWITCH, %BINARY (%BIN), %ADDRESS (%ADDR), %OFFSET (%OFS), %CHECK, %CHECKR, %SCAN, %TRIM, %TRIML, %TRIMR

Built-in functions and operators used in arithmetic, character string, relational or logical expressions.

Program control commands

CALL, RETURN, TFRCTL

CL commands used to pass control to other programs.

Procedure control commands

CALLPRC
CL command to pass control to another procedure.

ENDPGM command

ENDPGM

Optional End Program command.

 

The sequence, combination, and extent of these components are determined by the logic and design of your application.

A CL program or procedure can refer to other objects that must exist when the program or procedure is created, when the command is processed:

  • A display file. 
  • A database file
  • Other programs.
  • Other procedures

To access an object from a CL program, the object must be in the specified library when the command that refers to it runs.

Two types of files are supported in CL procedures and programs: display files and database files.

The Call Program (CALL), Call Bound Procedure (CALLPRC), and Return (RETURN) commands pass control back and forth between programs and procedures.

Post Comments