Difference between revisions of "Category:CLP"
DaveLClarkI (talk | contribs) |
DaveLClarkI (talk | contribs) (→Categories) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
As with many other languages, there are multiple versions in popular usage, such as [[CLP/400]] and [[ILE-CLP]]. | As with many other languages, there are multiple versions in popular usage, such as [[CLP/400]] and [[ILE-CLP]]. | ||
− | In some realities, this is comparable to software that is the "glue" connecting higher level language programs like [[:RPG]]; data base files and their over-rides; screen and print "files" and their | + | In some realities, this is comparable to software that is the "glue" connecting higher level language programs like [[:RPG]]; data base files and their over-rides; screen and print "files" and their overrides; and other objects with Menus ... typically when we take a menu option, we are launching a CLP program. Thus, a CLP program might also be thought of as a command script except that it is compiled and creates an object like any other program. |
== CLP Unique Commands == | == CLP Unique Commands == | ||
− | Some | + | Some IBM i [[:Category:Commands | commands]] can ONLY be executed from within a CLP program, not from a [[Command Line]]. Some of them are used to define the environment for a CLP program or control its flow. In other programming languages, these might be called OP CODES or "statements." |
* [[PGM]] (Begin program) | * [[PGM]] (Begin program) | ||
* [[RETURN]] | * [[RETURN]] | ||
Line 41: | Line 41: | ||
* [[INCLUDE]] (Include external CL source at compile-time) | * [[INCLUDE]] (Include external CL source at compile-time) | ||
* [[CLOSE]] (Close a file) | * [[CLOSE]] (Close a file) | ||
− | |||
== Special characters == | == Special characters == | ||
Line 165: | Line 164: | ||
==Categories== | ==Categories== | ||
− | |||
[[Category:Programming languages]] | [[Category:Programming languages]] | ||
− |
Latest revision as of 17:04, 27 December 2018
CLP is an acronym for Control Language Program.
Much of what we find in CLP programs are IBM Commands. [1] Also see CLP Coding Rules and Category:Commands.
As with many other languages, there are multiple versions in popular usage, such as CLP/400 and ILE-CLP.
In some realities, this is comparable to software that is the "glue" connecting higher level language programs like RPG; data base files and their over-rides; screen and print "files" and their overrides; and other objects with Menus ... typically when we take a menu option, we are launching a CLP program. Thus, a CLP program might also be thought of as a command script except that it is compiled and creates an object like any other program.
CLP Unique Commands
Some IBM i commands can ONLY be executed from within a CLP program, not from a Command Line. Some of them are used to define the environment for a CLP program or control its flow. In other programming languages, these might be called OP CODES or "statements."
- PGM (Begin program)
- RETURN
- ENDPGM
- DCL (Declare a variable)
- DCLF (Declare File)
- RCVF (Receive File)
- IF
- ELSE
- DO
- ENDDO
- GOTO
- MONMSG
In later releases, IBM also added the following CL-only commands (or "statements") for additional definition and control of a CL program.
- DOFOR
- DOWHILE
- DOUNTIL
- ITERATE
- LEAVE
- SELECT
- WHEN
- OTHERWISE
- ENDSELECT
- SUBR
- RTNSUBR
- ENDSUBR
- CALLSUBR
- DCLPRCOPT (Declare processing options)
- INCLUDE (Include external CL source at compile-time)
- CLOSE (Close a file)
Special characters
Some characters have special meaning in CL:
Symbol | Meaning |
---|---|
|| | *CAT |
|> | *BCAT |
|< | *TCAT |
= | *EQ |
> | *GT |
< | *LT |
>= | *GE |
<= | *LE |
¬= | *NE |
¬> | *NG |
¬< | *NL |
& | *AND |
| | *OR |
¬ | *NOT |
Ref: CL Programming, Expressions in CL commands
Built-in functions
Like RPG, CLP also supports many built-in functions. These would typically be used in CHGVAR commands and/or conditional statements (such as IF, DOWHILE, etc.) to manipulate variable data before its subsequent use. Initially, CLP offered the following built-in functions.
Function | Use |
---|---|
%BINary | Convert signed decimal data to or from binary character format. |
%SubSTring | Extract or set a subset of another character string. |
%SWITCH | Evaluate one or more of the eight job switches and return a Boolean result. |
As of V5R4 of the operating system, IBM added the following built-in functions to CLP.
Function | Use |
---|---|
%ADDRess | Change or test the address stored in a CL pointer variable. |
%OFfSet | Change or test the offset portion of an address stored in a CL pointer variable. |
As of V7R1 of the operating system, IBM added the following built-in functions to CLP.
Function | Use |
---|---|
%CHECK | Using a forward search, returns the first position in a base string that contains a character that is not in the comparator string — or zero if the base string contains only characters from the comparator string. |
%CHECKR | Using a reverse search, returns the last position in a base string that contains a character that is not in the comparator string — or zero if the base string contains only characters from the comparator string. |
%SCAN | Using a forward search, returns the first position of an argument string within a source string — or zero if not found. |
%TRIM | Returns the supplied string with leading and trailing blank characters or argument characters removed. |
%TRIML | Returns the supplied string with leading (i.e., leftmost) blank characters or argument characters removed. |
%TRIMR | Returns the supplied string with trailing (i.e., rightmost) blank characters or argument characters removed. |
As of V7R2 of the operating system, IBM added the following built-in functions to CLP.
Function | Use |
---|---|
%CHAR | Converts logical, decimal, integer, or unsigned integer data to character format. |
%DEC | Converts character, logical, decimal, integer, or unsigned integer data to packed decimal format. |
%INT | Converts character, logical, decimal, or unsigned integer data to integer format. |
%LEN | Returns the number of digits or characters of a CL numeric or character variable. |
%LOWER | Returns a character string that is the same length as the argument specified with each uppercase letter replaced by the corresponding lowercase letter. |
%SIZE | Returns the number of bytes occupied by the CL variable. |
%UINT | Converts character, logical, decimal, or integer data to unsigned integer format. |
%UPPER | Returns a character string that is the same length as the argument specified with each lowercase letter replaced by the corresponding uppercase letter. |
Pointer use
As of V5R4, CL allows the use of pointers. There were some problems with uninitialised pointers, and PTFs were issued. As of 15 Feb 2008, 5722-SS1:
- SI28620
- SI28196
- SI27953
These are immediate PTFs, but you will need to re-compile any CL programs using pointers in order to get the issues fixed.
One can't compare a pointer to *NULL, but a clever idea is to create an unused pointer (which will be set to *NULL if the above PTFs are applied) and compare to that. Here is a snippet from Tom L. for a CL program that performs getenv from a thread on RPG400-L.
dcl &pNull *ptr /* Auto-initialized to *null */ if ( &pEnvVar *eq &pNull ) do
Note: As of V6R1 of the operating system, complete *NULL support was added to ILE CL encompassing the DCL, CHGVAR, and conditional statements.
Categories
Pages in category "CLP"
The following 12 pages are in this category, out of 12 total.