the gnucobol 2.0 grammar - sourceforge · 07/09/2016 · the gnucobol 2.0 grammar for r1104 edward...
TRANSCRIPT
COBOL is an industry language and is not the property of any company or group ofcompanies, or of any organisation or group of organisations.No warranty, expressed or implied, is made by any contributor, or by the CODASYLCOBOL Committee,1 as to the accuracy and functioning of the programming system andlanguage. Moreover, no responsibility is assumed by any contributor, or by the committee,in connection therewith.The authors and copyright holders of the copyrighted materials used herein are:• FLOW-MATIC (trademark of Sperry Rand Corporation), Programming for the UNI-VAC ® I and II, Data Automation Systems, copyrighted 1958, 1959 by Sperry RandCorporation,2• IBM Commercial Translator, Form No. F28-8013, copyrighted 1959 by IBM, and• FACT, DSI 27A5260-2760, copyrighted 1960 by Minneapolis-Honeywell.
They have specially authorised the use of this material, in whole or in part, in theCOBOL specifications. Such authorisation extends to the reproduction and use of COBOLspecifications in programming manuals or similar publications.
This work is typeset in Roboto.
Copyright © 2016 Edward HartPermission is granted to copy, distribute and/or modify this document under the termsof the GNU Free Documentation License, Version 1.3 or any later version published bythe Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and noBack-Cover Texts. Your attention is drawn to the copy of the license in Appendix A.
The moral rights of the author have been asserted.1The CODASYL COBOL committee was dissolved in 1992. Its work was continued by ANSI X3J4 and thenINCITS PL22.4, which was itself dissolved in 2015.2Sperry Rand’s computer business is now part of Unisys.
ii
Contents
Foreword xi
Changelog xiii
1. Key 3
2. Compiler directives 52.1. D directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2. COPY statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.3. DEFINE directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.4. DISPLAY directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.5. IF directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.6. LEAP-SECOND directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.7. LISTING directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.8. PAGE directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.9. REPLACE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.10. SET directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.11. SOURCE directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.12. TURN directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.13. Miscellaneous directives . . . . . . . . . . . . . . . . . . . . . . . . . . . 83. Compilation group 10
4. Identification division 134.1. PROGRAM-ID paragraph . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.2. FUNCTION-ID paragraph . . . . . . . . . . . . . . . . . . . . . . . . . . . 145. Environment division 165.1. Configuration section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165.1.1. SOURCE-COMPUTER paragraph . . . . . . . . . . . . . . . . . . 165.1.2. OBJECT-COMPUTER paragraph . . . . . . . . . . . . . . . . . . . 165.1.3. SPECIAL-NAMES paragraph . . . . . . . . . . . . . . . . . . . . . 175.1.4. REPOSITORY paragraph . . . . . . . . . . . . . . . . . . . . . . . 185.2. Input-output section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185.2.1. FILE-CONTROL paragraph . . . . . . . . . . . . . . . . . . . . . . 195.2.2. I-O-CONTROL paragraph . . . . . . . . . . . . . . . . . . . . . . . 21
iv
Contents
6. Data division 236.1. File section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236.1.1. File description entry . . . . . . . . . . . . . . . . . . . . . . . . . 246.2. Working-storage section . . . . . . . . . . . . . . . . . . . . . . . . . . . 246.3. Local-storage section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256.4. Linkage section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256.5. Report section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256.5.1. Report description . . . . . . . . . . . . . . . . . . . . . . . . . . 256.6. Screen section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266.6.1. Screen description . . . . . . . . . . . . . . . . . . . . . . . . . . 276.7. Record description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286.8. Constant definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296.9. Data division clauses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306.9.1. BLANK WHEN ZERO clause . . . . . . . . . . . . . . . . . . . . . 306.9.2. BLOCK clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306.9.3. COLUMN clause . . . . . . . . . . . . . . . . . . . . . . . . . . . 306.9.4. Entry name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316.9.5. JUSTIFIED clause . . . . . . . . . . . . . . . . . . . . . . . . . . . 316.9.6. LINAGE clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316.9.7. LINE clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316.9.8. Level-number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326.9.9. NEXT GROUP clause . . . . . . . . . . . . . . . . . . . . . . . . . 326.9.10. OCCURS clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326.9.11. PRESENT WHEN clause . . . . . . . . . . . . . . . . . . . . . . . 336.9.12. RECORD clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336.9.13. SIGN clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336.9.14. SOURCE clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336.9.15. SUM clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336.9.16. TYPE clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346.9.17. USAGE clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346.9.18. VALUE clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366.9.19. VARYING clause . . . . . . . . . . . . . . . . . . . . . . . . . . . 367. Procedure division 387.1. Common phrases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397.1.1. ROUNDED phrase . . . . . . . . . . . . . . . . . . . . . . . . . . . 397.1.2. SIZE phrase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397.2. ACCEPT statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397.3. ADD statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437.4. ALLOCATE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447.5. ALTER statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447.6. CALL statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447.7. CANCEL statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457.8. CLOSE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
v
Contents
7.9. COMMIT statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457.10. COMPUTE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457.11. CONTINUE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467.12. DELETE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467.13. DISPLAY statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467.14. DIVIDE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497.15. ENTRY statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507.16. EVALUATE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507.17. EXIT statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517.18. FREE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517.19. GENERATE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517.20. GO TO statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517.21. GOBACK statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517.22. IF statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527.23. INITIALIZE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527.24. INITIATE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537.25. INSPECT statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537.26. MERGE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547.27. MOVE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547.28. MULTIPLY statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547.29. NEXT SENTENCE statement . . . . . . . . . . . . . . . . . . . . . . . . . 557.30. OPEN statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557.31. PERFORM statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557.32. READ statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567.33. READY statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577.34. RELEASE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577.35. RESET statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577.36. RETURN statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587.37. REWRITE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587.38. ROLLBACK statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587.39. SEARCH statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587.40. SET statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597.41. SORT statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607.42. START statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617.43. STOP statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617.44. STRING statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627.45. SUBTRACT statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627.46. SUPPRESS statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637.47. TERMINATE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647.48. TRANSFORM statement . . . . . . . . . . . . . . . . . . . . . . . . . . . 647.49. UNLOCK statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647.50. UNSTRING statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647.51. USE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657.52. WRITE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
vi
Contents
8. Intrinsic functions 698.1. ABS function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698.2. ACOS function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698.3. ANNUITY function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698.4. ASIN function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698.5. ATAN function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698.6. BOOLEAN-OF-INTEGER function . . . . . . . . . . . . . . . . . . . . . . . 708.7. BYTE-LENGTH function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708.8. CHAR function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708.9. CHAR-NATIONAL function . . . . . . . . . . . . . . . . . . . . . . . . . . 708.10. COMBINED-DATETIME function . . . . . . . . . . . . . . . . . . . . . . . 708.11. CONCATENATE function . . . . . . . . . . . . . . . . . . . . . . . . . . . 708.12. COS function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718.13. CURRENCY-SYMBOL function . . . . . . . . . . . . . . . . . . . . . . . . 718.14. CURRENT-DATE function . . . . . . . . . . . . . . . . . . . . . . . . . . . 718.15. DATE-OF-INTEGER function . . . . . . . . . . . . . . . . . . . . . . . . . . 718.16. DATE-TO-YYYYMMDD function . . . . . . . . . . . . . . . . . . . . . . . . 718.17. DAY-OF-INTEGER function . . . . . . . . . . . . . . . . . . . . . . . . . . 718.18. DAY-TO-YYYYDDD function . . . . . . . . . . . . . . . . . . . . . . . . . . 728.19. DISPLAY-OF function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728.20. E function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728.21. EXCEPTION-FILE function . . . . . . . . . . . . . . . . . . . . . . . . . . 728.22. EXCEPTION-FILE-N function . . . . . . . . . . . . . . . . . . . . . . . . . 728.23. EXCEPTION-LOCATION function . . . . . . . . . . . . . . . . . . . . . . . 728.24. EXCEPTION-LOCATION-N function . . . . . . . . . . . . . . . . . . . . . . 738.25. EXCEPTION-STATEMENT function . . . . . . . . . . . . . . . . . . . . . . 738.26. EXCEPTION-STATUS function . . . . . . . . . . . . . . . . . . . . . . . . 738.27. EXP function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738.28. EXP10 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738.29. FACTORIAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738.30. FORMATTED-CURRENT-DATE function . . . . . . . . . . . . . . . . . . . 748.31. FORMATTED-DATE function . . . . . . . . . . . . . . . . . . . . . . . . . 748.32. FORMATTED-DATETIME function . . . . . . . . . . . . . . . . . . . . . . 748.33. FORMATTED-TIME function . . . . . . . . . . . . . . . . . . . . . . . . . 748.34. FRACTION-PART function . . . . . . . . . . . . . . . . . . . . . . . . . . . 748.35. HIGHEST-ALGEBRAIC function . . . . . . . . . . . . . . . . . . . . . . . . 748.36. INTEGER function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 758.37. INTEGER-OF-BOOLEAN function . . . . . . . . . . . . . . . . . . . . . . . 758.38. INTEGER-OF-DATE function . . . . . . . . . . . . . . . . . . . . . . . . . . 758.39. INTEGER-OF-DAY function . . . . . . . . . . . . . . . . . . . . . . . . . . 758.40. INTEGER-OF-FORMATTED-DATE function . . . . . . . . . . . . . . . . . . 758.41. INTEGER-PART function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 758.42. LENGTH function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 768.43. LENGTH-AN function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
vii
Contents
8.44. LOCALE-COMPARE function . . . . . . . . . . . . . . . . . . . . . . . . . 768.45. LOCALE-DATE function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 768.46. LOCALE-TIME function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 768.47. LOCALE-TIME-FROM-SECONDS function . . . . . . . . . . . . . . . . . . 768.48. LOG function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 778.49. LOG10 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 778.50. LOWER-CASE function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 778.51. LOWEST-ALGEBRAIC function . . . . . . . . . . . . . . . . . . . . . . . . 778.52. MAX function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 778.53. MEAN function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 778.54. MEDIAN function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 788.55. MIDRANGE function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 788.56. MIN function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 788.57. MOD function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 788.58. MODULE-CALLER-ID function . . . . . . . . . . . . . . . . . . . . . . . . 788.59. MODULE-DATE function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 788.60. MODULE-FORMATTED-DATE function . . . . . . . . . . . . . . . . . . . . 798.61. MODULE-ID function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 798.62. MODULE-PATH function . . . . . . . . . . . . . . . . . . . . . . . . . . . 798.63. MODULE-SOURCE function . . . . . . . . . . . . . . . . . . . . . . . . . . 798.64. MODULE-TIME function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 798.65. MONETARY-DECIMAL-POINT function . . . . . . . . . . . . . . . . . . . 798.66. MONETARY-THOUSANDS-SEPARATOR function . . . . . . . . . . . . . . 808.67. NATIONAL-OF function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 808.68. NUMERIC-DECIMAL-POINT function . . . . . . . . . . . . . . . . . . . . . 808.69. NUMERIC-THOUSANDS-SEPARATOR function . . . . . . . . . . . . . . . 808.70. NUMVAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 808.71. NUMVAL-C function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 808.72. NUMVAL-F function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818.73. ORD function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818.74. ORD-MAX function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818.75. ORD-MIN function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818.76. PI function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818.77. PRESENT-VALUE function . . . . . . . . . . . . . . . . . . . . . . . . . . . 818.78. RANDOM function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 828.79. RANGE function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 828.80. REM function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 828.81. REVERSE function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 828.82. SECONDS-FROM-FORMATTED-TIME function . . . . . . . . . . . . . . . 828.83. SECONDS-PAST-MIDNIGHT function . . . . . . . . . . . . . . . . . . . . 828.84. SIGN function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 838.85. SIN function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 838.86. SQRT function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 838.87. STANDARD-COMPARE function . . . . . . . . . . . . . . . . . . . . . . . 83
viii
Contents
8.88. STANDARD-DEVIATION function . . . . . . . . . . . . . . . . . . . . . . . 838.89. STORED-CHAR-LENGTH function . . . . . . . . . . . . . . . . . . . . . . 838.90. SUBSTITUTE function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 848.91. SUBSTITUTE-CASE function . . . . . . . . . . . . . . . . . . . . . . . . . 848.92. SUM function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 848.93. TAN function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 848.94. TEST-DATE-YYYYMMDD function . . . . . . . . . . . . . . . . . . . . . . 848.95. TEST-DAY-YYYYDDD function . . . . . . . . . . . . . . . . . . . . . . . . 848.96. TEST-FORMATTED-DATETIME function . . . . . . . . . . . . . . . . . . . 858.97. TEST-NUMVAL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858.98. TEST-NUMVAL-C function . . . . . . . . . . . . . . . . . . . . . . . . . . 858.99. TEST-NUMVAL-F function . . . . . . . . . . . . . . . . . . . . . . . . . . . 858.100. TRIM function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858.101. UPPER-CASE function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858.102. VARIANCE function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 868.103. WHEN-COMPILED function . . . . . . . . . . . . . . . . . . . . . . . . . . 868.104. YEAR-TO-YYYY function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86Appendices 90
A. GNU Free Documentation License 92A.1. Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92A.2. Applicability and definitions . . . . . . . . . . . . . . . . . . . . . . . . . 93A.3. Verbatim copying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94A.4. Copying in quantity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95A.5. Modifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95A.6. Combining documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98A.7. Collections of documents . . . . . . . . . . . . . . . . . . . . . . . . . . 98A.8. Aggregation with independent works . . . . . . . . . . . . . . . . . . . . 98A.9. Translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99A.10. Termination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99A.11. Future revisions of this license . . . . . . . . . . . . . . . . . . . . . . . . 100A.12. Relicensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100A.13. Addendum: How to use this License for your documents . . . . . . . . . 101
ix
Foreword
This document describes the syntax of COBOL as supported by GnuCOBOL. It is hopedit will complement Gary Cutler’s 2013 GnuCOBOL Programmer’s Guide which does notdocument recent features added to GnuCOBOL. It is also formatted in LATEX, so thateverything looks a bit prettier.The syntax diagrams were transcribed from GnuCOBOL’s parsers. It thus replicatessomeunusual syntax rules andmisses some syntax rules implemented outside the parser.For example, the obsolete identification division comment paragraphs are allowed in anyorder and the syntax of a file-control entry does not distinguish between SEQUENTIAL,INDEXED and RELATIVE organisations.This is a draft and so hasmany flaws. Designed to document features theProgrammer’sGuide does not, it strangely lacks a list of these new features. Important syntax ruleswhich cannot be contained in syntax diagrams are missing. There are no definitions offundamental objects such as conditions and identifiers. If people find this documentuseful, I will try to fix these shortcomings.
xi
ChangelogFrom 23 November 2013.General
• 64-bit numbers: fixed bugs in handling of 64-bit numbers (e.g. bug #229).• C compiler support: fixed errors in compilers without designated initializers.• Comments: added ACUCOBOL comments: $ as synonym for * in indicator areaand | as synonym for floating comment indicator *>.• curses: fixed compilation errors when configured without curses (bug #90).• Error messages: error messages are now lowercase, in line with the GNU CodingStandards (bug #198).• Error messages: segfaults in the compiler now cause an error message to bedisplayed.• Indicators: invalid indicators no longer cause compilation to immediately terminate(feature request #126).• Manpage: added manpage generation and installation.• Nested programs: Nested programs no longer need to have END PROGRAM.• National literals: added basic support for national literals.• Numeric literals: added ACUCOBOL numeric literals: B#. . . for binary, O#. . . foroctal and X#. . . and H#. . . for hexadecimal.• Numeric literals: fixed bug #167 involving overly large numeric literals.• Listings: added complete listing support (-t/-T compiler options).• Literals: fixed heap corruptions caused by uncommon literals (bug #195).• Literals: allow concatenation of literal and Boolean literals.• Microsoft Visual C++: output when compiling with cl.exe is now filtered and tem-porary files are deleted.• stdin: allow COBOL code to come from stdin.
xiii
Changelog
• User-defined functions: function definitions must now end with END FUNCTION.• User-defined functions: function definitions may no longer be nested in programs(bug #255).• Variable format: added support for Micro Focus’ variable source format.
Configuration options
• Aliases: compiler configurations can now specify whether a reserved word is analias for another reserved word.• Deleted compiler configuration options: cobol85-reserved.• New compiler configurations: acu for ACUCOBOL, cobol2014 for COBOL 2014.• New compiler configuration options: accept-display-extensions, accept-update,accept-auto, acucobol-literals, call-overflow, console-is-crt, literal-length, not-exception-before-exception, numeric-boolean, numeric-literal-length, program-name-redefinition,renames-uncommon-levels, reserved, specify-all-reserved, word-length (featurerequest #43).• Nesting: permit nesting of runtime configuration files.• Renamed compiler configuration options: relaxed-syntax-check to relax-syntax-checks.• Reserved words: compiler configurations can now specify all the reserved wordsand context-sensitive words permitted.• Runtime configuration: added ability to configure programs at runtime.
Compiler directives
• >>IF directive: fixed bug #263, where nested >>IF directives were not handledcorrectly.• New constants: GCCOMP, GNUCOBOL.• New directives: >>LISTING, >>PAGE.
Identification division
• FUNCTION-ID: added checks for redefinition of function-names.• INITIAL phrase: fixed premature deallocation of INITIAL programs (bug #52).• PROGRAM-ID: added checks for redefinition of program-names.• PROGRAM-ID phrases: permit INITIAL or RECURSIVE before COMMON (bug #244).
xiv
Changelog
Environment division
• ASSIGN clause: missing ASSIGN clauses are now detected at compile-time.• ASSIGN clause: added PRINT and PRINTER-1 mnemonics.• CURRENCY phrase: fixed bug #182, where a preceding SWITCH phrase caused anincorrect duplicate CURRENCY clause error.• File-control entry: fixed bug #71, where referring a global constant caused aninternal error.• FUNCTION phrase: added checks for redefinition of function-(prototype-)names.• Locales: user-defined LOCALEDIR now supported.• Order of configuration section paragraphs: configuration section paragraphs areno longer allowed in any order (bug #224).• PROGRAM phrase: added support for program-prototype-names.• SIGN clause: improved syntax checks.• SWITCH phrase: added check for duplicate on/off clauses (bug #136).• SWITCH phrase: added new switch names: SWITCH-16 through to SWITCH-36(feature request #65), “SWITCH 1” to “SWITCH 26” (and their aliases “SWITCH A” to“SWITCH Z”).
Data division
• 78-level items: strengthened syntax checks.• 88-level items: strengthened syntax checks.• ANYLENGTHclause: ANYLENGTH itemsmay now longer beBYVALUEparameters(see bug #219).• BLANK clause: fixed bug #143, where BLANK LINE/SCREEN did not color line/screen.• BLANK WHEN ZERO clause: added checks that BLANK WHEN ZERO is not speci-fied with PICTURE clauses containing S.• Data description: sizes may no longer exceed the maximum permitted size.• ERASE clause: fixed bug#186, where ERASEEOL and ERASEEOS could be specifiedsimultaneously.• HIGHLIGHT and LOWLIGHT clauses: added checks that HIGHLIGHT and LOW-LIGHT are not specified simultaneously.
xv
Changelog
• Local-storage section: fixed bug #78, where local-storage items where initialisedafter file section items.• LOWLIGHT clause: implemented.• OCCURS clause (depending): require the minimum length to be less than themaximum length (feature request #99).• OCCURS clause (screen-section): require relative LINE/COLUMN clauses in OC-CURS entries (bug #83).• PICTURE clause: restricted number of permitted PICTURE strings (bug #232).• PICTURE clause: improved checks of constant-names referenced in PICTUREstrings.• RENAMES items: strengthened syntax checks.• Screen description: permit figurative constants in screen items (bug #108).• TALLY special register: added.
Procedure division
• ACCEPT statement: added ESCAPE as synonym for EXCEPTION.• ACCEPT statement: permit clauses in any order.• ACCEPT statement: allow WITH before every screen attribute clause.• ACCEPT statement (screen): fixed failed ACCEPTs caused by a buffer overflow.• ACCEPT statement (screen): enhanced support for special keys (insert, tab, delete,alt-delete, etc.).• ACCEPT statement (screen): fixed bug #161 where screens terminated after enter-ing a few characters in a field.• ACCEPT statement (screen): added DEFAULT as synonym for UPDATE.• ACCEPT statement (screen): ERASE and BLANK clauses in screens are now ig-nored (bug #192).• ACCEPT statement (screen): fixed bug #160 where ACCEPT statement LINE/COLUMN clauses did not work.• ACCEPT statement (screen): fixed segfault on ACCEPT OMITTED (bug #300).• ADD statement (corresponding): restricted to numeric items (bug #235).• Addition of COMP-3 numbers: fixed bug where COMP-3 addition failed.
xvi
Changelog
• Addition of floating-point numbers: fixed incorrect addition of floating-point num-bers.• CALL statement: implemented feature request #101, allowing more arguments tobe provided.• CALL statement: corrected CALL to cancelled modules.• CALL statement: added RETURNING NOTHING.• CANCEL statement: fixed crash caused by cancelling a cancelled module.• DISPLAY statement: permit clauses in any order.• DISPLAY statement: allow WITH before every screen attribute clause.• DISPLAY statement (screen): fixed bug where EC-SCREEN exceptions did nottrigger ON EXCEPTION handler (bug #243).• DISPLAY statement (screen): fixed bugs in DISPLAY SPACES/ALL X“02”/ALLX“07”.• END DECLARATIVES phrase: fixed bug #88, where an erroneous unreachable codewarning was emitted for code without a main procedure.• ENTRY statement: suppress incorrect unreachable code warnings.• Exception handlers: permit NOT ON EXCEPTION/END-OF-PAGE/etc. before ONEXCEPTION/END-OF-PAGE/etc.• EXIT statement: added extensionRETURNING/GIVINGclause for PROGRAMphrase.• File I-O: added detection of and handling for error when no disc space is availablefor output files.• FREE statement: NULL addresses no longer cause an exception.• GOBACK statement: added extension RETURNING/GIVING clause.• INITIALIZE statement: fixed bug #84, where literals could be passed to INITIALIZE.• INITIALIZE statement: fixed bug #287, where reference-modified group items werenot treated like elementary items.• INSPECT statement: fixed bug #47, where clauses were permitted in invalid orders.• LENGTH OF phrase: fixed bug #89.• MOVE statement: added more checks for overlapping MOVE statements.• Procedure division header: fixed bug #55, where a user-defined function withoutparameters failed to compile.
xvii
Changelog
• Procedure division header: disabled the BY VALUE phrase, pending a workingimplementation.• Procedure division header: added RETURNING OMITTED.• Reference modification: fixed bug #146.• Screen I-O: added detection of situations which raise EC-SCREEN-LINE-NUMBER,EC-SCREEN-STARTING-COLUMN and EC-SCREEN-ITEM-TRUNCATED.• Screen I-O: added support for the LINE 0 and COL 0 extensions.• SET statement (attribute): made HIGHLIGHT ON imply LOWLIGHT OFF and vice-versa.• SET statement (exception): added.• STOP statement (literal): fixed segfault.• STRING statement: strengthened syntax checks (bug #259).• SUBTRACT statement (corresponding): restricted to numeric items (bug #235).• Tracing: fixed bug #216.• UNSTRING statement: fixed bug #54 involving delimiter longer than one character.
Intrinsic functions
• New functions (COBOL 2014): FORMATTED-CURRENT-DATE, FORMATTED-DATE,FORMATTED-DATETIME, FORMATTED-TIME, INTEGER-OF-FORMATTED-DATE, TEST-FORMATTED-DATETIME.• ISO-8601-date-handling functions: added extension SYSTEM-OFFSET as replace-ment for last optional argument.• ISO-8601-date-handling functions: added EC-IMP-UTC-UNKNOWN if a time for-mat ending in Z is provided but the timezone cannot be found.• RANDOM function: fixed non-random number generation.
xviii
1. Key
Element NotesBraces, { } One element within the braces must be se-lected.Brackets, [ ] One or zero elements within the bracketsmust be selected.Vertical lines, | | Each element may be selected once and inany order; if within braces, at least one ele-ment must be selected.OPTIONAL-RESERVED-WORDMANDATORY-RESERVED-WORD Mandatory reservedwords in brackets are of-ten used instead of optional reserved wordsto indicate an optional feature.Deleted element These elements were previously in theCOBOL standard but have since beendeleted. Their use is strongly discouraged.Archaic element These elements remain in the standard, buttheir use is considered poor style and isstrongly discouraged.Obsolete element These elements are slated to be deleted fromthe standard. Their use is strongly discour-aged.X/Open extensionGnuCOBOL-only extensionMiscellaneous extension An extension which may have come fromCOBOL dialects by Micro Focus, IBM, Acu-Corp, Ryan-McFarland, Fujitsu or Microsoft.Unimplemented element These elements are recognised by Gnu-COBOL, but result in errors.
3
2. Compiler directives
2.1. D directive
>>D source-text-1
2.2. COPY statement
{COPYINCLUDE
} {literal-1text-name-1
} [{INOF} {literal-2
library-name-1}]
[SUPPRESS PRINTING]REPLACING
== pseudo-text-1 ==identifier-1literal-3
BY
== pseudo-text-2 ==identifier-2literal-4
{LEADINGTRAILING
}== partial-word-1 == BY == partial-word-2 ==
. . .
.
2.3. DEFINE directive
{>>$}
DEFINE [CONSTANT] compilation-variable-1 AS{literal-1PARAMETER
} [OVERRIDE]OFF
5
2. Compiler directives
2.4. DISPLAY directive
{>>$}
DISPLAY source-text-1
2.5. IF directive
{>>$}
IF compilation-variable-1 IS NOT
DEFINEDSETrelation compilation-variable-2
source-text-1[{ >>
$} {ELIF
ELSE-IF}
condition-1 source-text-2]. . .
[{>>$}
ELSE source-text-3]
[>>END-IF$END
]
2.6. LEAP-SECOND directive
>>LEAP-SECOND
2.7. LISTING directive
>>LISTING{ONOFF
}
6
2. Compiler directives
2.8. PAGE directive
>>PAGE [comment-text]
2.9. REPLACE statement
Format 1 (on)
REPLACE [ALSO]
{== pseudo-text-1 ==identifier-1
}BY{== pseudo-text-2 ==identifier-2
}{LEADINGTRAILING
}== partial-word-1 == BY == partial-word-2 ==
. . . .
Format 2 (off)
REPLACE [LAST] OFF.
2.10. SET directive
{ >>$
}SET
CONSTANT compilation-variable-1 AS literal-1compilation-variable-2 [AS literal-2]
SOURCEFORMAT AS literal-3{NO-FOLD-COPY-NAMENOFOLDCOPYNAME
}{FOLD-COPY-NAMEFOLDCOPYNAME
}AS literal-4
. . .
7
2. Compiler directives
2.11. SOURCE directive
>>SOURCE FORMAT IS{FIXEDFREE
}
2.12. TURN directive
>>TURN {exception-name-1} . . .[ONOFF
] [WITH LOCATION]
2.13. Miscellaneous directives
• EJECT• PROCESS• SKIP1• SKIP2• SKIP3
8
3. Compilation group
[program-definitionfunction-definition
]. . .
where program-definition is[{IDENTIFICATIONID
}DIVISION.
]
PROGRAM-ID.{program-name-1
literal-1}[AS literal-2]
IS
∣∣∣∣∣∣∣COMMON{INITIALRECURSIVE
}∣∣∣∣∣∣∣
EXTERNAL
PROGRAM.
[comment-paragraphs][environment-division][data-division][procedure-division [program-definition] . . .][END PROGRAM
{program-name-1literal-1
}.]
where function-definition is[{IDENTIFICATIONID
}DIVISION.
]
FUNCTION-ID.{program-name-1
literal-3} [AS literal-4].[comment-paragraphs][environment-division][data-division]
10
4. Identification division
[{IDENTIFICATIONID
}DIVISION.
]{function-id-paragraphprogram-id-paragraph
}
∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣
AUTHOR. comment-text.DATE-WRITTEN. comment-text.DATE-MODIFIED. comment-text.DATE-COMPILED. comment-text.INSTALLATION. comment-text.REMARKS. comment-text.SECURITY. comment-text.
∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣
. . .
4.1. PROGRAM-ID paragraph
PROGRAM-ID.{program-name-1literal-1
} [AS literal-2]IS
∣∣∣∣∣∣∣COMMON{INITIALRECURSIVE
}∣∣∣∣∣∣∣
EXTERNAL
PROGRAM.
13
4. Identification division
4.2. FUNCTION-ID paragraph
FUNCTION-ID.{function-name-1literal-1
} [AS literal-2].
14
5. Environment division
[ENVIRONMENT DIVISION.][configuration-section][input-output-section]
5.1. Configuration section
[CONFIGURATION SECTION.][∣∣∣∣∣source-computer-paragraphobject-computer-paragraph
∣∣∣∣∣]
[special-names-paragraph][special-names-entry][repository-paragraph]
5.1.1. SOURCE-COMPUTER paragraph
SOURCE-COMPUTER.[{computer-name-1} . . . [WITH DEBUGGING MODE] .
]
5.1.2. OBJECT-COMPUTER paragraph
OBJECT-COMPUTER.
16
5. Environment division
[{computer-name-1} . . . ]
MEMORY SIZE IS integer-1{CHARACTERSWORDS
}PROGRAM COLLATING SEQUENCE IS collating-sequence-1SEGMENT-LIMIT IS integer-2
CHARACTER CLASSIFICATION IS
locale-name-1LOCALESYSTEM-DEFAULTUSER-DEFAULT
. . . .
5.1.3. SPECIAL-NAMES paragraph
[SPECIAL-NAMES.]
mnemonic-name-clausealphabet-name-clausesymbolic-characters-clauseLOCALE locale-name-1 IS literal-1CLASS class-name-1 IS
{literal-2
[{THRUTHROUGH
}literal-3
]}. . .
CURRENCY SIGN IS literal-4 [WITH PICTURE-SYMBOL literal-5 ]DECIMAL-POINT IS COMMANUMERIC SIGN IS TRAILING SEPARATECURSOR IS identifier-1CRT STATUS IS identifier-2SCREEN-CONTROL IS identifier-3EVENT-STATUS IS identifier-4
. . . .
. . .
where mnemonic-name-clause is
mnemonic-name-1
IS CRTinteger-1 IS system-name-1[IS switch-name-1] {∣∣∣∣∣ON STATUS IS switch-status-name-1
OFF STATUS IS switch-status-name-2∣∣∣∣∣}
17
5. Environment division
where alphabet-name-clause is
ALPHABET alphabet-name-1 IS
ASCIIEBCDICNATIVESTANDARD-1STANDARD-2literal-6
{THROUGHTHRU
}literal-7{ALSO literal-8}. . .
. . .
where symbolic-characters-clause isSYMBOLICCHARACTERS
{{symbolic-character-name-1}. . .{ISARE
} {integer-2}. . .}. . .[IN WORD]
5.1.4. REPOSITORY paragraph
REPOSITORY.
FUNCTION{{function-name-1}. . .ALL
}INTRINSIC
FUNCTION function-name-2 [AS literal-1]. . . .
5.2. Input-output section
[INPUT-OUTPUT SECTION.][file-control-paragraph][i-o-control-paragraph]
18
5. Environment division
5.2.1. FILE-CONTROL paragraph
[FILE-CONTROL.][file-control-entry] . . .where file-control-entry is
SELECT[OPTIONALNOT OPTIONAL
]file-name-1
assign-clauseaccess-mode-clausealternative-record-key-clausecollating-sequence-clausefile-status-clauselock-mode-clauseorganization-clausepadding-character-clauserecord-delimiter-clauserecord-key-clauserelative-key-clausereserve-clausesharing-clause
. . . .
where assign-clause is
ASSIGN[TOUSING
] [DYNAMICEXTERNAL
]
[LINE ADVANCING FILE] {literal-1identifier-1
}
DISCDISKDISPLAYKEYBOARDPRINTER-1PRINTERPRINTRANDOMTAPE
[literal-2identifier-2
]
where access-mode-clause is
19
5. Environment division
ACCESS MODE IS
SEQUENTIALDYNAMICRANDOM
where alternative-record-key-clause isALTERNATERECORDKEY IS identifier-3
[{=SOURCE IS
} {identifier-4}. . .] [WITH DUPLICATES]SUPPRESS WHEN
ALL literal-3SPACEZERO
where collating-sequence-clause isCOLLATING SEQUENCE IS collating-sequence-name-1where file-status-clause is[FILESORT
]STATUS IS identifier-5
where lock-mode-clause is
LOCKMODE IS
{MANUALAUTOMATIC
}WITH
LOCK ON MULTIPLE{RECORDRECORDS
}ROLLBACK
EXCLUSIVE
where organization-clause is[{ORGANIZATION
ORGANISATION}
IS]
INDEXEDLINE SEQUENTIALRECORD BINARY SEQUENTIALRELATIVE
where padding-character-clause isPADDING CHARACTER IS
{identifier-6literal-4
}
20
5. Environment division
where record-delimiter-clause isRECORD DELIMITER IS STANDARD-1where record-key-clause isRECORD KEY IS identifier-7
[{=SOURCE IS
} {identifier-8}. . .]
where relative-key-clause isRELATIVE KEY IS identifier-9where reserve-clause isRESERVE
{NOinteger-1
}AREA
where sharing-clause is
SHARING WITH
ALL OTHERNO OTHERREAD ONLY
5.2.2. I-O-CONTROL paragraph
[I-O-CONTROL.]SAME
RECORDSORTSORT-MERGE
AREA FOR {file-name-1}. . .MULTIPLE FILE TAPE CONTAINS {file-name-2 [POSITION integer-1]}. . .
. . . .
21
6. Data division
[DATA DIVISION.][file-section][working-storage-section][local-storage-section][report-section][screen-section]
6.1. File section
[FILE SECTION.]{file-description-entry
{record-descriptionconstant-definition
}. . .}. . .
23
6. Data division
6.1.1. File description entry
{FDSD}
file-name-1
block-clauseCODE-SET IS alphabet-name-1 [FOR {identifier-1} . . .]DATA
{RECORD ISRECORDS ARE
} {identifier-2}. . .IS EXTERNALIS GLOBALLABEL
{RECORD ISRECORDS ARE
} {STANDARDOMITTED
}linage-clause
RECORDING MODE IS
{FFIXED
}{VVARIABLE
}US
{REPORT ISREPORTS ARE
} {identifier-3}. . .VALUE OF
FILE-IDIDidentifier-4
IS{literal-1identifier-5
}
record-clause
. . . .
6.2. Working-storage section
WORKING-STORAGE SECTION.[constant-definitionrecord-description
]. . .
24
6. Data division
6.3. Local-storage section
LOCAL-STORAGE SECTION.[constant-definitionrecord-description
]. . .
6.4. Linkage section
LINKAGE SECTION.[constant-definitionrecord-description
]. . .
6.5. Report section
REPORT SECTION.[constant-definitionreport-description
]. . .
6.5.1. Report description
RD report-name-1
IS GLOBALCODE IS {identifier-1 literal-1}{CONTROL ISCONTROLS ARE
}FINAL {identifier-2}. . .
PAGE[LIMIT ISLIMITS ARE
]integer-1
[LINELINES
] [integer-2
{COLUMNSCOLS
}]
. . . .
{report-group-description-1}. . .
25
6. Data division
Report group description
level-number entry-name
blank-clausecolumn-clauseGROUP INDICATEjustified-clauseline-clausenext-group-clausepicture-clausepresent-when-clauseoccurs-clausesign-clausesource-clausesum-clausetype-clauseUSAGE IS DISPLAYvalue-clausevarying-clause
. . . .
6.6. Screen section
SCREEN SECTION.[constant-definitionscreen-description
]. . .
26
6. Data division
6.6.1. Screen description
level-number entry-name
AUTOAUTO-SKIPAUTOTERMINATE
BLANK
{LINESCREEN
}BLINKcolumn-clause
ERASE
EOLEOS[END OF] {LINE
SCREEN}{FULL
LENGTH-CHECK}
IS GLOBALGRIDINITIALLEFTLINEjustified-clauseline-clauseoccurs-clauseOVERLINEpicture-clausePROMPT
[CHARACTER IS
{identifier-1literal-1
}]{REQUIRED
EMPTY-CHECK}
screen-attribute-clausessource-destination-clausesSECUREsign-clauseusage-clausevalue-clause
. . . .
where screen-attribute-clauses is
27
6. Data division
[BELLBEEP
][HIGHLIGHTLOWLIGHT
][REVERSE-VIDEO][UNDERLINE][{FOREGROUND-COLOR
FOREGROUND-COLOUR}
IS{identifier-2integer-1
}][{BACKGROUND-COLOR
BACKGROUND-COLOUR}
IS{identifier-3integer-2
}]
where source-destination-clauses is[FROM
{identifier-4literal-2
}][TO identifier-5][USING identifier-6]
6.7. Record description
Format 1 (data-description)
28
6. Data division
level-number entry-name
ANY{LENGTH
NUMERIC}
blank-clauseIS EXTERNAL [AS literal-1]IS GLOBALjustified-clauseoccurs-clausePICTURE picture-string-1REDEFINES identifier-1sign-clause
SYNCHRONIZEDSYNCHRONISEDSYNC
[LEFTRIGHT
]
usage-clausevalue-clause
. . . .
Format 2 (renames)
66 identifier-2 RENAMES identifier-3[{THROUGH
THRU}
identifier-4].
Format 3 (condition-name)
88 identifier-5{VALUEVALUES
} [ISARE
] {literal-2
[{THROUGHTHRU
}literal-3
]}. . .
[WHEN SET TO FALSE IS literal-4].
6.8. Constant definition
Format 1 (standard)
29
6. Data division
{101}
identifier-1 CONSTANT [IS GLOBAL]
AS
literal-1{BYTE-LENGTHLENGTH
}OF identifier-2
FROM identifier-3
.
Format 2 (micro-focus)
78 identifier-4 [IS GLOBAL] VALUE[ISARE
]literal-2 .
6.9. Data division clauses
6.9.1. BLANK WHEN ZERO clause
BLANK WHEN ZERO
6.9.2. BLOCK clause
BLOCK CONTAINS integer-1 [TO integer-2] [CHARACTERSRECORDS
]
6.9.3. COLUMN clause
Format 1 (report-section)
{COLUMNCOL
}NUMBERS
[ISARE
]{COLUMNSCOLS
}ARE
{[PLUS] integer-1} . . .
30
6. Data division
Format 2 (screen-section)
{COLUMNCOL
}NUMBER IS
+-PLUSMINUS
{identifier-1integer-2
}
6.9.4. Entry name
[FILLERidentifier-1
]
6.9.5. JUSTIFIED clause
JUSTIFIED RIGHT
6.9.6. LINAGE clause
LINAGE IS{identifier-1literal-1
}LINES
BOTTOMTOPWITH FOOTING AT
{identifier-2literal-2
} . . .
6.9.7. LINE clause
Format 1 (report section)LINE NUMBERS[ISARE
]LINES ARE
{[PLUS] integer-1NEXT PAGE
}. . .
Format 2 (screen section)
31
6. Data division
LINE NUMBER IS+-MINUSPLUS
{identifier-1integer-2
}
6.9.8. Level-number
A 1- or 2-digit integer having a value that is either between 1 and 49 or is 66, 77, 78 or 88.
6.9.9. NEXT GROUP clause
NEXT GROUP IS{[PLUS] integer-1NEXT PAGE
}
6.9.10. OCCURS clause
Format 1 (usual)
OCCURSinteger-1 [TO integer-2] TIMES [DEPENDING ON identifier-1]DYNAMIC [CAPACITY IN identifier-2] [FROM integer-3] [TO integer-4] [INITIALIZED]
[{ASCENDING
DESCENDING}
KEY IS {identifier-3}. . .]. . .[INDEXED BY {index-name-1}. . .]
Format 2 (report section)
OCCURS integer-5 [TO integer-6]TIMES [DEPENDING ON identifier-4] [STEP integer-7]
32
6. Data division
Format 3 (screen section)
OCCURS integer-8 TIMES
6.9.11. PRESENT WHEN clause
PRESENT WHEN condition-1
6.9.12. RECORD clause
RECORD
CONTAINS integer-1 [TO integer-2] CHARACTERSIS VARYING in size [FROM integer-3] [TO integer-4] CHARACTERS
DEPENDING ON identifier-1
6.9.13. SIGN clause
SIGN IS{LEADINGTRAILING
} [SEPARATE CHARACTER]
6.9.14. SOURCE clause
SOURCE IS number-1 [rounded-phrase]
6.9.15. SUM clause
SUM OF {number-2}. . .[RESET ON{identifier-1FINAL
}]
33
6. Data division
6.9.16. TYPE clause
TYPE IS
{CONTROL HEADINGCH
}{CONTROL FOOTINGCF
}{identifier-1FINAL
} [OR PAGE]{DETAILDE
}{PAGE FOOTINGPF
}{PAGE HEADINGPH
}{REPORT FOOTINGRF
}{REPORT HEADINGRH
}
6.9.17. USAGE clause
[USAGE IS]
BINARYfixed-length-integerscomputational-usagesDISPLAYFLOAT-BINARY-32FLOAT-BINARY-64FLOAT-BINARY-128FLOAT-DECIMAL-16FLOAT-DECIMAL-34FLOAT-LONGFLOAT-SHORTINDEXNATIONALPACKED DECIMALPOINTERPROGRAM-POINTER
34
6. Data division
where fixed-length-integers is
BINARY-CHAR{BINARY-LONGBINARY-INT
}BINARY-C-LONG{BINARY-DOUBLEBINARY-LONG-LONG
}
[SIGNEDUNSIGNED
]
SIGNED-SHORTSIGNED-INTSIGNED-LONGUNSIGNED-SHORTUNSIGNED-INTUNSIGNED-LONG
where computation-usages is
{COMPCOMPUTATIONAL
}{COMP-1COMPUTATIONAL-1
}{COMP-2COMPUTATIONAL-2
}{COMP-3COMPUTATIONAL-3
}{COMP-4COMPUTATIONAL-4
}{COMP-5COMPUTATIONAL-5
}{COMP-6COMPUTATIONAL-6
}{COMP-XCOMPUTATIONAL-X
}
35
6. Data division
6.9.18. VALUE clause
Format 1 (initialization){VALUEVALUES
} [ISARE
]literal-1
Format 2 (condition){VALUEVALUES
} [ISARE
] {literal-2
[{THROUGHTHRU
}literal-3
]}. . .
[WHEN SET TO FALSE IS literal-4]
6.9.19. VARYING clause
VARYING identifier-1 FROM number-1 BY number-2
36
7. Procedure division
PROCEDURE DIVISION [using-chaining-clause] [RETURNING{identifier-1OMITTED
}].[declaratives]section-name-2 SECTION.
paragraph-name-2.imperative-statement-1 .
. . .
where using-chaining-clause is{USINGCHAINING
}BY
{REFERENCEVALUE
} [UNSIGNED] SIZE IS
{AUTOinteger-1
}SIZE IS DEFAULT
[OPTIONAL] identifier-2. . .
where declaratives isDECLARATIVES.[section-name-1 SECTION. use-statement [[paragraph-name-2.] imperative-statement-2 .] . . .]. . .END DECLARATIVES.
38
7. Procedure division
7.1. Common phrases
7.1.1. ROUNDED phrase
ROUNDED
MODE IS
AWAY-FROM-ZERONEAREST-AWAY-FROM-ZERONEAREST-EVENNEAREST-TOWARD-ZEROPROHIBITEDTOWARD-GREATERTOWARD-LESSERTRUNCATION
7.1.2. SIZE phrase
SIZE IS AUTOSIZE IS DEFAULTSIZE IS integer-1UNSIGNED SIZE IS AUTOUNSIGNED SIZE IS integer-2
7.2. ACCEPT statement
Format 1 (device)
ACCEPT{identifier-1
OMITTED} [FROM mnemonic-name-1] [END-ACCEPT]
Format 2 (screen)
ACCEPT{identifier-2
OMITTED}
39
7. Procedure division
∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣
∣∣∣∣∣∣∣∣∣∣∣∣
AT LINE NUMBER{identifier-3integer-1
}
AT
COLUMNCOLPOSITION
NUMBER{identifier-4integer-2
}∣∣∣∣∣∣∣∣∣∣∣∣
AT{identifier-5integer-3
}
FROM CRTMODE IS BLOCKscreen-attribute-clauses
∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣∣
where screen-attribute-clauses is[WITH AUTO][WITH TAB][WITH
{BELLBEEP
}][WITH BLINK][WITH CONVERSION][WITH
{FULLLENGTH-CHECK
}][WITH
{HIGHLIGHTLOWLIGHT
}][WITH LEFTLINE][WITH LOWER][WITH NO-ECHO]
40
7. Procedure division
[WITH OVERLINE][WITH PROMPT
[CHARACTER IS
{identifier-6literal-1
}]][WITH
{REQUIREDEMPTY-CHECK
}][WITH REVERSE-VIDEO][WITH SECURE][WITH PROTECTED SIZE IS
{identifier-7integer-4
}][WITH UNDERLINE][WITH [NO] {DEFAULT
UPDATE}]
[WITH UPPER][WITH
{FOREGROUND-COLORFOREGROUND-COLOUR
}IS{identifier-8integer-5
}][WITH
{BACKGROUND-COLORBACKGROUND-COLOUR
}IS{identifier-9integer-6
}][WITH SCROLL UP
[identifier-10integer-7
] {LINELINES
}][WITH SCROLL DOWN
[identifier-11integer-8
] {LINELINES
}][WITH
{TIMEOUTTIME-OUT
}AFTER
[identifier-12integer-9
]]
41
7. Procedure division
Format 3 (temporal)
ACCEPT identifier-13 FROM
DATE [YYYYMMDD]DAY [YYYYDDD]DAY-OF-WEEKTIME
Format 4 (environment)
ACCEPT identifier-14 FROM
ARGUMENT-NUMBER{COLUMNSCOLS
}COMMAND-LINEESCAPE KEYEXCEPTION STATUS{LINESLINE NUMBER
}USER NAMEWORD
Format 5 (environment-exception)
ACCEPT identifier-15 FROM
ARGUMENT-VALUEENVIRONMENT
{identifier-16literal-2
}ENVIRONMENT-VALUE
∣∣∣∣∣∣∣∣∣∣ON
{EXCEPTIONESCAPE
}imperative-statement-1
NOT ON{EXCEPTIONESCAPE
}imperative-statement-2
∣∣∣∣∣∣∣∣∣∣
42
7. Procedure division
7.3. ADD statement
Format 1 (simple)
ADD{identifier-1literal-1
}. . .TO {identifier-2} . . .
[∣∣∣∣∣ON SIZE ERROR imperative-statement-1NOT ON SIZE ERROR imperative-statement-2
∣∣∣∣∣]
[END-ADD]
Format 2 (giving)
ADD{identifier-3literal-2
}. . .[TO [identifier-4] . . .]
GIVING {identifier-5 [rounded-phrase]} . . .[∣∣∣∣∣ON SIZE ERROR imperative-statement-3
NOT ON SIZE ERROR imperative-statement-4∣∣∣∣∣]
[END-ADD]
Format 3 (corresponding)
ADD{CORRESPONDINGCORR
}identifier-6 TO identifier-7 [rounded-phrase]
[∣∣∣∣∣ON SIZE ERROR imperative-statement-5NOT ON SIZE ERROR imperative-statement-6
∣∣∣∣∣]
[END-ADD]
43
7. Procedure division
7.4. ALLOCATE statement
ALLOCATE
identifier-1 [INITIALIZED]arithmetic-expression-1
INITIALIZED[TO{identifier-2literal-1
}]
[RETURNING identifier-3]
7.5. ALTER statement
ALTER {procedure-name-1 TO PROCEED TO procedure-name-2} . . .
7.6. CALL statement
CALLmnemonic-name-1STATICSTDCALL
identifier-1literal-1function-name-1
USING
BY
REFERENCECONTENTVALUE
OMITTED[size-phrase] {identifier-2literal-2
}. . .
{RETURNING
GIVING}
INTO identifier-3ADDRESS OF identifier-4NOTHINGNULLOMITTED
∣∣∣∣∣∣∣ON
{EXCEPTIONOVERFLOW
}imperative-statement-1
NOT ON EXCEPTION imperative-statement-2
∣∣∣∣∣∣∣
44
7. Procedure division
[END-CALL]
7.7. CANCEL statement
CANCEL{identifier-1literal-1
}. . .
7.8. CLOSE statement
CLOSEfile-name-1
{REELUNIT
} [FOR REMOVAL]WITH NO REWINDWITH LOCK
. . .
7.9. COMMIT statement
COMMIT
7.10. COMPUTE statement
COMPUTE {identifier-1 [rounded-phrase]} . . .
=EQUALEQUALS
arithmetic-expression-1
[∣∣∣∣∣ON SIZE ERROR imperative-statement-1NOT ON SIZE ERROR imperative-statement-2
∣∣∣∣∣]
[END-COMPUTE]
45
7. Procedure division
7.11. CONTINUE statement
CONTINUE
7.12. DELETE statement
Format 1 (record)
DELETE file-name-1 RECORD[∣∣∣∣∣INVALID KEY imperative-statement-1NOT INVALID KEY imperative-statement-2
∣∣∣∣∣]
[END-DELETE]
Format 2 (file)
DELETE FILE {file-name-2} . . . [END-DELETE]
7.13. DISPLAY statement
Format 1 (device)
DISPLAY{identifier-1literal-1
}. . .[∣∣∣∣∣UPON mnemonic-name-1
WITH NO ADVANCING∣∣∣∣∣]
[∣∣∣∣∣ON EXCEPTION imperative-statement-1NOT ON EXCEPTION imperative-statement-2
∣∣∣∣∣]
[END-DISPLAY]
Format 2 (environment)
46
7. Procedure division
DISPLAY{identifier-2literal-2
}UPON
ARGUMENT-NUMBERCOMMAND-LINEENVIRONMENT-NAMEENVIRONMENT-VALUE
[∣∣∣∣∣ON EXCEPTION imperative-statement-3NOT ON EXCEPTION imperative-statement-4
∣∣∣∣∣]
[END-DISPLAY]
Format 3 (screen)
47
7. Procedure division
DISPLAY
identifier-3literal-3OMITTED
position-clausesUPON
{CRTCRT-UNDER
}MODE IS BLOCKWITH
{BELLBEEP
}
WITH BLANK{LINESCREEN
}WITH BLINKWITH CONVERSION
WITH ERASE
EOLEOS[END OF] {LINE
SCREEN}
WITH{HIGHLIGHTLOWLIGHT
}WITH OVERLINEWITH REVERSE-VIDEOWITH SIZE IS
{identifier-4literal-4
}WITH UNDERLINEWITH
{FOREGROUND-COLORFOREGROUND-COLOUR
}IS{identifier-5integer-1
}
WITH{BACKGROUND-COLORBACKGROUND-COLOUR
}IS{identifier-6integer-2
}
WITH SCROLL UP[identifier-7integer-3
] {LINELINES
}
WITH SCROLL DOWN[identifier-8integer-4
] {LINELINES
}
. . .
[∣∣∣∣∣ON EXCEPTION imperative-statement-5NOT ON EXCEPTION imperative-statement-6
∣∣∣∣∣]
[END-DISPLAY]where position-clauses is
48
7. Procedure division
∣∣∣∣∣∣∣∣∣∣∣∣
LINE NUMBER{identifier-9literal-5
}
AT
COLUMNCOLPOSITION
{identifier-10literal-6
}∣∣∣∣∣∣∣∣∣∣∣∣
AT{identifier-11literal-7
}
7.14. DIVIDE statement
Format 1 (into)
DIVIDE{identifier-1literal-1
}INTO
{{identifier-2literal-2
} [rounded-phrase]} . . .[∣∣∣∣∣ON SIZE ERROR imperative-statement-1
NOT ON SIZE ERROR imperative-statement-2∣∣∣∣∣]
[END-DIVIDE]
Format 2 (giving)
DIVIDE{identifier-3literal-3
} {BYINTO
} {identifier-4literal-4
}
GIVING{{identifier-5
literal-5} [rounded-phrase]} . . .
[REMAINDER
{identifier-6literal-6
}][∣∣∣∣∣ON SIZE ERROR imperative-statement-3
NOT ON SIZE ERROR imperative-statement-4∣∣∣∣∣]
[END-DIVIDE]
49
7. Procedure division
7.15. ENTRY statement
ENTRY literal-1USINGBY
REFERENCECONTENTVALUE
OMITTED{ [size-phrase] {identifier-1literal-2
}}. . .
7.16. EVALUATE statement
EVALUATE
expression-1TRUEFALSE
ALSO
expression-2TRUEFALSE
. . .
{WHEN selection-object [ALSO selection-object]. . . imperative-statement-1} . . .[WHEN OTHER imperative-statement-2][END-EVALUATE]where selection-object is
partial-expression-3[{THROUGH
THRU}
expression-4]
ANYTRUEFALSE
50
7. Procedure division
7.17. EXIT statement
EXIT
FUNCTIONPARAGRAPHPERFORM [CYCLE]PROGRAM
[{RETURNINGGIVING
}] {identifier-1literal-1
}SECTION
7.18. FREE statement
FREE {identifier-1} . . .
7.19. GENERATE statement
GENERATE report-name-1
7.20. GO TO statement
GO TO {procedure-name-1} . . .[DEPENDING ON identifier-1]
7.21. GOBACK statement
GOBACK[{RETURNING
GIVING} {identifier-1
literal-1}]
51
7. Procedure division
7.22. IF statement
IF condition THEN{imperative-statement-1ELSE imperative-statement-2
}. . .
[END-IF]
7.23. INITIALIZE statement
{INITIALIZEINITIALISE
} {identifier-1basic-literal-1
}. . .[WITH FILLER]
ALLALPHABETICALPHANUMERICALPHANUMERIC-EDITEDNATIONALNATIONAL-EDITEDNUMERICNUMERIC-EDITED
TO VALUE
REPLACING
ALPHABETICALPHANUMERICALPHANUMERIC-EDITEDNATIONALNATIONAL-EDITEDNUMERICNUMERIC-EDITED
DATA BY
{identifier-2literal-2
}
. . .
[THEN TO DEFAULT]
52
7. Procedure division
7.24. INITIATE statement
INITIATE {report-name-1} . . .
7.25. INSPECT statement
INSPECT
identifier-1literal-1function-name-1
tallying-phrase [replacing-phrase]replacing-phraseconverting-phrase
where tallying-phrase is
TALLYING
{identifier-2literal-2
}FOR
CHARACTERS
ALLLEADINGTRAILING
{identifier-3literal-3
}
. . .[before-after-phrase]. . .
where replacing-phrase is
REPLACING
CHARACTERSALLLEADINGFIRSTTRAILING
{identifier-4literal-4
}
BY{identifier-5literal-5
} [before-after-phrase]. . .
where converting-phrase isCONVERTING
{identifier-6literal-6
}TO{identifier-7literal-7
} [before-after-phrase]where before-after-phrase is∣∣∣∣∣∣∣∣∣∣BEFORE INITIAL
{identifier-8literal-8
}
AFTER INITIAL{identifier-9literal-9
}∣∣∣∣∣∣∣∣∣∣
53
7. Procedure division
7.26. MERGE statement
MERGE identifier-1[ON
{ASCENDINGDESCENDING
}KEY [identifier-2]. . .] . . .
[WITH DUPLICATES [IN ORDER]][COLLATING SEQUENCE IS identifier-3][USING {file-name-1}. . .]GIVING {file-name-2}. . .OUTPUT PROCEDURE IS procedure-name-1
[{THROUGHTHRU
}procedure-name-2
]
7.27. MOVE statement
MOVE[CORRESPONDINGCORR
] {identifier-1literal-1
}TO {identifier-2} . . .
7.28. MULTIPLY statement
Format 1 (simple)
MULTIPLY{identifier-1literal-1
}BY{{identifier-2
literal-2} [rounded-phrase]} . . .
[∣∣∣∣∣ON SIZE ERROR imperative-statement-1NOT ON SIZE ERROR imperative-statement-2
∣∣∣∣∣]
[END-MULTIPLY]
54
7. Procedure division
Format 2 (giving)
MULTIPLY{identifier-3literal-3
}BY{identifier-4literal-4
}
GIVING{{identifier-5
literal-5} [rounded-phrase]} . . .
[∣∣∣∣∣ON SIZE ERROR imperative-statement-3NOT ON SIZE ERROR imperative-statement-4
∣∣∣∣∣]
[END-MULTIPLY]
7.29. NEXT SENTENCE statement
NEXT SENTENCE
7.30. OPEN statement
OPEN
INPUTOUTPUTI-OEXTEND
SHARING WITH
ALL OTHERNO OTHERREAD ONLY
{file-name-1} . . .
WITH NO REWINDWITH LOCKREVERSED
. . .
7.31. PERFORM statement
Format 1 (procedure)
PERFORM procedure-name-1[{THROUGH
THRU}
procedure-name-2]
FOREVERtimes-phraseuntil-phrasevarying-phrase
55
7. Procedure division
Format 2 (inline)
PERFORM
FOREVERtimes-phraseuntil-phrasevarying-phrase
imperative-statement-1 [END-PERFORM]
where times-phrase isidentifier-1literal-1function-name-1
TIMES
where until-phrase is[WITH TEST
{BEFOREAFTER
}]UNTIL
{condition-1EXIT
}
and where varying-phrase is[WITH TEST
{BEFOREAFTER
}]
VARYING identifier-2 FROM{identifier-3literal-2
}BY{identifier-4literal-3
}UNTIL condition-2
[AFTER identifier-5 FROM
{identifier-6literal-4
}BY{identifier-7literal-5
}UNTIL condition-3
]. . .
7.32. READ statement
READ file-name-1[NEXTPREVIOUS
]RECORD [INTO identifier-1]
56
7. Procedure division
IGNORING LOCKWITH
KEPTNOIGNORE
LOCKWITH WAIT
[KEY IS identifier-2]{∣∣∣∣∣INVALID KEY imperative-statement-1
NOT INVALID KEY imperative-statement-2∣∣∣∣∣}
{∣∣∣∣∣AT END imperative-statement-3NOT AT END imperative-statement-4
∣∣∣∣∣}
[END-READ]
7.33. READY statement
READY TRACE
7.34. RELEASE statement
RELEASE identifier-1FROM
identifier-2literal-1function-call-1
7.35. RESET statement
RESET TRACE
57
7. Procedure division
7.36. RETURN statement
RETURN file-name-1 RECORD [INTO identifier-1]AT END imperative-statement-1[NOT AT END imperative-statement-2][END-RETURN]
7.37. REWRITE statement
REWRITE record-name-1FROM
identifier-1literal-1function-name-1
[WITH [NO] LOCK]
[∣∣∣∣∣INVALID KEY imperative-statement-1NOT INVALID KEY imperative-statement-2
∣∣∣∣∣]
[END-REWRITE]
7.38. ROLLBACK statement
ROLLBACK
7.39. SEARCH statement
Format 1 (simple)
SEARCH identifier-1 [VARYING identifier-2][AT END imperative-statement-1]
58
7. Procedure division
{WHEN condition-1 imperative-statement-2} . . .[END-SEARCH]
Format 2 (all)
SEARCH ALL identifier-3[AT END imperative-statement-3]WHEN expression-1 imperative-statement-4[END-SEARCH]
7.40. SET statement
Format 1 (simple)
SET identifier-1 TO
identifier-2literal-1arithmetic-expression-1
Format 2 (entry)
SET identifier-3 TO ENTRY{identifier-4literal-2
}
Format 3 (environment)
SET ENVIRONMENT{identifier-5literal-3
}TO{identifier-6literal-4
}
Format 4 (attribute)
59
7. Procedure division
SET identifier-7 ATTRIBUTE
{BELLBEEP
}BLINKHIGHLIGHTLOWLIGHTREVERSE-VIDEOUNDERLINELEFTLINEOVERLINE
{ONOFF
}
. . .
Format 5 (arithmetic)
SET {index-name-1}. . .{UPDOWN
}BY arithmetic-expression-2
Format 6 (on/off)
SET{{mnemonic-name-1}. . .TO {ON
OFF}}
. . .
Format 7 (true/false)
SET{{condition-name-1}. . .TO {TRUE
FALSE}}
. . .
Format 8 (exception)
SET LAST EXCEPTION TO OFF
7.41. SORT statement
SORT identifier-1[ON
{ASCENDINGDESCENDING
}KEY [identifier-2]. . .] . . .
60
7. Procedure division
[WITH DUPLICATES [IN ORDER]][COLLATING SEQUENCE IS identifier-3]USING {file-name-1}. . .INPUT PROCEDURE IS procedure-name-1
[{THROUGHTHRU
}procedure-name-2
]GIVING {file-name-2}. . .OUTPUT PROCEDURE IS procedure-name-3
[{THROUGHTHRU
}procedure-name-4
]
7.42. START statement
START file-name-1FIRSTKEY IS relational-operator identifier-1LAST
[WITH
{SIZELENGTH
}arithmetic-expression-1
][∣∣∣∣∣INVALID KEY imperative-statement-1
NOT INVALID KEY imperative-statement-2∣∣∣∣∣]
[END-START]
7.43. STOP statement
Format 1 (standard)
61
7. Procedure division
STOP RUN{RETURNING
GIVING} {identifier-1
literal-1}
WITH{ERRORNORMAL
}STATUS
[identifier-2literal-2
]
Format 2 (literal)
STOP literal-3
Format 3 (ACUCOBOL)
STOP RUN{identifier-3literal-4
}
7.44. STRING statement
STRING{identifier-1literal-1
} DELIMITED BY
SIZEidentifier-2literal-2
. . . INTO identifier-3
[WITH POINTER IS identifier-4][∣∣∣∣∣ON OVERFLOW imperative-statement-1
NOT ON OVERFLOW imperative-statement-2∣∣∣∣∣]
7.45. SUBTRACT statement
Format 1 (simple)
SUBTRACT{identifier-1literal-1
}. . . FROM
{{identifier-2literal-2
} [rounded-phrase]} . . .
62
7. Procedure division
[∣∣∣∣∣ON SIZE ERROR imperative-statement-1NOT ON SIZE ERROR imperative-statement-2
∣∣∣∣∣]
[END-SUBTRACT]
Format 2 (giving)
SUBTRACT{identifier-3literal-3
}. . . FROM
{identifier-4literal-4
}
GIVING{{identifier-5
literal-5} [rounded-phrase]} . . .
[∣∣∣∣∣ON SIZE ERROR imperative-statement-3NOT ON SIZE ERROR imperative-statement-4
∣∣∣∣∣]
[END-SUBTRACT]
Format 3 (corresponding)
SUBTRACT{CORRCORRESPONDING
}identifier-6 FROM identifier-7 [rounded-phrase]
[∣∣∣∣∣ON SIZE ERROR imperative-statement-5NOT ON SIZE ERROR imperative-statement-6
∣∣∣∣∣]
[END-SUBTRACT]
7.46. SUPPRESS statement
SUPPRESS PRINTING
63
7. Procedure division
7.47. TERMINATE statement
TERMINATE {report-name-1} . . .
7.48. TRANSFORM statement
TRANSFORM identifier-1 FROM{identifier-2literal-1
}TO{identifier-3literal-2
}
7.49. UNLOCK statement
UNLOCK file-name-1[RECORDRECORDS
]
7.50. UNSTRING statement
UNSTRING identifier-1[DELIMITED BY [ALL] {identifier-2
literal-1} {
OR [ALL] {identifier-3literal-2
}}. . .]
INTO {identifier-4 [DELIMITER IN identifier-5] [COUNT IN identifier-6]} . . .[WITH POINTER IS identifier-7][TALLYING IN identifier-8][∣∣∣∣∣ON OVERFLOW imperative-statement-1
NOT ON OVERFLOW imperative-statement-2∣∣∣∣∣]
[END-OVERFLOW]
64
7. Procedure division
7.51. USE statement
Format 1 (file exception)
USE [GLOBAL] AFTER STANDARD{EXCEPTIONERROR
}PROCEDURE ON
{file-name-1} . . .
∣∣∣∣∣∣∣∣∣∣INPUTOUTPUTI-OEXTEND
∣∣∣∣∣∣∣∣∣∣
. . .
Format 2 (debugging)
USE FOR DEBUGGING ON
procedure-name-1ALL PROCEDURESALL REFERENCES OF identifier-1
. . .
Format 3 (start/end)
USE AT PROGRAM{STARTEND
}
Format 4 (reporting)
USE [GLOBAL] BEFORE REPORTING identifier-2
Format 5 (exception)
USE{EXCEPTION-CONDITIONEC
}
65
7. Procedure division
7.52. WRITE statement
Format 1 (sequential)
WRITE record-name-1FROM
identifier-1literal-1function-name-1
{BEFOREAFTER
}ADVANCING
{identifier-2literal-2
} [LINELINES
]mnemonic-name-1PAGE
[WITH [NO] LOCK]∣∣∣∣∣∣∣∣∣∣AT{END-OF-PAGEEOP
}imperative-statement-1
NOT AT{END-OF-PAGEEOP
}imperative-statement-2
∣∣∣∣∣∣∣∣∣∣
[END-WRITE]
Format 2 (random)
WRITE record-name-2FROM
identifier-3literal-3function-name-2
{BEFOREAFTER
}ADVANCING
{identifier-4literal-4
} [LINELINES
]mnemonic-name-2PAGE
[WITH [NO] LOCK]
66
7. Procedure division
[∣∣∣∣∣INVALID KEY imperative-statement-3NOT INVALID KEY imperative-statement-4
∣∣∣∣∣]
[END-WRITE]
67
8. Intrinsic functions
8.1. ABS function
FUNCTION ABS ( argument-1 )
8.2. ACOS function
FUNCTION ACOS ( argument-1 )
8.3. ANNUITY function
FUNCTION ANNUITY ( argument-1 argument-2 )
8.4. ASIN function
FUNCTION ASIN ( argument-1 )
8.5. ATAN function
FUNCTION ATAN ( argument-1 )
69
8. Intrinsic functions
8.6. BOOLEAN-OF-INTEGER function
FUNCTION BOOLEAN-OF-INTEGER ( argument-1 argument-2 )
8.7. BYTE-LENGTH function
FUNCTION BYTE-LENGTH ( argument-1 )
8.8. CHAR function
FUNCTION CHAR ( argument-1 )
8.9. CHAR-NATIONAL function
FUNCTION CHAR-NATIONAL ( argument-1 )
8.10. COMBINED-DATETIME function
FUNCTION COMBINED-DATETIME ( argument-1 argument-2 )
8.11. CONCATENATE function
FUNCTION CONCATENATE ( {argument-1} . . . )
70
8. Intrinsic functions
8.12. COS function
FUNCTION COS ( argument-1 )
8.13. CURRENCY-SYMBOL function
FUNCTION CURRENCY-SYMBOL
8.14. CURRENT-DATE function
FUNCTION CURRENT-DATE
8.15. DATE-OF-INTEGER function
FUNCTION DATE-OF-INTEGER ( argument-1 )
8.16. DATE-TO-YYYYMMDD function
FUNCTION DATE-TO-YYYYMMDD ( argument-1 [argument-2 [argument-3]] )
8.17. DAY-OF-INTEGER function
FUNCTION DAY-OF-INTEGER ( argument-1 )
71
8. Intrinsic functions
8.18. DAY-TO-YYYYDDD function
FUNCTION DAY-TO-YYYYDDD ( argument-1 [argument-2 [argument-3]] )
8.19. DISPLAY-OF function
FUNCTION DISPLAY-OF ( argument-1 )
8.20. E function
FUNCTION E
8.21. EXCEPTION-FILE function
FUNCTION EXCEPTION-FILE
8.22. EXCEPTION-FILE-N function
FUNCTION EXCEPTION-FILE-N
8.23. EXCEPTION-LOCATION function
FUNCTION EXCEPTION-LOCATION
72
8. Intrinsic functions
8.24. EXCEPTION-LOCATION-N function
FUNCTION EXCEPTION-LOCATION-N
8.25. EXCEPTION-STATEMENT function
FUNCTION EXCEPTION-STATEMENT
8.26. EXCEPTION-STATUS function
FUNCTION EXCEPTION-STATUS
8.27. EXP function
FUNCTION EXP ( argument-1 )
8.28. EXP10 function
FUNCTION EXP10 ( argument-1 )
8.29. FACTORIAL function
FUNCTION FACTORIAL ( argument-1 )
73
8. Intrinsic functions
8.30. FORMATTED-CURRENT-DATE function
FUNCTION FORMATTED-CURRENT-DATE ( argument-1 )
8.31. FORMATTED-DATE function
FUNCTION FORMATTED-DATE ( argument-1 argument-2 )
8.32. FORMATTED-DATETIME function
FUNCTION FORMATTED-DATETIME( argument-1 argument-2 argument-3
[argument-4SYSTEM-OFFSET
])
8.33. FORMATTED-TIME function
FUNCTION FORMATTED-TIME ( argument-1 argument-2[argument-3SYSTEM-OFFSET
])
8.34. FRACTION-PART function
FUNCTION FRACTION-PART ( argument-1 )
8.35. HIGHEST-ALGEBRAIC function
FUNCTION HIGHEST-ALGEBRAIC ( argument-1 )
74
8. Intrinsic functions
8.36. INTEGER function
FUNCTION INTEGER ( argument-1 )
8.37. INTEGER-OF-BOOLEAN function
FUNCTION INTEGER-OF-BOOLEAN ( argument-1 )
8.38. INTEGER-OF-DATE function
FUNCTION INTEGER-OF-DATE ( argument-1 )
8.39. INTEGER-OF-DAY function
FUNCTION INTEGER-OF-DAY ( argument-1 )
8.40. INTEGER-OF-FORMATTED-DATE function
FUNCTION INTEGER-OF-FORMATTED-DATE ( argument-1 argument-2 )
8.41. INTEGER-PART function
FUNCTION INTEGER-PART ( argument-1 )
75
8. Intrinsic functions
8.42. LENGTH function
FUNCTION LENGTH ( argument-1 )
8.43. LENGTH-AN function
FUNCTION LENGTH-AN ( argument-1 )
8.44. LOCALE-COMPARE function
FUNCTION LOCALE-COMPARE ( argument-1 argument-2 [argument-3] )
8.45. LOCALE-DATE function
FUNCTION LOCALE-DATE ( argument-1 [argument-2] )
8.46. LOCALE-TIME function
FUNCTION LOCALE-TIME ( argument-1 [argument-2] )
8.47. LOCALE-TIME-FROM-SECONDS function
FUNCTION LOCALE-TIME-FROM-SECONDS ( argument-1 [argument-2] )
76
8. Intrinsic functions
8.48. LOG function
FUNCTION LOG ( argument-1 )
8.49. LOG10 function
FUNCTION LOG10 ( argument-1 )
8.50. LOWER-CASE function
FUNCTION LOWER-CASE ( argument-1 )
8.51. LOWEST-ALGEBRAIC function
FUNCTION LOWEST-ALGEBRAIC ( argument-1 )
8.52. MAX function
FUNCTION MAX ( {argument-1}. . . )
8.53. MEAN function
FUNCTION MEAN ( {argument-1}. . . )
77
8. Intrinsic functions
8.54. MEDIAN function
FUNCTION MEDIAN ( {argument-1}. . . )
8.55. MIDRANGE function
FUNCTION MIDRANGE ( {argument-1}. . . )
8.56. MIN function
FUNCTION MIN ( {argument-1}. . . )
8.57. MOD function
FUNCTION MOD ( argument-1 argument-2 )
8.58. MODULE-CALLER-ID function
FUNCTION MODULE-CALLER-ID
8.59. MODULE-DATE function
FUNCTION MODULE-DATE
78
8. Intrinsic functions
8.60. MODULE-FORMATTED-DATE function
FUNCTION MODULE-FORMATTED-DATE
8.61. MODULE-ID function
FUNCTION MODULE-ID
8.62. MODULE-PATH function
FUNCTION MODULE-PATH
8.63. MODULE-SOURCE function
FUNCTION MODULE-SOURCE
8.64. MODULE-TIME function
FUNCTION MODULE-TIME
8.65. MONETARY-DECIMAL-POINT function
FUNCTION MONETARY-DECIMAL-POINT
79
8. Intrinsic functions
8.66. MONETARY-THOUSANDS-SEPARATOR function
FUNCTION MONETARY-THOUSANDS-SEPARATOR
8.67. NATIONAL-OF function
FUNCTION NATIONAL-OF ( argument-1 [argument-2] )
8.68. NUMERIC-DECIMAL-POINT function
FUNCTION NUMERIC-DECIMAL-POINT
8.69. NUMERIC-THOUSANDS-SEPARATOR function
FUNCTION NUMERIC-THOUSANDS-SEPARATOR
8.70. NUMVAL function
FUNCTION NUMVAL ( argument-1 )
8.71. NUMVAL-C function
FUNCTION NUMVAL-C ( argument-1 [argument-2] )
80
8. Intrinsic functions
8.72. NUMVAL-F function
FUNCTION NUMVAL-F ( argument-1 )
8.73. ORD function
FUNCTION ORD ( argument-1 )
8.74. ORD-MAX function
FUNCTION ORD-MAX ( {argument-1} . . . )
8.75. ORD-MIN function
FUNCTION ORD-MIN ( {argument-1} . . . )
8.76. PI function
FUNCTION PI
8.77. PRESENT-VALUE function
FUNCTION PRESENT-VALUE ( {argument-1} . . . )
81
8. Intrinsic functions
8.78. RANDOM function
FUNCTION RANDOM [( [argument-1] . . . )]
8.79. RANGE function
FUNCTION RANGE ( {argument-1}. . . )
8.80. REM function
FUNCTION REM ( argument-1 argument-2 )
8.81. REVERSE function
FUNCTION REVERSE ( argument-1 )
8.82. SECONDS-FROM-FORMATTED-TIME function
FUNCTION SECONDS-FROM-FORMATTED-TIME( argument-1 argument-2 )
8.83. SECONDS-PAST-MIDNIGHT function
FUNCTION SECONDS-PAST-MIDNIGHT ( argument-1 )
82
8. Intrinsic functions
8.84. SIGN function
FUNCTION SIGN ( argument-1 )
8.85. SIN function
FUNCTION SIN ( argument-1 )
8.86. SQRT function
FUNCTION SQRT ( argument-1 )
8.87. STANDARD-COMPARE function
FUNCTION STANDARD-COMPARE( argument-1 argument-2 [argument-3] [argument-4] )
8.88. STANDARD-DEVIATION function
FUNCTION STANDARD-DEVIATION ( {argument-1}. . . )
8.89. STORED-CHAR-LENGTH function
FUNCTION STORED-CHAR-LENGTH ( argument-1 )
83
8. Intrinsic functions
8.90. SUBSTITUTE function
FUNCTION SUBSTITUTE ( argument-1 {argument-2 argument-3}. . . )
8.91. SUBSTITUTE-CASE function
FUNCTION SUBSTITUTE-CASE ( argument-1 {argument-2 argument-3}. . . )
8.92. SUM function
FUNCTION SUM ( {argument-1}. . . )
8.93. TAN function
FUNCTION TAN ( argument-1 )
8.94. TEST-DATE-YYYYMMDD function
FUNCTION TEST-DATE-YYYYMMDD ( argument-1 )
8.95. TEST-DAY-YYYYDDD function
FUNCTION TEST-DAY-YYYYDDD ( argument-1 )
84
8. Intrinsic functions
8.96. TEST-FORMATTED-DATETIME function
FUNCTION TEST-FORMATTED-DATETIME ( argument-1 argument-2 )
8.97. TEST-NUMVAL function
FUNCTION TEST-NUMVAL ( argument-1 )
8.98. TEST-NUMVAL-C function
FUNCTION TEST-NUMVAL-C ( argument-1 argument-2 )
8.99. TEST-NUMVAL-F function
FUNCTION TEST-NUMVAL-F ( argument-1 )
8.100. TRIM function
FUNCTION TRIM ( argument-1[LEADINGTRAILING
])
8.101. UPPER-CASE function
FUNCTION UPPER-CASE ( argument-1 )
85
8. Intrinsic functions
8.102. VARIANCE function
FUNCTION VARIANCE ( {argument-1}. . . )
8.103. WHEN-COMPILED function
FUNCTION WHEN-COMPILED
8.104. YEAR-TO-YYYY function
FUNCTION YEAR-TO-YYYY ( argument-1 [argument-2 [argument-3]] )
86
A. GNU Free Documentation License
Version 1.3, 3 November 2008Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
<http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document,but changing it is not allowed.
A.1. Preamble
The purpose of this License is to make a manual, textbook, or other functional and usefuldocument “free” in the sense of freedom: to assure everyone the effective freedom tocopy and redistribute it, with or without modifying it, either commercially or noncommer-cially. Secondarily, this License preserves for the author and publisher a way to get creditfor their work, while not being considered responsible for modifications made by others.This License is a kind of “copyleft”, which means that derivative works of the documentmust themselves be free in the same sense. It complements the GNU General PublicLicense, which is a copyleft license designed for free software.We have designed this License in order to use it for manuals for free software, becausefree software needs free documentation: a free program should come with manualsproviding the same freedoms that the software does. But this License is not limited tosoftware manuals; it can be used for any textual work, regardless of subject matter orwhether it is published as a printed book. We recommend this License principally forworks whose purpose is instruction or reference.
92
A. GNU Free Documentation License
A.2. Applicability and definitions
This License applies to any manual or other work, in any medium, that contains a noticeplaced by the copyright holder saying it can be distributed under the terms of this License.Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use thatwork under the conditions stated herein. The “Document”, below, refers to any suchmanual or work. Any member of the public is a licensee, and is addressed as “you”. Youaccept the license if you copy, modify or distribute the work in a way requiring permissionunder copyright law.A “Modified Version” of the Document means any work containing the Document or aportion of it, either copied verbatim, or with modifications and/or translated into anotherlanguage.A “Secondary Section” is a named appendix or a front-matter section of the Documentthat deals exclusively with the relationship of the publishers or authors of the Documentto the Document’s overall subject (or to related matters) and contains nothing that couldfall directly within that overall subject. (Thus, if the Document is in part a textbook ofmathematics, a Secondary Section may not explain any mathematics.) The relationshipcould be a matter of historical connection with the subject or with related matters, or oflegal, commercial, philosophical, ethical or political position regarding them.The “Invariant Sections” are certain Secondary Sections whose titles are designated,as being those of Invariant Sections, in the notice that says that the Document is releasedunder this License. If a section does not fit the above definition of Secondary then it isnot allowed to be designated as Invariant. The Document may contain zero InvariantSections. If the Document does not identify any Invariant Sections then there are none.The “Cover Texts” are certain short passages of text that are listed, as Front-CoverTexts or Back-Cover Texts, in the notice that says that the Document is released underthis License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may beat most 25 words.A “Transparent” copy of the Document means a machine-readable copy, representedin a format whose specification is available to the general public, that is suitable forrevising the document straightforwardly with generic text editors or (for images com-posed of pixels) generic paint programs or (for drawings) some widely available drawingeditor, and that is suitable for input to text formatters or for automatic translation to avariety of formats suitable for input to text formatters. A copy made in an otherwiseTransparent file format whose markup, or absence of markup, has been arranged tothwart or discourage subsequent modification by readers is not Transparent. An imageformat is not Transparent if used for any substantial amount of text. A copy that is not“Transparent” is called “Opaque”.
93
A. GNU Free Documentation License
Examples of suitable formats for Transparent copies include plain ASCII withoutmarkup, Texinfo input format, LaTeX input format, SGML or XML using a publicly availableDTD, and standard-conforming simple HTML, PostScript or PDF designed for humanmodification. Examples of transparent image formats include PNG, XCF and JPG. Opaqueformats include proprietary formats that can be read and edited only by proprietary wordprocessors, SGML or XML for which the DTD and/or processing tools are not generallyavailable, and the machine-generated HTML, PostScript or PDF produced by some wordprocessors for output purposes only.The “Title Page” means, for a printed book, the title page itself, plus such followingpages as are needed to hold, legibly, the material this License requires to appear in thetitle page. For works in formats which do not have any title page as such, “Title Page”means the text near the most prominent appearance of the work’s title, preceding thebeginning of the body of the text.The “publisher” means any person or entity that distributes copies of the Documentto the public.A section “Entitled XYZ” means a named subunit of the Document whose title eitheris precisely XYZ or contains XYZ in parentheses following text that translates XYZ inanother language. (Here XYZ stands for a specific section name mentioned below, suchas “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve
the Title” of such a section when you modify the Document means that it remains asection “Entitled XYZ” according to this definition.The Document may include Warranty Disclaimers next to the notice which states thatthis License applies to the Document. These Warranty Disclaimers are considered to beincluded by reference in this License, but only as regards disclaiming warranties: anyother implication that these Warranty Disclaimers may have is void and has no effect onthe meaning of this License.
A.3. Verbatim copying
You may copy and distribute the Document in any medium, either commercially ornoncommercially, provided that this License, the copyright notices, and the licensenotice saying this License applies to the Document are reproduced in all copies, andthat you add no other conditions whatsoever to those of this License. You may not usetechnical measures to obstruct or control the reading or further copying of the copiesyou make or distribute. However, you may accept compensation in exchange for copies.If you distribute a large enough number of copies you must also follow the conditions insection 3.
94
A. GNU Free Documentation License
You may also lend copies, under the same conditions stated above, and you maypublicly display copies.
A.4. Copying in quantity
If you publish printed copies (or copies in media that commonly have printed covers) ofthe Document, numbering more than 100, and the Document’s license notice requiresCover Texts, you must enclose the copies in covers that carry, clearly and legibly, allthese Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on theback cover. Both covers must also clearly and legibly identify you as the publisher ofthese copies. The front cover must present the full title with all words of the title equallyprominent and visible. You may add other material on the covers in addition. Copyingwith changes limited to the covers, as long as they preserve the title of the Documentand satisfy these conditions, can be treated as verbatim copying in other respects.If the required texts for either cover are too voluminous to fit legibly, you should putthe first ones listed (as many as fit reasonably) on the actual cover, and continue the restonto adjacent pages.If you publish or distribute Opaque copies of the Document numbering more than100, you must either include a machine-readable Transparent copy along with eachOpaque copy, or state in or with each Opaque copy a computer-network location fromwhich the general network-using public has access to download using public-standardnetwork protocols a complete Transparent copy of the Document, free of added material.If you use the latter option, you must take reasonably prudent steps, when you begindistribution of Opaque copies in quantity, to ensure that this Transparent copy will remainthus accessible at the stated location until at least one year after the last time youdistribute an Opaque copy (directly or through your agents or retailers) of that edition tothe public.It is requested, but not required, that you contact the authors of the Document wellbefore redistributing any large number of copies, to give them a chance to provide youwith an updated version of the Document.
A.5. Modifications
You may copy and distribute a Modified Version of the Document under the conditions ofsections 2 and 3 above, provided that you release the Modified Version under precisely
95
A. GNU Free Documentation License
this License, with the Modified Version filling the role of the Document, thus licensingdistribution and modification of the Modified Version to whoever possesses a copy of it.In addition, you must do these things in the Modified Version:A. Use in the Title Page (and on the covers, if any) a title distinct from that of theDocument, and from those of previous versions (which should, if there were any,be listed in the History section of the Document). You may use the same title as aprevious version if the original publisher of that version gives permission.B. List on the Title Page, as authors, one or more persons or entities responsible forauthorship of the modifications in the Modified Version, together with at least fiveof the principal authors of the Document (all of its principal authors, if it has fewerthan five), unless they release you from this requirement.C. State on the Title page the name of the publisher of the Modified Version, as thepublisher.D. Preserve all the copyright notices of the Document.E. Add an appropriate copyright notice for your modifications adjacent to the othercopyright notices.F. Include, immediately after the copyright notices, a license notice giving the publicpermission to use the Modified Version under the terms of this License, in the formshown in the Addendum below.G. Preserve in that license notice the full lists of Invariant Sections and required CoverTexts given in the Document’s license notice.H. Include an unaltered copy of this License.I. Preserve the section Entitled “History”, Preserve its Title, and add to it an itemstating at least the title, year, new authors, and publisher of the Modified Versionas given on the Title Page. If there is no section Entitled “History” in the Document,create one stating the title, year, authors, and publisher of the Document as givenon its Title Page, then add an item describing the Modified Version as stated in theprevious sentence.J. Preserve the network location, if any, given in the Document for public access toa Transparent copy of the Document, and likewise the network locations given inthe Document for previous versions it was based on. These may be placed in the“History” section. You may omit a network location for a work that was publishedat least four years before the Document itself, or if the original publisher of theversion it refers to gives permission.
96
A. GNU Free Documentation License
K. For any section Entitled “Acknowledgements” or “Dedications”, Preserve the Titleof the section, and preserve in the section all the substance and tone of each ofthe contributor acknowledgements and/or dedications given therein.L. Preserve all the Invariant Sections of the Document, unaltered in their text andin their titles. Section numbers or the equivalent are not considered part of thesection titles.M. Delete any section Entitled “Endorsements”. Such a section may not be included inthe Modified Version.N. Do not retitle any existing section to be Entitled “Endorsements” or to conflict intitle with any Invariant Section.O. Preserve any Warranty Disclaimers.If the Modified Version includes new front-matter sections or appendices that qualifyas Secondary Sections and contain no material copied from the Document, you may atyour option designate some or all of these sections as invariant. To do this, add theirtitles to the list of Invariant Sections in the Modified Version’s license notice. These titlesmust be distinct from any other section titles.You may add a section Entitled “Endorsements”, provided it contains nothing butendorsements of your Modified Version by various parties—for example, statements ofpeer review or that the text has been approved by an organization as the authoritativedefinition of a standard.You may add a passage of up to five words as a Front-Cover Text, and a passage of upto 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the ModifiedVersion. Only one passage of Front-Cover Text and one of Back-Cover Text may be addedby (or through arrangements made by) any one entity. If the Document already includesa cover text for the same cover, previously added by you or by arrangement made by thesame entity you are acting on behalf of, you may not add another; but you may replacethe old one, on explicit permission from the previous publisher that added the old one.The author(s) and publisher(s) of the Document do not by this License give permissionto use their names for publicity for or to assert or imply endorsement of any ModifiedVersion.
97
A. GNU Free Documentation License
A.6. Combining documents
You may combine the Document with other documents released under this License,under the terms defined in section 4 above for modified versions, provided that youinclude in the combination all of the Invariant Sections of all of the original documents,unmodified, and list them all as Invariant Sections of your combined work in its licensenotice, and that you preserve all their Warranty Disclaimers.The combined work need only contain one copy of this License, and multiple identicalInvariant Sections may be replaced with a single copy. If there are multiple InvariantSections with the same name but different contents, make the title of each such sectionunique by adding at the end of it, in parentheses, the name of the original author orpublisher of that section if known, or else a unique number. Make the same adjustmentto the section titles in the list of Invariant Sections in the license notice of the combinedwork.In the combination, you must combine any sections Entitled “History” in the variousoriginal documents, forming one section Entitled “History”; likewise combine any sectionsEntitled “Acknowledgements”, and any sections Entitled “Dedications”. You must deleteall sections Entitled “Endorsements”.
A.7. Collections of documents
You may make a collection consisting of the Document and other documents releasedunder this License, and replace the individual copies of this License in the variousdocuments with a single copy that is included in the collection, provided that you followthe rules of this License for verbatim copying of each of the documents in all otherrespects.You may extract a single document from such a collection, and distribute it individuallyunder this License, provided you insert a copy of this License into the extracted document,and follow this License in all other respects regarding verbatim copying of that document.
A.8. Aggregation with independent works
A compilation of the Document or its derivatives with other separate and independentdocuments or works, in or on a volume of a storage or distribution medium, is called
98
A. GNU Free Documentation License
an “aggregate” if the copyright resulting from the compilation is not used to limit thelegal rights of the compilation’s users beyond what the individual works permit. Whenthe Document is included in an aggregate, this License does not apply to the other worksin the aggregate which are not themselves derivative works of the Document.If the Cover Text requirement of section 3 is applicable to these copies of the Document,then if the Document is less than one half of the entire aggregate, the Document’s CoverTexts may be placed on covers that bracket the Document within the aggregate, or theelectronic equivalent of covers if the Document is in electronic form. Otherwise theymust appear on printed covers that bracket the whole aggregate.
A.9. Translation
Translation is considered a kind of modification, so you may distribute translations of theDocument under the terms of section 4. Replacing Invariant Sections with translationsrequires special permission from their copyright holders, but youmay include translationsof some or all Invariant Sections in addition to the original versions of these InvariantSections. You may include a translation of this License, and all the license notices inthe Document, and any Warranty Disclaimers, provided that you also include the originalEnglish version of this License and the original versions of those notices and disclaimers.In case of a disagreement between the translation and the original version of this Licenseor a notice or disclaimer, the original version will prevail.If a section in theDocument is Entitled “Acknowledgements”, “Dedications”, or “History”,the requirement (section 4) to Preserve its Title (section 1) will typically require changingthe actual title.
A.10. Termination
You may not copy, modify, sublicense, or distribute the Document except as expresslyprovided under this License. Any attempt otherwise to copy, modify, sublicense, ordistribute it is void, and will automatically terminate your rights under this License.However, if you cease all violation of this License, then your license from a particularcopyright holder is reinstated (a) provisionally, unless and until the copyright holderexplicitly and finally terminates your license, and (b) permanently, if the copyright holderfails to notify you of the violation by some reasonable means prior to 60 days after thecessation.
99
A. GNU Free Documentation License
Moreover, your license from a particular copyright holder is reinstated permanentlyif the copyright holder notifies you of the violation by some reasonable means, this isthe first time you have received notice of violation of this License (for any work) fromthat copyright holder, and you cure the violation prior to 30 days after your receipt of thenotice.Termination of your rights under this section does not terminate the licenses of partieswho have received copies or rights from you under this License. If your rights have beenterminated and not permanently reinstated, receipt of a copy of some or all of the samematerial does not give you any rights to use it.
A.11. Future revisions of this license
The Free Software Foundation may publish new, revised versions of the GNU Free Doc-umentation License from time to time. Such new versions will be similar in spirit tothe present version, but may differ in detail to address new problems or concerns. Seehttp://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number. If the Documentspecifies that a particular numbered version of this License “or any later version” appliesto it, you have the option of following the terms and conditions either of that specifiedversion or of any later version that has been published (not as a draft) by the Free SoftwareFoundation. If the Document does not specify a version number of this License, you maychoose any version ever published (not as a draft) by the Free Software Foundation. If theDocument specifies that a proxy can decide which future versions of this License can beused, that proxy’s public statement of acceptance of a version permanently authorizesyou to choose that version for the Document.
A.12. Relicensing
“Massive Multiauthor Collaboration Site” (or “MMC Site”) means any World Wide Webserver that publishes copyrightable works and also provides prominent facilities foranybody to edit those works. A public wiki that anybody can edit is an example of such aserver. A “Massive Multiauthor Collaboration” (or “MMC”) contained in the site meansany set of copyrightable works thus published on the MMC site.“CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0 license publishedby Creative Commons Corporation, a not-for-profit corporation with a principal place of
100
A. GNU Free Documentation License
business in San Francisco, California, as well as future copyleft versions of that licensepublished by that same organization.“Incorporate” means to publish or republish a Document, in whole or in part, as part ofanother Document.An MMC is “eligible for relicensing” if it is licensed under this License, and if all worksthat were first published under this License somewhere other than this MMC, and subse-quently incorporated in whole or in part into the MMC, (1) had no cover texts or invariantsections, and (2) were thus incorporated prior to November 1, 2008.The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligiblefor relicensing.
A.13. Addendum: How to use this License for your documents
To use this License in a document you have written, include a copy of the License in thedocument and put the following copyright and license notices just after the title page:
Copyright © YEAR YOUR NAME. Permission is granted to copy, distributeand/ormodify this document under the terms of the GNU Free DocumentationLicense, Version 1.3 or any later version published by the Free SoftwareFoundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNUFree Documentation License”.
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the“with . . . Texts.” line with this:
with the Invariant Sections being LIST THEIR TITLES, with the Front-CoverTexts being LIST, and with the Back-Cover Texts being LIST.
If you have Invariant Sections without Cover Texts, or some other combination of thethree, merge those two alternatives to suit the situation.
101