CL programming is a flexible tool allowing you to perform a variety of operations. Each of the following uses is described in greater detail in individual sections later in this chapter. In general, you can:
PGM
DCL &C *LGL
DCL &A *DEC VALUE(22)
DCL &B *CHAR VALUE(ABCDE)
*
*
*
CHGVAR &A (&A + 30)
*
*
*
IF (&A < 50) THEN(CHGVAR &C '1')
*
DSPLIB ('Q' || &B)
*
IF (%SST(&B 5 1)=E) THEN(CHGVAR &A 12)
*
*
*
ENDPGM
PGM
MONMSG MSGID(CPF0001) EXEC(GOTO ERROR)
CALL PROGA
CALL PROGB
RETURN
ERROR: SNDPGMMSG MSG('A CALL command failed') MSGTYPE(*ESCAPE)
ENDPGM
Used as a controlling procedure, a CL procedure can call procedures written in other languages. The following illustration shows how control can be passed between a CL procedure and RPG IV* and ILE COBOL procedures in an application. To use the application, a work station user would request program A, which controls the entire application. The illustration shows: The preceding example shows a single bound program (PGMA) that is called using the CALL command with PGMA. PGMA consists of:
The procedures can be created as indicated in the following example. You can enter source for procedures in separate source members.
CRTCLMOD PGMA CRTRPGMOD PGMB CRTRPGMOD PGMC CRTCLMOD PGMD CRTCBLMOD PGME CRTCLMOD PGMF CRTPGM PGM(PGMA) + MODULE(PGMA PGMB PGMC PGMD PGME PGMF) + ENTMOD(*FIRST)
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.