Commands

199 Views


CL command parts

The parts of a command include a command label (optional), a command name (mnemonic), and one or more parameters. The parameter includes a keyword and a value.

This figure illustrates the parts of a command:

CL command syntax:

A command name and parameters make up each CL command.

The parameters used in CL commands are keyword parameters. The keyword identifies the purpose of the parameter.

CL command label:

Command labels identify particular commands for branching purposes in a CL program.

Labels can also be used to identify statements in CL programs that are being debugged.

Command labels are not required, but a label can be placed on any command.

CL command parameters:

Most CL commands have one or more parameters that specify the objects and values used to run the commands.

When a command is entered, the user supplies the command object name, the parameter keyword names, and the parameter values used by the command.

The number of parameters specified depends upon the command.

CL command delimiter characters:

Command delimiter characters are special characters or spaces that identify the beginning or end of a group of characters in a command.

Delimiter characters are used to separate a character string into the individual parts that form a command: command label, command name, parameter keywords, and parameter values. 

The following delimiter characters are used in the IBM i control language:

  • The colon (:) ends the command label, and it can be used to separate the command label from the command name. v Blank spaces separate the command name from its parameters and separate parameters from each other.
  • Parentheses ( ) are used to separate parameter values from their keywords, to group lists of values, and to group lists within lists.
  • Slashes (/) connect the parts of a qualified name or the parts of a path name.
  • Either a period or a comma can be used as a decimal point in a decimal value (3.14 or 3,14)
  • The characters /* and */ can indicate the beginning and ending of a comment
  • A question mark (?) preceding the command name indicates that the command is prompted
  • Single quotation marks specify the beginning and ending of a quoted character string

CL command continuation:

Commands can be entered in free format. This means that a command does not have to begin in a specific location.

A command can be entirely in one line or on several lines.

Plus sign (+) or Minus sign (-) is entered as the last character on the line to indicate that a command is continued.

The + is generally useful between parameters or values.

The difference between the plus and minus sign usage is particularly important when continuation occurs inside a quoted character string.

The example that follows shows the difference.

CRTLIB LIB(XYZ) TEXT(’This is CONT+
INUED’)
CRTLIB LIB(XYZ) TEXT(’This is CONTINUED’)

For + : CRTLIB LIB(XYZ) TEXT(’This is CONTINUED’)
For - : CRTLIB LIB(XYZ) TEXT(’This is CONT INUED’)

The minus sign causes the leading blanks on the next line to be entered.

CL command comments:

Comments within CL programs describe the expected behavior of the code.

To begin a comment, the characters /* must be placed in the first position of the command and then */

Comments may not follow a continuation character on the same line.

For readability, it is recommended that each comment be specified on a separate line preceding or following the command it describes, as shown here:

MOVOBJ OBJA TOLIB(LIBY)
/* Object OBJA is moved to library LIBY. */
DLTLIB LIBX
/* Library LIBX is deleted. */

CL command coding rules

  • Blanks are the basic separators between the parts of a command:

              – Between command label and command name

              – Between command name and first parameter, and between parameters.

              – Between values in a list of values 

              – Between the slashes and the name or label of some job control commands

  • Blanks cannot separate a parameter's keyword. For example, KWD(   A    ) is valid
  • Multiple blanks are treated as a single blank
  • A colon must immediately follow a command label. Only one label can be used on any command (LABEL1: DCLF).
  • Single quotation marks must be used to specify the beginning and end of a quoted character string
  • Parentheses must be used on parameters that are specified (coded) in keyword form
  • Comments can appear wherever blanks are permitted
  • A plus or minus sign at the end of a line indicates that the command is continued
  • All required parameters must be coded.

Sample CL Progarm:

F4 taken on DSPPGMREF

Typed 'TEST' in Label

We see the label TEST appearing there.

CL command help:

All IBM CL commands have online help available.

Online help contains the parameter and value descriptions for the command.

To display help for a command, do one of the following:

From an IBM i command line, type the command name (for example, CRTUSRPRF) and press F1.

The display shows general help for the command and help for each command parameter.

CL command prompters:

Command prompters allow you to prompt for CL command parameters and values.

Command prompters can be invoked directly or called from application programs.

Using the prompters allows you to easily build syntactically correct CL command strings.

Press F4 on a CL command from command line for prompting.

Take F4 for prompting.

Most IBM i object types have commands that perform the following actions:

  • Create (CRT): Creates the object and specifies its attributes.
  • Delete (DLT): Deletes the object from the system.
  • Change (CHG): Changes the attributes, contents of the object, or both.
  • Display (DSP): Displays the contents of the object. Display commands cannot be used to operate on objects.

Work with (WRK): Works with the attributes, contents of the object, or both. Unlike display commands, work commands allow users to operate on objects and modify applications.

Post Comments