The Control Language (CL) is a scripting language originally created by IBM for the System/38 Control Program Facility and later used in OS/400 (now known as IBM i). It bears a resemblance to the IBM Job Control Language and consists of a set of command objects (*CMD) used to invoke traditional programs or get help on what those programs do. CL can also be used to create CL programs (congruent to shell scripts) where there are additional commands that provide program-like functionality (IF/ELSE, variable declaration, file input, etc.)
Although CL is a scripting language for system administration, it is used mainly to create compiled programs. The use of interpreted CL scripts through the SBMDBJOB command is in fact extremely limited.
While thousands of commands were written by IBM developers to perform system level tasks like compiling programs, backing up data, changing system configurations, displaying system object details, or deleting them, commands are not limited to systems level concerns and can be drafted for user applications as well.
Commands and programs
Parameters (command-line arguments) defined in the main procedures of all traditional System/38 and AS/400 programs are hard coded lists that are made up of parameters that can be numeric, alphanumeric, boolean, etc. and the order in which parameters are passed is important. This is a stark difference from the Unix and DOS worlds where the parameter list in Unix shell scripts and C programs is a set or array of character pointers and more often than not the parameters are not positionally dependent.
The developer's solution to this problem was the command object (*CMD). While the parameters on the command can be specified in any order, each parameter is defined to be passed in a specific order to the program. The programmer can also define, among other things, the parameter's data type, unique parameter name, descriptive text (for prompting), default value (used only if the parameter isn't specified during execution), if the values are restricted to a certain set or range, if the data entered should be changed to another value before calling the program, etc.
At its most basic a command names a single program to call when the user types or prompts the command and presses the Enter key. The command takes all of the parameters typed by the user, and those not typed by the user, and builds a parameter list that it passes to the program when it's called.
Syntax
The BNF for a much simplified CL command syntax would be defined as follows: <CL-command> ::= command-name [<positional-parameter-list>] [<named-parameter-list>]
<positional-parameter-list> ::= <parameter-value> [<positional-parameter-list>]
<named-parameter-list> ::= parameter-name "(" <parameter-element-list> ")" [<named-parameter-list>]
<parameter-element-list> ::= <parameter-value> [<parameter-element-list>]
<parameter-value> ::= CL-name |
qualified-CL-name |
"*"special-value |
generic-CL-name"*" |
"'"alphanumeric-value"'" |
numeric-value |
"X'"hexadecimal-value"'" The items above that end in -name follow object naming conventions which, generally speaking, means the name starts with a letter and can be up to ten characters in length. (CL commands are also case-insensitive.)
A good example of a typical CL command is the Change Program (CHGPGM) command below:
CHGPGM MYPGM OPTIMIZE(*FULL) RMVOBS(*BLKORD *PRCORD) TEXT('My program.')
The above command is passing four parameters to the program that does Change Program processing and they are:
MYPGM: A positional parameter (PGM), and the only required parameter. In this case it's the name of the program being changed. Positional parameters are always first. Once a named parameter appears all parameters that follow must be named parameters. OPTIMIZE(*FULL): A named parameter specifying a single element which is a special value. In this case it will change the program to be fully optimized. RMVOBS(*BLKORD *PRCORD): A named parameter (Remove Observability) specifying multiple special values. In this case telling it to remove two kinds of profiling data from the program. TEXT('My program.'): Another named parameter specifying a single alphanumeric value. In this case it's changing the descriptive text of the program.