Safekipedia

Control Language

Adapted from Wikipedia · Adventurer experience

The Control Language (CL) is a scripting language made by IBM for the System/38 Control Program Facility and later used in OS/400 (now known as IBM i). It is similar to the IBM Job Control Language.

CL includes special command objects (*CMD) that help run programs and understand what those programs do.

CL can also be used to build CL programs, much like shell scripts. These programs can include features such as choices and variable declaration.

Even though CL is a scripting language for system management, it is mostly used to create programs that are compiled into the system. Using CL scripts directly is very rare.

IBM developers created many commands to help with tasks like compiling programs, backing up data, changing settings, and showing details about system objects. These commands can also be used for user applications.

Commands and programs

In older computer systems like the System/38 and AS/400, programs needed details in a specific order. This was different from systems like Unix and DOS, where details could be given in any order.

To make things easier, developers created something called a command object (*CMD). With this, users could give details in any order, and the system would organize them correctly for the program. Developers could also decide what kind of information was needed, give each detail a name, and provide helpful hints for users.

When a user types a command and presses Enter, the system gathers all the details, organizes them, and sends them to the right program to do its work.

Syntax

The BNF for a simple version of CL command syntax can be described like this:

::= command-name [] []

::= []

::= parameter-name "(" ")" []

::= []

::= CL-name | qualified-CL-name | "*"special-value | generic-CL-name"*" | "'"alphanumeric-value"'" | numeric-value | "X'"hexadecimal-value"'"

Names in CL usually start with a letter and can be up to ten characters long. CL commands do not care about uppercase or lowercase letters.

A common CL command is the Change Program (CHGPGM) command shown here:

CHGPGM MYPGM OPTIMIZE(*FULL) RMVOBS(*BLKORD *PRCORD) TEXT('My program.')

This command gives four details to the program that handles changing other programs. These details are:

  • MYPGM: This is the main detail needed — the name of the program to change.
  • OPTIMIZE(*FULL): This tells the program to fully optimize the other program.
  • RMVOBS(*BLKORD *PRCORD): This asks the program to clear out two types of tracking information.
  • TEXT('My program.'): This changes the description of the program to "My program."

Actually, the system sends many more details than just these four. Any details not given will use their default settings, which usually means "keep it the same."

Prompting

All CL commands start by typing the command and pressing the F4 function key. You can ask for help by typing a ? before the command. This shows a screen with the settings the program needs, with important settings listed first.

If you need to see more settings, press F10. Sometimes, choosing a setting might need more choices, and those will show up as you pick. You can also find out what values are allowed for each setting by moving the cursor to it and pressing F4 again. The system will show you what kind of input is needed and a list of allowed values. If you need to enter a longer name or add extra values, type a plus sign instead of the value.

Command help

When you use commands, you can get help easily. Just move the cursor to a part of the command and press F1 (help). This will show help for that part. To learn more about the whole command and all its pieces, press F1 anywhere on the screen and then press F2 for extra details. This helps you understand what each command does.

Creating new commands

You can create new commands that work like the built-in ones, even for programs that are not part of the system. There are guides to help you learn how to do this.

Later versions of the operating system made it easier to add help screens for these new commands. You can use a simple command to create a basic help screen, and then edit and compile it to connect it to your command.

Finding the right command

There are 2,262 built-in commands in this system, but finding them is easy because of some helpful designs. These designs include Standardized Abbreviations, Command Grouping Menus, and Command Selection.

The system uses standard abbreviations for command names. For example, "change" is always shortened to "CHG", "display" to "DSP", and "work" to "WRK". Words like "program" become "PGM", and "user" become "USR". You can see all possible verbs and subjects by entering the commands GO VERB or GO SUBJECT.

The system also has special menus to group commands together. For example, to see all commands that start with "CHG", you would enter GO CMDCHG. The main menu for these options can be accessed by pressing F4 on an empty command line.

If you only know part of a command, or if you are using software from another company, you can type what you know followed by an asterisk (*) and press enter. The system will show a list of matching commands, and you can choose the one you need. This uses the SLTCMD command behind the scenes. To select all commands in a library, you can use the special value *ALL.

Main article: library list

Sample code

Here’s an example of a CL program. This program helps change dates from one format to another. It can change dates from a special Julian format to a regular month-day-year format, and vice versa.

The program shows the result on the screen.

To use it, you give it two pieces of information: the date you want to change, and the format you want it changed to. For example, if you type CALL PGM(ICVTDATC) PARM('04180' 'M'), it will change the Julian date 04180 to June 28, 2004. The program then displays the result clearly.

Related articles

This article is a child-friendly adaptation of the Wikipedia article on Control Language, available under CC BY-SA 4.0.