NAMING CONVENTIONS


As with other computer languages, RPG has standard naming conventions. Table 1.5 lists the criteria for each named component of an RPG program. Unless otherwise noted, all names must be unique. For example, the name of a data structure cannot be the same as that of an array.

Table 1.5: Naming Conventions

Name

Naming Convention

All Names

The first character must be A to Z (or a to z), @, #, or $. Subsequent characters can be A to Z (or a to z), @, #, $, 0 to 9, or the underscore (_) character. Letter case is not significant. If @, #, or $ is used as the first character of a name, at least one other character must be specified. No embedded blanks or periods are allowed. Array names can be suffixed with an array index. All names are global to all areas of the RPG IV program unless modules or subprocedures are used. When modules or subprocedures are used, names can be declared local to a module.

File

A file name cannot be the same as a (record) format name.

Format

A (record) format name must be 1 to 10 characters in length. Format names cannot be the same as that of a file name.

Field

A field name must be 1 to 4096 characters in length. Field names may be the same as a data structure or data structure subfield name, but not both.

Structure

A structure name, referred to as a data structure in RPG, can be the same as that of an input file's field name. It can be manipulated the same as any other variable, and can be specified as a parameter of a CALLx operation.

Qualified Name

A qualified name is a data structure subfield name qualified to (i.e., attached to) its parent data structure name. Qualified names are created by specifying the data structure name followed by a period, followed by the data structure subfield name. For example: MyDS.CustName Qualified names are created when the QUALIFIED or LIKEDS keywords are used to declare a data structure.

Array Index

An array index name must represent a numeric field that contains zero decimal places or it can be an expression. The array index can be a field of type packed, signed, integer, or binary. Although binary and integer are the most efficient, packed decimal is most commonly used. Array indexes are identified using parentheses. For example, MyArray(x) indicates that array index x is used with the array name MyArray.

Label

A label is the target of a branch or GOTO operation. A label is defined with either the TAG or ENDSR operation.

Named Constant

A named constant is used to assign a name to a literal value. This name can be used repeatedly throughout the program.




The Modern RPG IV Language
The Modern RPG IV Language
ISBN: 1583470646
EAN: 2147483647
Year: 2003
Pages: 156
Authors: Robert Cozzi

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net