Control Language

Last updated
Control Language
Paradigm imperative
Designed by IBM
Developer IBM
First appeared1978;45 years ago (1978)
OS Control Program Facility, IBM i
License Proprietary
Influenced by
Job Control Language, PL/I
Influenced
Windows PowerShell

The Control Language (CL) is a scripting language originally created by IBM for the System/38 Control Program Facility [1] 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.)

Contents

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 [2] 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:

In reality the system will pass many more parameters than the four specified above. This is because the rest of the CHGPGM command's parameters were not specified, so default values will be passed instead. For every parameter on this, aside from the PGM parameter, that default is *SAME, meaning don't change it.

Prompting

All CL commands can be prompted directly from the command line or within CL program source by typing the command and pressing the F4 function key. An OS/400 command can also be prompted by typing a ? before the command. (This is useful in an interactive program which cues a command string, having already filled in some values.)

The system will then present a screen with the set of parameters that the program accepts/requires (required parameters are usually highlighted).

Required parameters are listed first, and parameters with system-supplied default values are listed last of all. To see all parameters, press F10. If any one choice requires further selections, those are cued as you select that value for that parameter, by appearing onscreen.

Prompting is further enhanced to allow the programmer to find what values are valid for each parameter. To do this during prompting the user would move the cursor to the parameter field in question and press F4 again. The system would then display a screen describing the type of input required and an available list of allowable values.

To enter a longer name, or extend the list to allow you to enter extra values, type a plus sign instead of a value. (As when listing names of objects to be saved or restored.)

Command help

Cursor sensitive help can also be provided on commands but it's not required. If help has been provided one can view help for a parameter by moving the cursor to the desired parameter field and pressing F1 (help). To get help for the entire command itself (and all of its parameters) the user would press F1 anywhere on the prompt display and then press F2 (extended help).

Creating new commands

New commands can be created to call non-system programs and they will work exactly like the inbuilt variety. The Command Definition Language is described in the CL Programmer's Guide.

It's a good idea to create help screens for new commands and their parameters. All help screens use panel group objects (*PNLGRP) and these can be created using the UIM language described in the IBM AS/400 Application Display Programming manual.

Beginning in V5R3 of the operating system a new, much simpler method of creating help was added: run the command

 GENCMDDOC CMD(MYLIB/MYCMD) TODIR('/QSYS.LIB/MYLIB.LIB/QPNLSRC.FILE) GENOPT(*UIM)

A skeleton UIM panel group will be automatically generated including all parameters described by the command. The result file can be edited (seu, wdsc, rdi), then compiled with the CRTPNLGRP command, and finally associated with the command via CHGCMD HLPPNLGRP().

Finding the right command

There are 2,262 built-in IBM commands contained in V7R3, [3] but finding them isn't all that hard because of several designs of the system that make life easier. These labor saving designs are: Standardized Abbreviations, Command Grouping Menus, and Command Selection.

Standardized abbreviations

The IBM developers standardized the abbreviations used to create command names. Verbs like change are always rendered as CHG, display as DSP, work as WRK, create as CRT, etc. Subjects like program are always PGM, user is USR, module is MOD, server is SVR, etc. You can see every possible verb and subject used on the system in the VERB and SUBJECT menus, just enter the commands GO VERB or GO SUBJECT.

Likewise, "Control Language Programming" was abbreviated CLP, and the source type was accordingly CLP. With the introduction of the ILE programming model, the source type was changed to "CLLE". [4]

Command grouping menus

The VERB and SUBJECT menus are part of what are called the Command Grouping Menus. For every Three (or four) Letter abbreviation there is a menu devoted to it that starts with the letters CMD. So to see all CHG commands the user would execute the command GO CMDCHG. For program commands the menu would be CMDPGM.

There are other menus besides the Command Grouping Menus. The starting point for the menuing system can be accessed by pressing F4 on an empty command line.

Command selection

If one only knows part of a command or if third party software is being used where the commands don't conform to the AS/400 abbreviation standard then you would enter that part of the command that is known, attach an asterisk (to make it generic), and press enter. The system will then display a list of commands in the job's library list that match the generic names just typed. One can then page through the list looking for the command needed and then select it using option 1.

In the background the system is using the SLTCMD command to perform this function. If one wants to select all commands in a library then prompt this command and enter the special value *ALL.

Sample code

The following is a sample of CL programming. The program interactively converts dates from Julian to MDY and vice versa. Results are displayed on line 24 of the terminal. It accepts two parameters. The &IN parameter which is the date string to be converted. If a Julian string it should be in the format YYNNN where YY is the year number and NNN is the day number of the year. If a MDY string it must be in the format MMDDYY. The second parameter is &TYP which is the type of date to be converted to. It must be 'J' (Julian) or 'M' (MDY). For example: the command CALL PGM(ICVTDATC) PARM('04180' 'M') will convert the Julian date 04180 to 062804 (June 28, 2004).

PGM (&IN &TYP)     DCL &IN  *CHAR 6    DCL &OUT *CHAR 8    DCL &TYP *CHAR 1     IF (&TYP = J) +       DO          CVTDAT DATE(&IN) TOVAR(&OUT) FROMFMT(*MDY) +                 TOFMT(*JUL) TOSEP(*NONE)       ENDDO     ELSE IF (&TYP = M) +       DO          CVTDAT DATE(&IN) TOVAR(&OUT) FROMFMT(*JUL) +                 TOFMT(*MDY) TOSEP(*NONE)       ENDDO     SNDPGMMSG MSG('IN=' || &IN || '  OUT=' || &OUT) +              MSGTYPE(*COMP)  ENDPGM   

See also

Related Research Articles

<span class="mw-page-title-main">COMMAND.COM</span> Default command line for MS-DOS and Windows 9x

COMMAND.COM is the default command-line interpreter for MS-DOS, Windows 95, Windows 98 and Windows Me. In the case of DOS, it is the default user interface as well. It has an additional role as the usual first program run after boot, hence being responsible for setting up the system by running the AUTOEXEC.BAT configuration file, and being the ancestor of all processes.

at (command) Task scheduling command on various operating systems

In computing, at is a command in Unix-like operating systems, Microsoft Windows, and ReactOS used to schedule commands to be executed once, at a particular time in the future.

NTLDR is the boot loader for all releases of Windows NT operating system from 1993 with the release of Windows NT 3.1 up until Windows XP and Windows Server 2003. From Windows Vista onwards it was replaced by the BOOTMGR bootloader. NTLDR is typically run from the primary storage device, but it can also run from portable storage devices such as a CD-ROM, USB flash drive, or floppy disk. NTLDR can also load a non NT-based operating system given the appropriate boot sector in a file.

<span class="mw-page-title-main">Visual IRC</span> Open source Internet Relay Chat client

Visual IRC (ViRC) is an open-source Internet Relay Chat client for the Windows operating system. Unlike many other IRC clients, nearly all of the functionality in ViRC is driven by the included IRC script, with the result that the program's behavior can be extended or changed without altering the source code.

An environment variable is a user-definable value that can affect the way running processes will behave on a computer. Environment variables are part of the environment in which a process runs. For example, a running process can query the value of the TEMP environment variable to discover a suitable location to store temporary files, or the HOME or USERPROFILE variable to find the directory structure owned by the user running the process.

Job Control Language (JCL) is a name for scripting languages used on IBM mainframe operating systems to instruct the system on how to run a batch job or start a subsystem. The purpose of JCL is to say which programs to run, using which files or devices for input or output, and at times to also indicate under what conditions to skip a step. Parameters in the JCL can also provide accounting information for tracking the resources used by a job as well as which machine the job should run on.

On many computing platforms everything is a file, but in contrast in IBM i everything is an object.

<span class="mw-page-title-main">DIGITAL Command Language</span> Command language adopted by several operating systems (OSs)

DIGITAL Command Language (DCL) is the standard command language adopted by many of the operating systems created by Digital Equipment Corporation. DCL had its roots in IAS, TOPS-20, and RT-11 and was implemented as a standard across most of Digital's operating systems, notably RSX-11 and RSTS/E, but took its most powerful form in VAX/VMS. DCL continues to be developed by VSI as part of OpenVMS.

ps (Unix) Standard UNIX utility that displays the currently-running processes

In most Unix and Unix-like operating systems, the ps program displays the currently-running processes. A related Unix utility named top provides a real-time view of the running processes.

Command-line completion is a common feature of command-line interpreters, in which the program automatically fills in partially typed commands.

This article discusses support programs included in or available for OS/360 and successors. IBM categorizes some of these programs as utilities and others as service aids; the boundaries are not always consistent or obvious. Many, but not all, of these programs match the types in utility software.

<span class="mw-page-title-main">Comparison of command shells</span>

A command shell is a command-line interface to interact with and manipulate a computer's operating system.

An autorun.inf file is a text file that can be used by the AutoRun and AutoPlay components of Microsoft Windows operating systems. For the file to be discovered and used by these component, it must be located in the root directory of a volume. As Windows has a case-insensitive view of filenames, the autorun.inf file can be stored as AutoRun.inf or Autorun.INF or any other case combination.

test is a command-line utility found in Unix, Plan 9, and Unix-like operating systems that evaluates conditional expressions. test was turned into a shell builtin command in 1981 with UNIX System III and at the same time made available under the alternate name [.

RUNCOM is a CTSS macro command (script) processor.

A batch file is a script file in DOS, OS/2 and Microsoft Windows. It consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file. A batch file may contain any command the interpreter accepts interactively and use constructs that enable conditional branching and looping within the batch file, such as IF, FOR, and GOTO labels. The term "batch" is from batch processing, meaning "non-interactive execution", though a batch file might not process a batch of multiple data.

In computing, label is a command included with some operating systems. It is used to create, change, or delete a volume label on a logical drive, such as a hard disk partition or a floppy disk. Used without parameters, label changes the current volume label or deletes the existing label.

<span class="mw-page-title-main">Command-line interface</span> Computer interface that uses text

A command-line interface (CLI) is a means of interacting with a computer program by inputting lines of text called command-lines. Command-line interfaces emerged in the mid-1960s, on computer terminals, as a user-friendly alternative to punched cards.

In computing, dpath is an internal cmd.exe command on IBM OS/2 and Microsoft Windows that allows using a set of files with the TYPE command and with input redirection as if they are in the current directory. On Windows it is undocumented and deprecated. dpath differs from the append command in the way it operates. dpath informs programs what directories they should search in order to find computer files. It is then up to the applications to recognize %DPATH%. Using the append command on the other side, programs are able to find files without recognizing that the command is in effect.

References

  1. "IBM System/38 Control Language Reference Manual" (PDF). IBM. 1982-09-10. Retrieved 2021-03-24.[ permanent dead link ]
  2. itjungle.com
  3. IBM.com
  4. Meyers, Bryan (1997). Control Language Programming for the AS/400 (2nd ed.). 29th Street Press. ISBN   9781882419760.