Difference between revisions of "Free Form Definitions"
From MidrangeWiki
DaveLClarkI (talk | contribs) (→Free-Form Definitions) |
DaveLClarkI (talk | contribs) (→Examples) |
||
(22 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | [[Category:RPG]] | ||
+ | [[Category:Programming]] | ||
One of the major new features of ILE RPG, introduced in [[7.1]], is free form definition specifications. | One of the major new features of ILE RPG, introduced in [[7.1]], is free form definition specifications. | ||
+ | {{stub}} | ||
==Features== | ==Features== | ||
Line 12: | Line 15: | ||
==Free-Form Definitions== | ==Free-Form Definitions== | ||
− | The following are new free-form definition statements to take the place of the indicated fixed-format specifications. | + | The following are the new free-form definition statements to take the place of the indicated fixed-format specifications. |
CTL-OPT . . equates to H-specs | CTL-OPT . . equates to H-specs | ||
DCL-F . . . equates to F-specs | DCL-F . . . equates to F-specs | ||
Line 26: | Line 29: | ||
END-PROC . . equates to P-spec end statements | END-PROC . . equates to P-spec end statements | ||
− | ==Examples== | + | ===Examples=== |
− | < | + | <pre> |
+ | ----+----1----+----2----+----3----+----4----+----5---- | ||
D* fixed-form declarations | D* fixed-form declarations | ||
D string S 50A VARYING | D string S 50A VARYING | ||
Line 43: | Line 47: | ||
DCL-C max_count 200; | DCL-C max_count 200; | ||
DCL-C deleted 'D'; | DCL-C deleted 'D'; | ||
− | </source | + | </pre> |
+ | |||
+ | ===Fully Free-Form coding=== | ||
+ | Another one of the new features of ILE RPG, introduced for 7.3 and as of 7.2 TR 3 and 7.1 TR 11, is a fully free-form coding format. The program source must start with **FREE and this removes all of the prior column restrictions for RPG source. | ||
+ | * Fixed-form specifications cannot be used in the main program source. | ||
+ | * Fixed-form copy/include files can still be used—the SQL precompiler, at least, automatically inserts **END-FREE and **FREE around them. | ||
+ | * Columns 6 and 7 no longer have special meaning for fixed-form specification characters, compiler directives, or comments. | ||
+ | * All free-form statements, compiler directives, and comments may start in column 1. | ||
+ | * All comments must start with a double forward slash (//), instead of an asterisk, and can be used practically anywhere/anytime. | ||
+ | * Column 80 is no longer the restricted right margin for statement content. | ||
+ | * The entire source line length may be used for statement content—no reserved comment area. | ||
+ | * Source line lengths greater than 100 characters are automatically supported. | ||
==Links== | ==Links== | ||
[http://ibmsystemsmag.blogs.com/i_can/2014/01/free-format-rpg-and-tr7.html Dawn May: Free format RPG and TR7] | [http://ibmsystemsmag.blogs.com/i_can/2014/01/free-format-rpg-and-tr7.html Dawn May: Free format RPG and TR7] | ||
+ | [https://ibm.biz/rpgcafe_fullyfree_rpg RPG Cafe: Fully free-form RPG] | ||
− | + | [https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzasd/freestmt.htm IBM Knowledge Center: Free-Form Statements] | |
− | [ | ||
− |
Latest revision as of 21:05, 27 December 2018
One of the major new features of ILE RPG, introduced in 7.1, is free form definition specifications.
This article is a stub. You can help by editing it.
Contents
Features
- Removes the column restrictions on definitions.
- Can be interspersed with standard, fixed form, definitions.
- /free and /end-free no longer required.
Requirements
- IBM i 7.1 or higher.
- 7.1 PTF 5770WDS SI51094.
- If using SQLRPGLE, 7.1 PTF Group SF99701 level 26 or higher.
Free-Form Definitions
The following are the new free-form definition statements to take the place of the indicated fixed-format specifications.
CTL-OPT . . equates to H-specs DCL-F . . . equates to F-specs DCL-C . . . equates to D-spec constants DCL-S . . . equates to D-spec stand-alone fields DCL-DS . . . equates to D-spec data structures END-DS . . . to terminate most DCL-DS statements DCL-PI . . . equates to D-spec procedure interface definitions END-PI . . . to terminate procedure interface definitions DCL-PR . . . equates to D-spec procedure prototype definitions END-PR . . . to terminate procedure prototype definitions DCL-PROC . . equates to P-spec begin statements END-PROC . . equates to P-spec end statements
Examples
----+----1----+----2----+----3----+----4----+----5---- D* fixed-form declarations D string S 50A VARYING D date S D DATFMT(*MDY) D obj S O CLASS(*JAVA:'MyClass') D ptr S * PROCPTR // free-form declarations DCL-S string VARCHAR(50); DCL-S date DATE(*MDY); DCL-S obj OBJECT(*JAVA:'MyClass'); DCL-S ptr POINTER(*PROC); // constants DCL-C max_count 200; DCL-C deleted 'D';
Fully Free-Form coding
Another one of the new features of ILE RPG, introduced for 7.3 and as of 7.2 TR 3 and 7.1 TR 11, is a fully free-form coding format. The program source must start with **FREE and this removes all of the prior column restrictions for RPG source.
- Fixed-form specifications cannot be used in the main program source.
- Fixed-form copy/include files can still be used—the SQL precompiler, at least, automatically inserts **END-FREE and **FREE around them.
- Columns 6 and 7 no longer have special meaning for fixed-form specification characters, compiler directives, or comments.
- All free-form statements, compiler directives, and comments may start in column 1.
- All comments must start with a double forward slash (//), instead of an asterisk, and can be used practically anywhere/anytime.
- Column 80 is no longer the restricted right margin for statement content.
- The entire source line length may be used for statement content—no reserved comment area.
- Source line lengths greater than 100 characters are automatically supported.