GNU COBOL Programmer's Guide
Total Page:16
File Type:pdf, Size:1020Kb
GNU COBOL Programmer's Guide For Version 2.1 [23NOV2013] Gary L. Cutler ([email protected]). This manual documents GNU COBOL 2.1, 23NOV2013 build. GNU-COBOL Copyright 2002-2007 Keisuke Nishida Copyright 2007-2012 Roger While Copyright 2013-2013 Ron Norman (RWCS for GNU COBOL) Document Copyright 2009-2014 Gary L. Cutler Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License [FDL], Version 1.3 or any later version published by the Free Software Foundation; with Invariant Section "Introduction", no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". GNU COBOL 2.1 [23NOV2013] Programmer's Guide i Table of Contents 1. Introduction ::::::::::::::::::::::::::::::::::::: 1 1.1. Additional Reference Sources ::::::::::::::::::::::::::::::::::: 1 1.2. Introducing COBOL :::::::::::::::::::::::::::::::::::::::::::: 1 1.2.1. Why YOU Should Learn COBOL :::::::::::::::::::::::::: 2 1.2.2. Programmer Productivity :::::::::::::::::::::::::::::::::: 4 1.3. So What is GNU COBOL?:::::::::::::::::::::::::::::::::::::: 5 1.3.1. Language Reserved Words ::::::::::::::::::::::::::::::::: 6 1.3.2. User-Defined Words :::::::::::::::::::::::::::::::::::::::: 6 1.3.3. Case Insensitivity :::::::::::::::::::::::::::::::::::::::::: 7 1.3.4. Readability of Programs ::::::::::::::::::::::::::::::::::: 7 1.3.5. Divisions Organize Programs :::::::::::::::::::::::::::::: 10 1.3.6. Copybooks:::::::::::::::::::::::::::::::::::::::::::::::: 10 1.3.7. Structured Data :::::::::::::::::::::::::::::::::::::::::: 10 1.3.8. Files :::::::::::::::::::::::::::::::::::::::::::::::::::::: 11 1.3.9. Table Handling ::::::::::::::::::::::::::::::::::::::::::: 15 1.3.10. Sorting and Merging Data ::::::::::::::::::::::::::::::: 15 1.3.11. String Manipulation Features :::::::::::::::::::::::::::: 16 1.3.12. Screen Formatting Features :::::::::::::::::::::::::::::: 18 1.3.12.1. A Sample Screen:::::::::::::::::::::::::::::::::::: 19 1.3.12.2. Color Palette and Video Attributes:::::::::::::::::: 20 1.3.13. Report Writer Features :::::::::::::::::::::::::::::::::: 22 1.3.14. Data Initialization ::::::::::::::::::::::::::::::::::::::: 23 1.3.15. Syntax Diagram Conventions :::::::::::::::::::::::::::: 24 1.3.16. Format of Program Source Lines ::::::::::::::::::::::::: 26 1.3.17. Program Structure::::::::::::::::::::::::::::::::::::::: 29 1.3.18. Comments ::::::::::::::::::::::::::::::::::::::::::::::: 31 1.3.19. Literals :::::::::::::::::::::::::::::::::::::::::::::::::: 32 1.3.19.1. Numeric Literals :::::::::::::::::::::::::::::::::::: 33 1.3.19.2. Alphanumeric Literals :::::::::::::::::::::::::::::: 33 1.3.19.3. Figurative Constants:::::::::::::::::::::::::::::::: 35 1.3.20. Punctuation ::::::::::::::::::::::::::::::::::::::::::::: 36 1.3.21. LENGTH OF:::::::::::::::::::::::::::::::::::::::::::: 36 1.3.22. Interfacing to Other Environments ::::::::::::::::::::::: 37 2. CDF - Compiler Directing Facility ::::::::::: 39 2.1. COPY::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 40 2.2. REPLACE :::::::::::::::::::::::::::::::::::::::::::::::::::: 42 2.3. >>DEFINE :::::::::::::::::::::::::::::::::::::::::::::::::::: 45 2.4. >>IF::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 46 2.5. >>SET :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 49 2.6. >>SOURCE ::::::::::::::::::::::::::::::::::::::::::::::::::: 50 2.7. >>TURN :::::::::::::::::::::::::::::::::::::::::::::::::::::: 51 3 June 2014 Contents ii GNU COBOL 2.1 [23NOV2013] Programmer's Guide 3. IDENTIFICATION DIVISION ::::::::::::::: 53 4. ENVIRONMENT DIVISION ::::::::::::::::: 55 4.1. CONFIGURATION SECTION :::::::::::::::::::::::::::::::: 56 4.1.1. SOURCE-COMPUTER::::::::::::::::::::::::::::::::::: 57 4.1.2. OBJECT-COMPUTER ::::::::::::::::::::::::::::::::::: 58 4.1.3. REPOSITORY ::::::::::::::::::::::::::::::::::::::::::: 60 4.1.4. SPECIAL-NAMES:::::::::::::::::::::::::::::::::::::::: 62 4.1.4.1. Alphabet-Name-Clause::::::::::::::::::::::::::::::: 67 4.1.4.2. Class-Definition-Clause::::::::::::::::::::::::::::::: 69 4.1.4.3. Switch-Definition-Clause ::::::::::::::::::::::::::::: 70 4.1.4.4. Symbolic-Characters-Clause :::::::::::::::::::::::::: 71 4.2. INPUT-OUTPUT SECTION :::::::::::::::::::::::::::::::::: 72 4.2.1. SELECT ::::::::::::::::::::::::::::::::::::::::::::::::: 73 4.2.1.1. ORGANIZATION SEQUENTIAL :::::::::::::::::::: 78 4.2.1.2. ORGANIZATION LINE SEQUENTIAL:::::::::::::: 80 4.2.1.3. ORGANIZATION RELATIVE ::::::::::::::::::::::: 82 4.2.1.4. ORGANIZATION INDEXED :::::::::::::::::::::::: 84 4.2.2. MULTIPLE FILE :::::::::::::::::::::::::::::::::::::::: 86 4.2.3. SAME RECORD AREA :::::::::::::::::::::::::::::::::: 87 5. DATA DIVISION :::::::::::::::::::::::::::::: 89 5.1. Data Definition Principles ::::::::::::::::::::::::::::::::::::: 90 5.2. FILE SECTION ::::::::::::::::::::::::::::::::::::::::::::::: 93 5.2.1. File/Sort-Description ::::::::::::::::::::::::::::::::::::: 94 5.2.2. FILE-SECTION-Data-Item ::::::::::::::::::::::::::::::: 98 5.3. WORKING-STORAGE SECTION ::::::::::::::::::::::::::: 100 5.4. LOCAL-STORAGE SECTION ::::::::::::::::::::::::::::::: 102 5.5. LINKAGE SECTION :::::::::::::::::::::::::::::::::::::::: 104 5.6. REPORT SECTION ::::::::::::::::::::::::::::::::::::::::: 107 5.6.1. Report Group Definitions :::::::::::::::::::::::::::::::: 111 5.6.2. REPORT SECTION Data Items ::::::::::::::::::::::::: 113 5.7. SCREEN SECTION :::::::::::::::::::::::::::::::::::::::::: 115 5.8. Special Data Items ::::::::::::::::::::::::::::::::::::::::::: 118 5.8.1. 01-Level Constants :::::::::::::::::::::::::::::::::::::: 118 5.8.2. 66-Level Data Items ::::::::::::::::::::::::::::::::::::: 121 5.8.3. 77-Level Data Items ::::::::::::::::::::::::::::::::::::: 122 5.8.4. 78-Level Data Items ::::::::::::::::::::::::::::::::::::: 123 5.8.5. 88-Level Data Items ::::::::::::::::::::::::::::::::::::: 124 5.9. Data Description Clauses ::::::::::::::::::::::::::::::::::::: 125 5.9.1. ANY LENGTH:::::::::::::::::::::::::::::::::::::::::: 125 5.9.2. AUTO::::::::::::::::::::::::::::::::::::::::::::::::::: 126 5.9.3. AUTO-SKIP :::::::::::::::::::::::::::::::::::::::::::: 127 5.9.4. AUTOTERMINATE :::::::::::::::::::::::::::::::::::: 128 5.9.5. BACKGROUND-COLOR:::::::::::::::::::::::::::::::: 129 5.9.6. BASED ::::::::::::::::::::::::::::::::::::::::::::::::: 130 Contents 3 June 2014 GNU COBOL 2.1 [23NOV2013] Programmer's Guide iii 5.9.7. BEEP ::::::::::::::::::::::::::::::::::::::::::::::::::: 131 5.9.8. BELL ::::::::::::::::::::::::::::::::::::::::::::::::::: 132 5.9.9. BLANK ::::::::::::::::::::::::::::::::::::::::::::::::: 133 5.9.10. BLANK WHEN ZERO ::::::::::::::::::::::::::::::::: 134 5.9.11. BLINK ::::::::::::::::::::::::::::::::::::::::::::::::: 135 5.9.12. COLUMN :::::::::::::::::::::::::::::::::::::::::::::: 136 5.9.13. CONSTANT ::::::::::::::::::::::::::::::::::::::::::: 138 5.9.14. EMPTY-CHECK::::::::::::::::::::::::::::::::::::::: 139 5.9.15. ERASE :::::::::::::::::::::::::::::::::::::::::::::::: 140 5.9.16. EXTERNAL ::::::::::::::::::::::::::::::::::::::::::: 141 5.9.17. FALSE ::::::::::::::::::::::::::::::::::::::::::::::::: 142 5.9.18. FOREGROUND-COLOR::::::::::::::::::::::::::::::: 143 5.9.19. FROM ::::::::::::::::::::::::::::::::::::::::::::::::: 144 5.9.20. FULL :::::::::::::::::::::::::::::::::::::::::::::::::: 145 5.9.21. GLOBAL :::::::::::::::::::::::::::::::::::::::::::::: 146 5.9.22. GROUP INDICATE:::::::::::::::::::::::::::::::::::: 147 5.9.23. HIGHLIGHT ::::::::::::::::::::::::::::::::::::::::::: 148 5.9.24. JUSTIFIED :::::::::::::::::::::::::::::::::::::::::::: 149 5.9.25. LEFTLINE::::::::::::::::::::::::::::::::::::::::::::: 151 5.9.26. LENGTH-CHECK ::::::::::::::::::::::::::::::::::::: 152 5.9.27. LINE::::::::::::::::::::::::::::::::::::::::::::::::::: 153 5.9.28. LOWLIGHT ::::::::::::::::::::::::::::::::::::::::::: 155 5.9.29. NEXT GROUP :::::::::::::::::::::::::::::::::::::::: 156 5.9.30. NO-ECHO ::::::::::::::::::::::::::::::::::::::::::::: 157 5.9.31. OCCURS :::::::::::::::::::::::::::::::::::::::::::::: 158 5.9.32. OVERLINE :::::::::::::::::::::::::::::::::::::::::::: 161 5.9.33. PICTURE:::::::::::::::::::::::::::::::::::::::::::::: 162 5.9.34. PRESENT WHEN ::::::::::::::::::::::::::::::::::::: 170 5.9.35. PROMPT :::::::::::::::::::::::::::::::::::::::::::::: 171 5.9.36. REDEFINES ::::::::::::::::::::::::::::::::::::::::::: 172 5.9.37. RENAMES::::::::::::::::::::::::::::::::::::::::::::: 173 5.9.38. REQUIRED :::::::::::::::::::::::::::::::::::::::::::: 174 5.9.39. REVERSE-VIDEO ::::::::::::::::::::::::::::::::::::: 175 5.9.40. SECURE ::::::::::::::::::::::::::::::::::::::::::::::: 176 5.9.41. SIGN IS :::::::::::::::::::::::::::::::::::::::::::::::: 177 5.9.42. SOURCE::::::::::::::::::::::::::::::::::::::::::::::: 178 5.9.43. SUM OF ::::::::::::::::::::::::::::::::::::::::::::::: 179 5.9.44. SYNCRONIZED ::::::::::::::::::::::::::::::::::::::: 181 5.9.45. TO ::::::::::::::::::::::::::::::::::::::::::::::::::::: 183 5.9.46. TYPE :::::::::::::::::::::::::::::::::::::::::::::::::: 184 5.9.47. UNDERLINE :::::::::::::::::::::::::::::::::::::::::: 185 5.9.48. USAGE :::::::::::::::::::::::::::::::::::::::::::::::: 186 5.9.49. USING ::::::::::::::::::::::::::::::::::::::::::::::::: 196 5.9.50. VALUE :::::::::::::::::::::::::::::::::::::::::::::::: 197 3 June 2014 Contents iv GNU COBOL 2.1 [23NOV2013] Programmer's Guide 6. PROCEDURE DIVISION ::::::::::::::::::: 201 6.1. PROCEDURE DIVISION USING :::::::::::::::::::::::::::: 202 6.2. PROCEDURE