Difference between revisions of "CLP Coding Rules"

From MidrangeWiki
Jump to: navigation, search
m (remove link to CLP Commands, add link to Category:Commands)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Programming]]
+
{{See also|:Category:Commands}}
[[Category:CLP]]
+
== Coding rules for [[CLP]] [[Commands]] ==
[[Category:Commands]]
 
== Coding rules for [[CLP]] Commands ==
 
 
These rules apply both on [[Command Line]] and inside a [[CLP]] program.
 
These rules apply both on [[Command Line]] and inside a [[CLP]] program.
 
+
* Everything is promptable
 +
** Key in part of the [[CLP]] or [[Command]] then instead of pressing ENTER key, do F4
 +
** depending on where cursor was when you did F4, controls what help you get
 
* Blank space separates parts of a command
 
* Blank space separates parts of a command
 
** Example [[WRKOUTQ]] QFISCAL* to get at list of all [[OUTQ]] whose name starts with QFISCAL
 
** Example [[WRKOUTQ]] QFISCAL* to get at list of all [[OUTQ]] whose name starts with QFISCAL
Line 27: Line 27:
 
* plus sign at end of line(s) that need to go to another line, when the next character is non-blank (F4 gets it perfect)
 
* plus sign at end of line(s) that need to go to another line, when the next character is non-blank (F4 gets it perfect)
 
* minus sign at end of line(s) that need to go to another line, when the next character period (F4 gets it perfect)
 
* minus sign at end of line(s) that need to go to another line, when the next character period (F4 gets it perfect)
 +
== [[CLP]] Program Structure ==
 +
* Except for comment lines
 +
* CLP program begins with [[PGM]] Program command and ends with [[ENDPGM]] End Program command
 +
** ENDPGM is safety to make sure we have all of the source code
 +
* Right after [[PGM]] is the [[DCL]] declaration section where we define the variables that will be used in the rest of the program
 +
=== Declare Variable ===
 +
Examples used to illustrate how this works.
 +
 +
DCL VAR(Variable Name) TYPE(*CHAR) LEN(Lengthe) VALUE(Initial Value)
 +
DCL &X *CHAR 1 /* Y=Yes N=No */
 +
 +
* Variable Name must start with ampersand (&) followed by up to 10 characters (11 total maximum)
 +
* Length of character field
 +
** 1 minumum
 +
** 9999 maximum
 +
** 32 default
 +
* Type ... the first example above is a character variable
 +
* Value specifies what goes into the variable when it is first created.  Later in the program the contents can be changed.
 +
** If the specified starting value is less than the length, the result is left justified (blanks after what gets specified)
 +
 +
==Categories==
 +
[[Category:CLP]]
 +
[[Category:Commands]]
 +
[[Category:Basics 101]]

Latest revision as of 17:24, 17 June 2008

See also: [[::Category:Commands|:Category:Commands]]

Coding rules for CLP Commands

These rules apply both on Command Line and inside a CLP program.

  • Everything is promptable
    • Key in part of the CLP or Command then instead of pressing ENTER key, do F4
    • depending on where cursor was when you did F4, controls what help you get
  • Blank space separates parts of a command
    • Example WRKOUTQ QFISCAL* to get at list of all OUTQ whose name starts with QFISCAL
  • Parentheses go around keywords and values
    • Example SAVLIB LIB(XFILES) DEV(TAP01)
  • Slash connects parts of a qualified name or path name
  • Single apostrophe indicates beginning and end of a quoted character string (a constant)
    • Example SNDMSG MSG('Intruder Alert') TOUSR(QBOSS)
  • *N is a place holder (take the defaults) indicating the absense of a positional parameter
  • Predefined values begin with an asterisk and indicate IBM-defined values which are reserved by OS/400 and may be used in programs to have those set functions
    • Example SAVLIB LIB(*ALLUSR) DEV(*SAVF)
  • Generic name contains one or more characters that are those that start some object(s) then end in asterisk to signify wild card list of all that share that prefix
    • Example DSPF*

Coding rules inside CLP Programs

  • Variable name has ampersand & followed by up to 10 characters (11 total), used to store and update data and to receive parameters, as temporary storage while program is running
  • Colon : ends a command label
    • Example LABEL:
  • /* at beginning and */ at end of comment lines
  • plus sign at end of line(s) that need to go to another line, when the next character is non-blank (F4 gets it perfect)
  • minus sign at end of line(s) that need to go to another line, when the next character period (F4 gets it perfect)

CLP Program Structure

  • Except for comment lines
  • CLP program begins with PGM Program command and ends with ENDPGM End Program command
    • ENDPGM is safety to make sure we have all of the source code
  • Right after PGM is the DCL declaration section where we define the variables that will be used in the rest of the program

Declare Variable

Examples used to illustrate how this works.

DCL VAR(Variable Name) TYPE(*CHAR) LEN(Lengthe) VALUE(Initial Value)
DCL &X *CHAR 1 /* Y=Yes N=No */
  • Variable Name must start with ampersand (&) followed by up to 10 characters (11 total maximum)
  • Length of character field
    • 1 minumum
    • 9999 maximum
    • 32 default
  • Type ... the first example above is a character variable
  • Value specifies what goes into the variable when it is first created. Later in the program the contents can be changed.
    • If the specified starting value is less than the length, the result is left justified (blanks after what gets specified)

Categories