What does Control Language (CL) look like?

What does CL Control Language Look Like?

Quite simply CL is a very structured, very readable scripting language that is easy to write and east to understand.

From simple CL like this:

simple cl program

To more complex CL like this:

Control Language (CL) has a clean, command‑driven structure that’s easy to read once you get used to its style. A CL program is made up of simple, English‑like commands each one performing a specific task on the IBM i system. Most commands follow a verb–noun pattern, such as SNDMSG (Send Message), CPYF (Copy File), or DLTF (Delete File). Parameters are written in a keyword format, making the intent of each line very clear.

A typical CL program begins with a program declaration, followed by a sequence of operational commands. It often includes conditional logic, loops, and calls to RPG or other programs. Here’s a small example to illustrate the look and feel:

PGM
DCL VAR(&COUNT) TYPE(*DEC) LEN(3 0)
CHGVAR VAR(&COUNT) VALUE(0)

LOOP:
CHGVAR VAR(&COUNT) VALUE(&COUNT + 1)
SNDPGMMSG MSG('Loop iteration:' *BCAT &COUNT)

IF COND(&COUNT < 5) THEN(GOTO LOOP)

ENDPGM

This snippet shows the core characteristics of CL:

  • Uppercase commands that describe exactly what they do
  • Keyword‑driven parameters for clarity
  • Structured flow using labels, loops, and conditions
  • A procedural, step‑by‑step feel that mirrors how the IBM i operates

CL is intentionally straight-forward. It's designed to automate tasks, control jobs, manage files, and orchestrate system operations. Once you see a few examples, its style becomes instantly recognizable.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>