@node Top @top Top @menu * OpenCOBOL FAQ:: @end menu @node OpenCOBOL FAQ @chapter OpenCOBOL FAQ @image{images/opencobol,,,OpenCOBOL,png} @quotation @table @asis @item .. Attention:: This is a 1.0 release candidate of the OpenCOBOL FAQ. Sourced at @uref{http://opencobol.add1tocobol.com/ocfaq.rst,ocfaq.rst} @end table @end quotation @table @asis @item .. Suggestions in general: @enumerate @item Remove the leading "Q." because most points are questions and the answers weren't titled as "A." @item Change the (minor) version number every time you do something (1.0rc@comma{} 1.0rc2@comma{} ...). @item If possible: use images for "back to index links" @item If possible: remove all backlinks via css if file is printed. @end enumerate 5. Why is this called a FAQ? 1 done 2 done 3 and 4 corrected with use of :backlinks: option of contents directive 5 Good question @item :Authors: Brian Tiffin [btiffin]_@comma{} John Ellis [jrls_swla]_@comma{} human [human]_@comma{} Joseph James Frantz [aoirthoir]_@comma{} Roger While [Roger]_@comma{} Keisuke Nishida [Keisuke]_ (with the invaluable assistance of many others) @item :Organization: The OpenCOBOL Project @item :Version: 1.0rc21@comma{} February 6@comma{} 2009 @item :Status: Release Candidate @item :Copyright: |copyleft| @item :ChangeLog: changelog_ @item .. note:: This FAQ is more than a FAQ and less than a FAQ@comma{} someday that will change and this document will be split into an OpenCOBOL manual and a simplified Frequently Asked Questions file. @item .. Attention:: Regarding COBOL Standards@comma{} Official COBOL Standards: There are many references to @strong{standards} in this document. Very few of them are @emph{technically} correct references. Apologies to all the hard working men and women of the technical committees for this unintentional slight. For specific details on what wordings should be used please see `What are the Official COBOL Standards?`_ @item .. contents:: FAQ Contents @table @asis @item depth 2 @item backlinks entry @end table @end table @menu * OpenCOBOL:: * History:: * Using OpenCOBOL:: * Notes:: * Authors:: * Maintainers and Contributors:: * ChangeLog:: @end menu @node OpenCOBOL @section OpenCOBOL @menu * What is OpenCOBOL?:: * What is COBOL?:: * How is OpenCOBOL licensed?:: * What platforms are supported by OpenCOBOL?:: * Are there pre-built OpenCOBOL packages:: * What is the most recent version of OpenCOBOL?:: * How complete is OpenCOBOL?:: * Will I be amazed by OpenCOBOL?:: * Who do I thank for OpenCOBOL?:: * Does OpenCOBOL include a Test Suite?:: * Does OpenCOBOL pass the NIST Test Suite?:: * What about OpenCOBOL and benchmarks?:: * Can OpenCOBOL be used for CGI?:: * Can OpenCOBOL be used for production applications?:: * Where can I get more information about COBOL?:: * Where can I get more information about OpenCOBOL?:: * Can I help out with the OpenCOBOL project?:: * Is there an OpenCOBOL mailing list?:: * Where can I find more information about COBOL standards?:: * Do you know any good jokes?:: @end menu @node What is OpenCOBOL? @subsection What is OpenCOBOL? OpenCOBOL_ is an open-source COBOL_ compiler. OpenCOBOL implements a substantial part of the `COBOL 85`_ and `COBOL 2002`_ standards@comma{} as well as many extensions of the existent COBOL compilers. OpenCOBOL translates COBOL into C and compiles the translated code using the native C compiler. You can build your COBOL programs on various platforms@comma{} including Unix/Linux@comma{} Mac OS X@comma{} and Microsoft Windows. @node What is COBOL? @subsection What is COBOL? COBOL_ is an acronym for COmmon Business Oriented Language. This author has always thought of it as "Common Business" Oriented more than Common "Business Oriented"@comma{} but that emphasis is perhaps up to the readers point of view. @node How is OpenCOBOL licensed? @subsection How is OpenCOBOL licensed? The compiler is licensed under @uref{http://www.gnu.org/licenses/gpl.html,GNU General Public License}. The run-time library is licensed under @uref{http://www.gnu.org/licenses/lgpl.html,GNU Lesser General Public License}. All source codes are copyright by the respective authors. OpenCOBOL is distributed in the hope that it will be useful@comma{} but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @node What platforms are supported by OpenCOBOL? @subsection What platforms are supported by OpenCOBOL? `OpenCOBOL 1.0`_ the current official release version@comma{} hosted on SourceForge.net@comma{} compiles on: @itemize @item All 32-bit MS Windows (95/98/NT/2000/XP) @item All POSIX (Linux/BSD/UNIX-like OSes) @item OS/X @end itemize `OpenCOBOL 1.1`_@comma{} has been built on @itemize @item MS Windows native @item MS Windows with Cygwin @item POSIX Systems including OpenSolaris @item OS/X @end itemize @node Are there pre-built OpenCOBOL packages @subsection Are there pre-built OpenCOBOL packages Yes. Debian APT@comma{} and RPM packages exist. Packages for NetBSD. Many. Google @emph{opencobol packages} for any late breaking news. A Debian apt binary package exists for OpenCOBOL 1.0 as @strong{open-cobol} and lists dependencies of @itemize @item libc6 (>= 2.7-1)@comma{} @item libcob1@comma{} @item libcob1-dev (= 1.0-1)@comma{} @item libdb4.5 (>= 4.5.20-3)@comma{} @item libdb4.5-dev@comma{} @item libgmp3-dev@comma{} @item libgmp3c2@comma{} @item libltdl3-dev@comma{} @item libncurses5 (>= 5.6+20071006-3) @end itemize Thanks to the gracious efforts of Bart Martens@comma{} bartm on Debian's .org domain. Also check out @uref{http://www.kiska.net/opencobol/,http://www.kiska.net/opencobol/} and @uref{http://www.kiska.net/opencobol/1.1/,http://www.kiska.net/opencobol/1.1/} for binary builds on various platforms. Thanks to Sergey Kashyrin. @node What is the most recent version of OpenCOBOL? @subsection What is the most recent version of OpenCOBOL? See `What is the current version of OpenCOBOL?`_ @node How complete is OpenCOBOL? @subsection How complete is OpenCOBOL? `OpenCOBOL 1.0`_ implements a substantial portion of `COBOL 85`_@comma{} supports many of the advances and clarifications of `COBOL 2002`_@comma{} and includes many extensions in common use from Micro Focus COBOL@comma{} ACUCOBOL and other existent compilers. `OpenCOBOL 1.1`_ implements a more substantial portion of the `COBOL 85`_ Dialect@comma{} `COBOL 2002`_ and a growing number of vendor extensions. Some proposed COBOL 2008 features have also been implemented. Compatibility support includes: @itemize @item MF for Micro Focus @item IBM for IBM compatibility @item MVS @item BS2000 @end itemize OpenCOBOL also includes some advanced features allowing source code such as @verbatim CALL "cfunction" USING BY REFERENCE ADDRESS OF VAR-IN-LINKAGE-SECTION. @end verbatim Passing the equivalent of char**@comma{} pointer to pointer to char. Just as a small example of the level of coverage provided by OpenCOBOL. @table @asis @item .. note:: While OpenCOBOL can be held to a high standard of quality and robustness@comma{} the authors @emph{DO NOT} claim it to be a "Standard Conforming" implementation of COBOL. @end table @node Will I be amazed by OpenCOBOL? @subsection Will I be amazed by OpenCOBOL? This author believes so. For an open source implementation of COBOL@comma{} OpenCOBOL may surprise you in the depth and breadth of its COBOL feature support@comma{} usability and robustness. @node Who do I thank for OpenCOBOL? @subsection Who do I thank for OpenCOBOL? Many people. In particular Keisuke Nishida and Roger While. See the THANKS file in the source code archive for more names of people that have worked on the OpenCOBOL project. Roger points out that the list is woefully incomplete. To quote: @verbatim The OC project would not have been where it is today without the significant/enormous help from many-many persons. The THANKS file does not even do justice to this. @end verbatim @node Does OpenCOBOL include a Test Suite? @subsection Does OpenCOBOL include a Test Suite? Why yes it does. 74 syntax tests@comma{} 170 coverage tests@comma{} and 16 data representation tests at last count. From the development tarball: @verbatim $ make check @end verbatim will evaluate and report on the test suite. From a run in December 2008: @verbatim make check-recursive make[1]: Entering directory `open-cobol-1.1' Making check in lib make[2]: Entering directory `open-cobol-1.1/lib' make[2]: Nothing to be done for `check'. make[2]: Leaving directory `open-cobol-1.1/lib' Making check in libcob make[2]: Entering directory `open-cobol-1.1/libcob' make[2]: Nothing to be done for `check'. make[2]: Leaving directory `open-cobol-1.1/libcob' Making check in cobc make[2]: Entering directory `open-cobol-1.1/cobc' make check-am make[3]: Entering directory `open-cobol-1.1/cobc' make[3]: Nothing to be done for `check-am'. make[3]: Leaving directory `open-cobol-1.1/cobc' make[2]: Leaving directory `open-cobol-1.1/cobc' Making check in bin make[2]: Entering directory `open-cobol-1.1/bin' make[2]: Nothing to be done for `check'. make[2]: Leaving directory `open-cobol-1.1/bin' Making check in config make[2]: Entering directory `open-cobol-1.1/config' make[2]: Nothing to be done for `check'. make[2]: Leaving directory `open-cobol-1.1/config' Making check in copy make[2]: Entering directory `open-cobol-1.1/copy' make[2]: Nothing to be done for `check'. make[2]: Leaving directory `open-cobol-1.1/copy' Making check in po make[2]: Entering directory `open-cobol-1.1/po' make[2]: Nothing to be done for `check'. make[2]: Leaving directory `open-cobol-1.1/po' Making check in texi make[2]: Entering directory `open-cobol-1.1/texi' make[2]: Nothing to be done for `check'. make[2]: Leaving directory `open-cobol-1.1/texi' Making check in tests make[2]: Entering directory `open-cobol-1.1/tests' Making check in cobol85 make[3]: Entering directory `open-cobol-1.1/tests/cobol85' make[3]: Nothing to be done for `check'. make[3]: Leaving directory `open-cobol-1.1/tests/cobol85' make[3]: Entering directory `open-cobol-1.1/tests' make check-TESTS make[4]: Entering directory `open-cobol-1.1/tests' ## --------------------------------------- ## ## OpenCOBOL 1.1 test suite: Syntax Tests. ## ## --------------------------------------- ## 1: COPY: file not found ok 2: COPY: replacement order ok 3: COPY: separators ok 4: COPY: partial replacement ok 5: COPY: recursive replacement ok 6: Invalid PROGRAM-ID ok 7: Undefined data name ok 8: Undefined group name ok 9: Undefined data name in group ok 10: Reference not a group name ok 11: Incomplete 01 definition ok 12: Same labels in different sections ok 13: Redefinition of 01 items ok 14: Redefinition of 01 and 02 items ok 15: Redefinition of 02 items ok 16: Redefinition of 77 items ok 17: Redefinition of 01 and 77 items ok 18: Redefinition of 88 items ok 19: Ambiguous reference to 02 items ok 20: Ambiguous reference to 02 and 03 items ok 21: Ambigous reference with qualification ok 22: Unique reference with ambiguous qualifiers ok 23: Undefined procedure name ok 24: Redefinition of section names ok 25: Redefinition of section and paragraph names ok 26: Redefinition of paragraph names ok 27: Ambiguous reference to paragraph name ok 28: Non-matching level numbers (extension) ok 29: Ambiguous AND/OR ok 30: START on SEQUENTIAL file ok 31: Subscripted item requires OCCURS clause ok 32: The number of subscripts ok 33: OCCURS with level 01, 66, 77, and 88 ok 34: OCCURS with variable-occurrence data item ok 35: Nested OCCURS clause ok 36: OCCURS DEPENDING followed by another field ok 37: OCCURS DEPENDING without TO clause ok 38: REDEFINES: not following entry-name ok 39: REDEFINES: level 02 by 01 ok 40: REDEFINES: level 03 by 02 ok 41: REDEFINES: level 66 ok 42: REDEFINES: level 88 ok 43: REDEFINES: lower level number ok 44: REDEFINES: with OCCURS ok 45: REDEFINES: with subscript ok 46: REDEFINES: with variable occurrence ok 47: REDEFINES: with qualification ok 48: REDEFINES: multiple redefinition ok 49: REDEFINES: size exceeds ok 50: REDEFINES: with VALUE ok 51: REDEFINES: with intervention ok 52: REDEFINES: within REDEFINES ok 53: Numeric item (integer) ok 54: Numeric item (non-integer) ok 55: Numeric item with picture P ok 56: Signed numeric literal ok 57: Alphabetic item ok 58: Alphanumeric item ok 59: Alphanumeric group item ok 60: Numeric-edited item ok 61: Alphanumeric-edited item ok 62: MOVE SPACE TO numeric or numeric-edited item ok 63: MOVE ZERO TO alphabetic item ok 64: MOVE alphabetic TO x ok 65: MOVE alphanumeric TO x ok 66: MOVE alphanumeric-edited TO x ok 67: MOVE numeric (integer) TO x ok 68: MOVE numeric (non-integer) TO x ok 69: MOVE numeric-edited TO x ok 70: Operands must be groups ok 71: MOVE: misc ok 72: Category check of Format 1 ok 73: Category check of Format 2 ok 74: Category check of literals ok 75: SET: misc ok ## ------------- ## ## Test results. ## ## ------------- ## All 75 tests were successful. PASS: ./syntax ## ------------------------------------ ## ## OpenCOBOL 1.1 test suite: Run Tests. ## ## ------------------------------------ ## 1: DISPLAY literals ok 2: DISPLAY literals, Decimal Point is COMMA ok 3: Hexadecimal literal ok 4: DISPLAY data items with VALUE clause ok 5: DISPLAY data items with MOVE statement ok 6: GLOBAL at same level ok 7: GLOBAL at lower level ok 8: non-numeric subscript ok 9: The range of subscripts ok 10: Subscript out of bounds (1) ok 11: Subscript out of bounds (2) ok 12: Value of DEPENDING ON N out of bounds (lower)ok 13: Value of DEPENDING ON N out of bounds (upper)ok 14: Subscript bounds with ODO (lower) ok 15: Subscript bounds with ODO (upper) ok 16: Subscript bounds with ODO ok 17: Subscript by arithmetic expression ok 18: Separate sign positions ok 19: Static reference modification ok 20: Dynamic reference modification ok 21: Static out of bounds ok 22: Offset underflow ok 23: Offset overflow ok 24: Length underflow ok 25: Length overflow ok 26: ACCEPT ok 27: INITIALIZE group entry with OCCURS ok 28: INITIALIZE OCCURS with numeric edited ok 29: INITIALIZE complex group (1) ok 30: INITIALIZE complex group (2) ok 31: INITIALIZE with REDEFINES ok 32: Source file not found ok 33: Comma separator without space ok 34: LOCAL-STORAGE ok 35: EXTERNAL data item ok 36: EXTERNAL AS data item ok 37: cobcrun validation ok 38: MOVE to itself ok 39: MOVE with refmod ok 40: MOVE with refmod (variable) ok 41: MOVE with group refmod ok 42: MOVE indexes ok 43: MOVE X'00' ok 44: Level 01 subscripts ok 45: Class check with reference modification ok 46: Index and parenthesized expression ok 47: Alphanumeric and binary numeric ok 48: Dynamic call with static linking ok 49: CALL m1. CALL m2. CALL m1. ok 50: CALL binary literal parameter/LENGTH OF ok 51: INSPECT REPLACING LEADING ZEROS BY SPACES ok 52: INSPECT: No repeat conversion check ok 53: INSPECT: REPLACING figurative constant ok 54: INSPECT: TALLYING BEFORE ok 55: INSPECT: TALLYING AFTER ok 56: INSPECT REPLACING TRAILING ZEROS BY SPACES ok 57: INSPECT REPLACING complex ok 58: SWITCHES ok 59: Nested PERFORM ok 60: EXIT PERFORM ok 61: EXIT PERFORM CYCLE ok 62: EXIT PARAGRAPH ok 63: EXIT SECTION ok 64: 88 with FILLER ok 65: Non-overflow after overflow ok 66: PERFORM ... CONTINUE ok 67: STRING with subscript reference ok 68: UNSTRING DELIMITED ALL LOW-VALUE ok 69: READ INTO AT-END sequence ok 70: First READ on empty SEQUENTIAL INDEXED file ok 71: REWRITE a RELATIVE file with RANDOM access ok 72: SORT: table sort ok 73: SORT: EBCDIC table sort ok 74: SORT nonexistent file ok 75: PIC ZZZ-, ZZZ+ ok 76: Larger REDEFINES lengths ok 77: PERFORM type OSVS ok 78: Sticky LINKAGE ok 79: COB_PRE_LOAD test ok 80: COB_LOAD_CASE=UPPER test ok 81: 88 level with FALSE IS clause ok 82: ALLOCATE/FREE with BASED item ok 83: INITIZIALIZE with reference modification ok 84: CALL with OMITTED parameter ok 85: ANY LENGTH ok 86: BASED item non-ALLOCATED (debug) ok 87: COMP-5 ok 88: Hexadecimal numeric literal ok 89: Semi-parenthesized condition ok 90: ADDRESS OF ok 91: LENGTH OF ok 92: WHEN-COMPILED ok 93: Complex OCCURS DEPENDING ON ok 94: MOVE NON-INTEGER TO ALPHA-NUMERIC ok 95: CALL USING file-name ok 96: CALL unusual program-id. ok 97: ASSIGN MF ok 98: ASSIGN IBM ok 99: ASSIGN mapping ok 100: ASSIGN expansion ok 101: ASSIGN with COB_FILE_PATH ok 102: NUMBER-OF-CALL-PARAMETERS ok 103: PROCEDURE DIVISION USING BY ... ok 104: PROCEDURE DIVISION CHAINING ... ok 105: STOP RUN RETURNING ok 106: ENTRY ok 107: LINE SEQUENTIAL write ok 108: LINE SEQUENTIAL read ok 109: ASSIGN to KEYBOARD/DISPLAY ok 110: Environment/Argument variable ok 111: RETURN-CODE moving ok 112: RETURN-CODE passing ok 113: FUNCTION ABS ok 114: FUNCTION ACOS ok 115: FUNCTION ANNUITY ok 116: FUNCTION ASIN ok 117: FUNCTION ATAN ok 118: FUNCTION CHAR ok 119: FUNCTION COMBINED-DATETIME ok 120: FUNCTION COS ok 121: FUNCTION DATE-OF-INTEGER ok 122: FUNCTION DATE-TO-YYYYMMDD ok 123: FUNCTION DAY-OF-INTEGER ok 124: FUNCTION DAY-TO-YYYYDDD ok 125: FUNCTION E ok 126: FUNCTION EXCEPTION-FILE ok 127: FUNCTION EXCEPTION-LOCATION ok 128: FUNCTION EXCEPTION-STATEMENT ok 129: FUNCTION EXCEPTION-STATUS ok 130: FUNCTION EXP ok 131: FUNCTION FACTORIAL ok 132: FUNCTION FRACTION-PART ok 133: FUNCTION INTEGER ok 134: FUNCTION INTEGER-OF-DATE ok 135: FUNCTION INTEGER-OF-DAY ok 136: FUNCTION INTEGER-PART ok 137: FUNCTION LENGTH ok 138: FUNCTION LOCALE-DATE ok 139: FUNCTION LOCALE-TIME ok 140: FUNCTION LOCALE-TIME-FROM-SECONDS ok 141: FUNCTION LOG ok 142: FUNCTION LOG10 ok 143: FUNCTION LOWER-CASE ok 144: FUNCTION LOWER-CASE with reference modding ok 145: FUNCTION MAX ok 146: FUNCTION MEAN ok 147: FUNCTION MEDIAN ok 148: FUNCTION MIDRANGE ok 149: FUNCTION MIN ok 150: FUNCTION MOD ok 151: FUNCTION NUMVAL ok 152: FUNCTION NUMVAL-C ok 153: FUNCTION ORD ok 154: FUNCTION ORD-MAX ok 155: FUNCTION ORD-MIN ok 156: FUNCTION PI ok 157: FUNCTION PRESENT-VALUE ok 158: FUNCTION RANGE ok 159: FUNCTION REM ok 160: FUNCTION REVERSE ok 161: FUNCTION REVERSE with reference modding ok 162: FUNCTION SECONDS-FROM-FORMATTED-TIME ok 163: FUNCTION SECONDS-PAST-MIDNIGHT ok 164: FUNCTION SIGN ok 165: FUNCTION SIN ok 166: FUNCTION SQRT ok 167: FUNCTION STANDARD-DEVIATION ok 168: FUNCTION STORED-CHAR-LENGTH ok 169: FUNCTION TAN ok 170: FUNCTION TRIM ok 171: FUNCTION TRIM with reference modding ok 172: FUNCTION UPPER-CASE ok 173: FUNCTION UPPER-CASE with reference modding ok 174: FUNCTION VARIANCE ok 175: FUNCTION WHEN-COMPILED ok ## ------------- ## ## Test results. ## ## ------------- ## All 175 tests were successful. PASS: ./run ## Run time tests with -O option ## ## ------------------------------------ ## ## OpenCOBOL 1.1 test suite: Run Tests. ## ## ------------------------------------ ## 1: DISPLAY literals ok 2: DISPLAY literals, Decimal Point is COMMA ok 3: Hexadecimal literal ok 4: DISPLAY data items with VALUE clause ok 5: DISPLAY data items with MOVE statement ok 6: GLOBAL at same level ok 7: GLOBAL at lower level ok 8: non-numeric subscript ok 9: The range of subscripts ok 10: Subscript out of bounds (1) ok 11: Subscript out of bounds (2) ok 12: Value of DEPENDING ON N out of bounds (lower)ok 13: Value of DEPENDING ON N out of bounds (upper)ok 14: Subscript bounds with ODO (lower) ok 15: Subscript bounds with ODO (upper) ok 16: Subscript bounds with ODO ok 17: Subscript by arithmetic expression ok 18: Separate sign positions ok 19: Static reference modification ok 20: Dynamic reference modification ok 21: Static out of bounds ok 22: Offset underflow ok 23: Offset overflow ok 24: Length underflow ok 25: Length overflow ok 26: ACCEPT ok 27: INITIALIZE group entry with OCCURS ok 28: INITIALIZE OCCURS with numeric edited ok 29: INITIALIZE complex group (1) ok 30: INITIALIZE complex group (2) ok 31: INITIALIZE with REDEFINES ok 32: Source file not found ok 33: Comma separator without space ok 34: LOCAL-STORAGE ok 35: EXTERNAL data item ok 36: EXTERNAL AS data item ok 37: cobcrun validation ok 38: MOVE to itself ok 39: MOVE with refmod ok 40: MOVE with refmod (variable) ok 41: MOVE with group refmod ok 42: MOVE indexes ok 43: MOVE X'00' ok 44: Level 01 subscripts ok 45: Class check with reference modification ok 46: Index and parenthesized expression ok 47: Alphanumeric and binary numeric ok 48: Dynamic call with static linking ok 49: CALL m1. CALL m2. CALL m1. ok 50: CALL binary literal parameter/LENGTH OF ok 51: INSPECT REPLACING LEADING ZEROS BY SPACES ok 52: INSPECT: No repeat conversion check ok 53: INSPECT: REPLACING figurative constant ok 54: INSPECT: TALLYING BEFORE ok 55: INSPECT: TALLYING AFTER ok 56: INSPECT REPLACING TRAILING ZEROS BY SPACES ok 57: INSPECT REPLACING complex ok 58: SWITCHES ok 59: Nested PERFORM ok 60: EXIT PERFORM ok 61: EXIT PERFORM CYCLE ok 62: EXIT PARAGRAPH ok 63: EXIT SECTION ok 64: 88 with FILLER ok 65: Non-overflow after overflow ok 66: PERFORM ... CONTINUE ok 67: STRING with subscript reference ok 68: UNSTRING DELIMITED ALL LOW-VALUE ok 69: READ INTO AT-END sequence ok 70: First READ on empty SEQUENTIAL INDEXED file ok 71: REWRITE a RELATIVE file with RANDOM access ok 72: SORT: table sort ok 73: SORT: EBCDIC table sort ok 74: SORT nonexistent file ok 75: PIC ZZZ-, ZZZ+ ok 76: Larger REDEFINES lengths ok 77: PERFORM type OSVS ok 78: Sticky LINKAGE ok 79: COB_PRE_LOAD test ok 80: COB_LOAD_CASE=UPPER test ok 81: 88 level with FALSE IS clause ok 82: ALLOCATE/FREE with BASED item ok 83: INITIZIALIZE with reference modification ok 84: CALL with OMITTED parameter ok 85: ANY LENGTH ok 86: BASED item non-ALLOCATED (debug) ok 87: COMP-5 ok 88: Hexadecimal numeric literal ok 89: Semi-parenthesized condition ok 90: ADDRESS OF ok 91: LENGTH OF ok 92: WHEN-COMPILED ok 93: Complex OCCURS DEPENDING ON ok 94: MOVE NON-INTEGER TO ALPHA-NUMERIC ok 95: CALL USING file-name ok 96: CALL unusual program-id. ok 97: ASSIGN MF ok 98: ASSIGN IBM ok 99: ASSIGN mapping ok 100: ASSIGN expansion ok 101: ASSIGN with COB_FILE_PATH ok 102: NUMBER-OF-CALL-PARAMETERS ok 103: PROCEDURE DIVISION USING BY ... ok 104: PROCEDURE DIVISION CHAINING ... ok 105: STOP RUN RETURNING ok 106: ENTRY ok 107: LINE SEQUENTIAL write ok 108: LINE SEQUENTIAL read ok 109: ASSIGN to KEYBOARD/DISPLAY ok 110: Environment/Argument variable ok 111: RETURN-CODE moving ok 112: RETURN-CODE passing ok 113: FUNCTION ABS ok 114: FUNCTION ACOS ok 115: FUNCTION ANNUITY ok 116: FUNCTION ASIN ok 117: FUNCTION ATAN ok 118: FUNCTION CHAR ok 119: FUNCTION COMBINED-DATETIME ok 120: FUNCTION COS ok 121: FUNCTION DATE-OF-INTEGER ok 122: FUNCTION DATE-TO-YYYYMMDD ok 123: FUNCTION DAY-OF-INTEGER ok 124: FUNCTION DAY-TO-YYYYDDD ok 125: FUNCTION E ok 126: FUNCTION EXCEPTION-FILE ok 127: FUNCTION EXCEPTION-LOCATION ok 128: FUNCTION EXCEPTION-STATEMENT ok 129: FUNCTION EXCEPTION-STATUS ok 130: FUNCTION EXP ok 131: FUNCTION FACTORIAL ok 132: FUNCTION FRACTION-PART ok 133: FUNCTION INTEGER ok 134: FUNCTION INTEGER-OF-DATE ok 135: FUNCTION INTEGER-OF-DAY ok 136: FUNCTION INTEGER-PART ok 137: FUNCTION LENGTH ok 138: FUNCTION LOCALE-DATE ok 139: FUNCTION LOCALE-TIME ok 140: FUNCTION LOCALE-TIME-FROM-SECONDS ok 141: FUNCTION LOG ok 142: FUNCTION LOG10 ok 143: FUNCTION LOWER-CASE ok 144: FUNCTION LOWER-CASE with reference modding ok 145: FUNCTION MAX ok 146: FUNCTION MEAN ok 147: FUNCTION MEDIAN ok 148: FUNCTION MIDRANGE ok 149: FUNCTION MIN ok 150: FUNCTION MOD ok 151: FUNCTION NUMVAL ok 152: FUNCTION NUMVAL-C ok 153: FUNCTION ORD ok 154: FUNCTION ORD-MAX ok 155: FUNCTION ORD-MIN ok 156: FUNCTION PI ok 157: FUNCTION PRESENT-VALUE ok 158: FUNCTION RANGE ok 159: FUNCTION REM ok 160: FUNCTION REVERSE ok 161: FUNCTION REVERSE with reference modding ok 162: FUNCTION SECONDS-FROM-FORMATTED-TIME ok 163: FUNCTION SECONDS-PAST-MIDNIGHT ok 164: FUNCTION SIGN ok 165: FUNCTION SIN ok 166: FUNCTION SQRT ok 167: FUNCTION STANDARD-DEVIATION ok 168: FUNCTION STORED-CHAR-LENGTH ok 169: FUNCTION TAN ok 170: FUNCTION TRIM ok 171: FUNCTION TRIM with reference modding ok 172: FUNCTION UPPER-CASE ok 173: FUNCTION UPPER-CASE with reference modding ok 174: FUNCTION VARIANCE ok 175: FUNCTION WHEN-COMPILED ok ## ------------- ## ## Test results. ## ## ------------- ## All 175 tests were successful. PASS: ./run-O ## ---------------------------------------------- ## ## OpenCOBOL 1.1 test suite: Data Representation. ## ## ---------------------------------------------- ## 1: BINARY: 2-4-8 big-endian ok 2: BINARY: 2-4-8 native ok 3: BINARY: 1-2-4-8 big-endian ok 4: BINARY: 1-2-4-8 native ok 5: BINARY: 1--8 big-endian ok 6: BINARY: 1--8 native ok 7: BINARY: full-print ok 8: DISPLAY: Sign ascii ok 9: DISPLAY: Sign ebcdic ok 10: PACKED-DECIMAL dump ok 11: PACKED-DECIMAL display ok 12: PACKED-DECIMAL move ok 13: PACKED-DECIMAL arithmetic (1) ok 14: PACKED-DECIMAL arithmetic (2) ok 15: PACKED-DECIMAL numeric test ok 16: POINTER: display ok ## ------------- ## ## Test results. ## ## ------------- ## All 16 tests were successful. PASS: ./data-rep ## Data representation tests with -O option ## ## ---------------------------------------------- ## ## OpenCOBOL 1.1 test suite: Data Representation. ## ## ---------------------------------------------- ## 1: BINARY: 2-4-8 big-endian ok 2: BINARY: 2-4-8 native ok 3: BINARY: 1-2-4-8 big-endian ok 4: BINARY: 1-2-4-8 native ok 5: BINARY: 1--8 big-endian ok 6: BINARY: 1--8 native ok 7: BINARY: full-print ok 8: DISPLAY: Sign ascii ok 9: DISPLAY: Sign ebcdic ok 10: PACKED-DECIMAL dump ok 11: PACKED-DECIMAL display ok 12: PACKED-DECIMAL move ok 13: PACKED-DECIMAL arithmetic (1) ok 14: PACKED-DECIMAL arithmetic (2) ok 15: PACKED-DECIMAL numeric test ok 16: POINTER: display ok ## ------------- ## ## Test results. ## ## ------------- ## All 16 tests were successful. PASS: ./data-rep-O ================== All 5 tests passed ================== @end verbatim @node Does OpenCOBOL pass the NIST Test Suite? @subsection Does OpenCOBOL pass the NIST Test Suite? OpenCOBOL passes many of the tests included in the NIST sponsored COBOL 85 test suite. While it passes over 9000 of the tests@comma{} OpenCOBOL does not claim conformance to any level of COBOL @emph{Standard}. The National Institute of Standards and Technology@comma{} NIST@comma{} maintains a COBOL 85 implementation verification suite of tests. An archive of the tests can be found at @uref{http://www.itl.nist.gov/div897/ctg/cobol_form.htm,http://www.itl.nist.gov/div897/ctg/cobol_form.htm} Instructions for use of the NIST suite is included in the build archive under: @verbatim tests/cobol85/README @end verbatim Basically@comma{} it is a simple @strong{uncompress} and @strong{make} then sit back and relax. The scripts run OpenCOBOL over some 364 programs/modules and includes thousands of test passes. @verbatim Test Modules ------------ Core tests: NC - COBOL nucleus tests SM - COPY sentence tests IC - CALL sentence tests File I-O tests: SQ - Sequential file I-O tests RL - Relative file I-O tests IX - Indexed file I-O tests ST - SORT sentence tests Advanced facilities: IF - Intrinsic Function tests @end verbatim With the addition of GLOBAL support@comma{} the OpenCOBOL 1.1 pre-release fails none of the attempted tests. The summary.log from a run in February 2009: @verbatim ------ Directory Information ------- --- Total Tests Information --- Module Programs Executed Error Crash Pass Fail Deleted Inspect Total ------ -------- -------- ----- ----- ----- ---- ------- ------- ----- NC 92 92 0 0 4363 0 6 11 4380 SM 15 15 0 0 290 0 3 1 294 IC 24 24 0 0 246 0 4 0 250 SQ 81 81 0 0 512 0 6 81 599 RL 32 32 0 0 1827 0 5 0 1832 IX 39 39 0 0 507 0 1 0 508 ST 39 39 0 0 278 0 0 0 278 SG 5 5 0 0 193 0 0 0 193 OB 5 5 0 0 16 0 0 0 16 IF 42 42 0 0 732 0 0 0 732 ------ -------- -------- ----- ----- ----- ---- ------- ------- ----- Total 374 374 0 0 8964 0 25 93 9082 @end verbatim @node What about OpenCOBOL and benchmarks? @subsection What about OpenCOBOL and benchmarks? COBOL has a legacy dating back to 1959. Many features of the COBOL standard provide defaults more suitable to mainframe architecture than the personal computer a 3rd millennium OpenCOBOL developer will likely be using. OpenCOBOL@comma{} by default@comma{} generates code optimized for big-endian_ hardware. Fairly dramatic speed improvements on Intel architecture can come from simple @strong{USAGE IS COMPUTATIONAL-5} clauses in the DATA DIVISION. @node Can OpenCOBOL be used for CGI? @subsection Can OpenCOBOL be used for CGI? Yes. Through standard IO redirection and the extended @strong{ACCEPT ... FROM ENVIRONMENT ...} feature@comma{} OpenCOBOL is more than capable of supporting advanced CGI programming. @quotation @table @asis @item COBOL >>SOURCE FORMAT IS FIXED @table @asis @item @strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@emph{*} Author: Brian Tiffin@comma{} Francois Hiniger * Date: 30-Aug-2008 * Purpose: Display the CGI environment space * Tectonics: cobc -x cgienv.cob * Move cgienv to the cgi-bin directory as cgienv.cgi * browse @uref{http://localhost/cgi-bin/cgienv.cgi,http://localhost/cgi-bin/cgienv.cgi} or cgienvform.html}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}** identification division. program-id. cgienv. environment division. input-output section. file-control. select webinput assign to KEYBOARD. data division. file section. fd webinput. 01 postchunk pic x(1024). working-storage section. 78 name-count value 34. 01 newline pic x value x'0a'. 01 name-index pic 99 usage comp-5. 01 value-string pic x(256). 01 environment-names. 02 name-strings. 03 filler pic x(20) value 'AUTH_TYPE'. 03 filler pic x(20) value 'CONTENT_LENGTH'. 03 filler pic x(20) value 'CONTENT_TYPE'. 03 filler pic x(20) value 'DOCUMENT_ROOT'. 03 filler pic x(20) value 'GATEWAY_INTERFACE'. 03 filler pic x(20) value 'HTTP_ACCEPT'. 03 filler pic x(20) value 'HTTP_ACCEPT_CHARSET'. 03 filler pic x(20) value 'HTTP_ACCEPT_ENCODING'. 03 filler pic x(20) value 'HTTP_ACCEPT_LANGUAGE'. 03 filler pic x(20) value 'HTTP_COOKIE'. 03 filler pic x(20) value 'HTTP_CONNECTION'. 03 filler pic x(20) value 'HTTP_HOST'. 03 filler pic x(20) value 'HTTP_REFERER'. 03 filler pic x(20) value 'HTTP_USER_AGENT'. 03 filler pic x(20) value 'LIB_PATH'. 03 filler pic x(20) value 'PATH'. 03 filler pic x(20) value 'PATH_INFO'. 03 filler pic x(20) value 'PATH_TRANSLATED'. 03 filler pic x(20) value 'QUERY_STRING'. 03 filler pic x(20) value 'REMOTE_ADDR'. 03 filler pic x(20) value 'REMOTE_HOST'. 03 filler pic x(20) value 'REMOTE_IDENT'. 03 filler pic x(20) value 'REMOTE_PORT'. 03 filler pic x(20) value 'REQUEST_METHOD'. 03 filler pic x(20) value 'REQUEST_URI'. 03 filler pic x(20) value 'SCRIPT_FILENAME'. 03 filler pic x(20) value 'SCRIPT_NAME'. 03 filler pic x(20) value 'SERVER_ADDR'. 03 filler pic x(20) value 'SERVER_ADMIN'. 03 filler pic x(20) value 'SERVER_NAME'. 03 filler pic x(20) value 'SERVER_PORT'. 03 filler pic x(20) value 'SERVER_PROTOCOL'. 03 filler pic x(20) value 'SERVER_SIGNATURE'. 03 filler pic x(20) value 'SERVER_SOFTWARE'. 02 filler redefines name-strings. 03 name-string pic x(20) occurs name-count times. procedure division. @end table @itemize @item Always send out the Content-type before any other IO @end itemize @quotation @table @asis @item display "Content-type: text/html" newline @end table end-display. display "" end-display. display "

CGI environment with OpenCOBOL

" end-display. display 'To cgienvform.html' "

" end-display. @end quotation @table @asis @item * Accept and display some of the known CGI environment values @table @asis @item perform varying name-index from 1 by 1 @table @asis @item until name-index > name-count @table @asis @item accept value-string from environment name-string(name-index) @end table end-accept display "" end-display if (name-string(name-index) = "REQUEST_METHOD") and (value-string = "POST") open input webinput read webinput at end move spaces to postchunk end-read close webinput display '" end-display end-if @end table @end table end-perform. display "
" name-string(name-index) ": " function trim (value-string trailing) "
' "First chunk of POST:" postchunk(1:72) "

" end-display. @end table @end table COOL goback. @end quotation cgienv.cgi form @quotation OpenCOBOL sample CGI form

OpenCOBOL sample CGI form

Text:
Password:
Checkbox:
One
Two

@end quotation @node Can OpenCOBOL be used for production applications? @subsection Can OpenCOBOL be used for production applications? Depends. OpenCOBOL is still in active development. Feature coverage is growing@comma{} and while the current implementation offers great coverage@comma{} applicability to any given situation would need to analyzed and risks evaluated before commitment to production use. The licensing allows for commercial use@comma{} but OpenCOBOL also ships with notice of indemnity@comma{} meaning that there are no guarantees when using OpenCOBOL@comma{} directly or indirectly. There may be a time when commercial support of OpenCOBOL is offered@comma{} but at the time of writing no known offering exists. @emph{Search google just in case!} And yes@comma{} OpenCOBOL is used in production environments. From [Roger]_: @verbatim Incidentally, OC has been (and still is) used in production environments since 2005. (This includes projects that I personally worked on plus other   projects reported to me; these worldwide) The OC project would not have been where it is today without the significant/enormous help from many-many persons. The THANKS file does not even do justice to this. @end verbatim @node Where can I get more information about COBOL? @subsection Where can I get more information about COBOL? The `COBOL FAQ`_ by William M Klein is a great place to start. A google of the search words "COBOL" or "OpenCOBOL" are bound to lead to enough days worth of reading of in-depth articles@comma{} opinions and technical information to satisfy the greatest of curiosities. The COBUG_ site @emph{COBOL User Groups} is also a wonderful resource for OpenCOBOL developers. @node Where can I get more information about OpenCOBOL? @subsection Where can I get more information about OpenCOBOL? The opencobol.org_ website is probably the best place to find out more about the OpenCOBOL system. @node Can I help out with the OpenCOBOL project? @subsection Can I help out with the OpenCOBOL project? Absolutely. Visit the opencobol.org_ website and either post a message asking what needs to be done@comma{} or perhaps join the development mailing list to find out the current state of development. See `Is there an OpenCOBOL mailing list?`_ for some details. OpenCOBOL is a GPL licensed open source project and while [Roger]_ is the lead developer he is quite open to code submissions. Having a central point of development allows for consistency and the very high level of quality control enjoyed by OpenCOBOL users. @node Is there an OpenCOBOL mailing list? @subsection Is there an OpenCOBOL mailing list? Yes. Visit opencobol.org_ for details. The OpenCOBOL development mailing list is graciously hosted by SourceForge. The ML archive is available at @uref{http://sourceforge.net/mailarchive/forum.php?forum_name=open-cobol-list,http://sourceforge.net/mailarchive/forum.php?forum_name=open-cobol-list} and once you have subscribed@comma{} the list will accept messages at the open-cobol-list email destination at lists.sourceforge.net. @node Where can I find more information about COBOL standards? @subsection Where can I find more information about COBOL standards? The `COBOL 85`_ standard is documented in @itemize @item ANSI X3.23-1985 @item ISO 1989-1985 @item ANSI X3.23a-1989 @item ANSI X3.23b-1993 @end itemize @node Do you know any good jokes? @subsection Do you know any good jokes? Maybe. @itemize @item A computer without COBOL and Fortran is like a piece of chocolate cake without ketchup or mustard. @emph{John Krueger} @item A determined coder can write COBOL programs in any language. @emph{Author: unknown} @item Rumour has it that the object oriented specification for COBOL was code named @emph{ADD 1 TO COBOL GIVING COBOL.} @emph{Author: unknown} A less verbose@comma{} more concise version; @emph{very unCOBOL that} @emph{ADD 1 TO COBOL.} @emph{Thanks to aoirthoir} And@comma{} just because; @emph{ADD 1 TO COBOL GIVING OpenCOBOL} @item A common disrepect of COBOL joke is that the acronym stands for: Completely Obsolete Business Oriented Language. @emph{Author unkown} We know better. The reality is: Can't Obsolesce Because Of Legacy. @emph{And why would you want to?} @emph{Brian Tiffin} @item COBOL Certainly Old But Often Limber. @emph{Brian Tiffin} @item Ruby on Rails? Don't forget COBOL ON COGS. @uref{http://www.coboloncogs.org/INDEX.HTM,http://www.coboloncogs.org/INDEX.HTM} @item Eat COBOL@comma{} 200 billion lines can't be wrong. @emph{Brian Tiffin} @item What did COBOL yell to the escaping thief? @strong{STOP RUN RETURNING NOW.} @emph{Brian Tiffin} @item What did COBOL reply to the executive? @emph{Why yes@comma{} I can} @strong{PERFORM JUMPS THRU HOOPS.} @emph{Brian Tiffin} @item What did OpenCOBOL reply to the executive? @emph{Sir@comma{} I can} @strong{PERFORM JUMPS THRU FLAMING-HOOPS UNTIL HELL-FREEZES-OVER.} @emph{And being COBOL@comma{} I have to show you how little code it takes:} @end itemize @quotation identification division. program-id. freeze. data division. working-storage section. 01 hell pic 9. 88 hell-freezes-over value 1. procedure division. perform jumps thru flaming-hoops until hell-freezes-over. stop run. jumps. flaming-hoops. divide 1 by 0 giving hell. @end quotation @quotation @emph{Brian Tiffin} @end quotation And how about a 5-7-5 haiku? @quotation program-id. no. procedure division. add 1 to return-code. @end quotation @quotation @emph{Brian Tiffin} @end quotation @node History @section History @menu * What is the history of COBOL?:: * What are the Official COBOL Standards?:: * What is the development history of OpenCOBOL?:: * What is the current version of OpenCOBOL?:: @end menu @node What is the history of COBOL? @subsection What is the history of COBOL? Starting in 1959@comma{} a committee was formed under the sponsorship of the United States Department of Defense to recommend a short range option regarding business computing. The Conference on Data System Languages (CODASYL) led by Joe Wegstein of National Bureau of Standards (now National Institute of Standards and Technology) developed a new language@comma{} and created the first standardized business computer programming language. The COmmon Business Oriented Language acronym was announced on September 18th@comma{} 1959. Late in 1960@comma{} @emph{essentially} the same COBOL program ran on two different hardware platforms@comma{} and stakeholders espied the potential for fulfilling the objective of industry wide@comma{} compatible business systems. @uref{http://en.wikipedia.org/wiki/Grace_Hopper,Admiral Grace Hopper} is affectionately referred to as the @emph{mother of the COBOL language} as she and her previous work with FLOW-MATIC greatly influenced the specifications of the first COBOL. Standards have been published for: @itemize @item COBOL-68 @item COBOL-74 @item COBOL-85 @item COBOL-2002 @item Draft work for COBOL-2008 is |currently| underway @end itemize and these roughly correspond to the year they were produced. Note the y2k flavour of four digit naming occurred after the millennium change. Estimates vary@comma{} but it is entirely reasonable to believe that of the some 300@comma{}000@comma{}000@comma{}000 (three hundred thousand million) lines of computer source code in production today@comma{} 200@comma{}000@comma{}000@comma{}000 (two hundred thousand million) lines are COBOL. A full 2/3rds of the world's source code. See the Wikipedia entry for COBOL_ for a lot more details. @node What are the Official COBOL Standards? @subsection What are the Official COBOL Standards? Many thanks to William Klein for details on what wordings are to be used when referencing COBOL Standards: @verbatim There are several references to "COBOL 85" and these are often distinguished from "Intrinsic Functions". The official (but really obscure) term that should be used is "Amended Third Standard COBOL". The "clearer" (and IMHO better) term that should be used is something like - "'85 Standard COBOL with its amendments" By 1991 (actually 1993 for ISO rather than ANSI) there was no such thing as "just '85 Standard COBOL". The only recognized Standard was the "base" document (X3.23-1985) ALONG with its two amendments - Intrinsic Functions Module Amendment - Corrections Amendment An interesting related fact is that the "Intrinsic Functions Module" was OPTIONAL in the ANSI and ISO COBOL Standards but was REQUIRED (at the HIGH level) for FIPS COBOL. As the "certification tests" were aimed at getting US government contracts, most vendors (who were still doing certification) actually treated Intrinsic Functions required not optional for "High-level" certification. (They were NOT included in the FIPS intermediate certification process). Bottom-Line: Although some intrinsic functions were added in the '02 Standard (and more are included in the draft revision), it is not proper (in my opinion) to distinguish between supporting the '85 Standard and supporting intrinsic functions. P.S. The corrections amendment did make some technical changes but all of these were included in the '02 Standard. Therefore, hopefully, what it did won't impact OpenCOBOL much. @end verbatim @node What is the development history of OpenCOBOL? @subsection What is the development history of OpenCOBOL? OpenCOBOL was initially developed by Keisuke Nishida [Keisuke]_ from experience working on @uref{http://tiny-cobol.sourceforge.net/index.php,TinyCOBOL} originally developed by Rildo Pragana. The first public release was version 0.9.0 on January 25th@comma{} 2002. Development continued apace@comma{} with version 0.30 released by Keisuke on August 8th@comma{} 2004. Roger While [Roger]_ then took up the role as lead developer on October 30th@comma{} 2004. @table @asis @item Version 0.31 was released February 1st@comma{} 2005. @item Version 0.32 was released May 12th@comma{} 2005. @item Version 0.33 started on May 13th@comma{} 2005. @item Version 1.0 was released on December 27th@comma{} 2007. @end table @node What is the current version of OpenCOBOL? @subsection What is the current version of OpenCOBOL? OpenCOBOL 1.0 was released December 27th@comma{} 2007 by Roger While [Roger]_. The decision to go 1.0 from the 0.33 version followed many incremental enhancements from 2005 through till late in 2007. OpenCOBOL 1.1 pre-release became active on December 27th@comma{} 2007 and is |currently| in active development. The pre-release source tar can be found at `OpenCOBOL 1.1`_ with installer instructions at `OpenCOBOL Install`_ and in the INSTALLING text file of the sources. After a download @quotation $ ./configure $ make $ make check $ sudo make install @end quotation will place a new set of binaries rooted off @strong{/usr/local} If you build a pre-release OC1.1@comma{} you will be able to compile the @strong{occurlrefresh.cbl} (with @strong{occurlsym.cpy}) application and an early @strong{occurl.c} libCURL wrapper that allows file transfers off the Internet. @strong{occurlrefresh} includes default filenames for retrieving the most recent pre-release source archive and only updates the local copy if there has been a newer upload. Thanks to [aoirthoir]_ for hosting these; |currently| at @uref{http://opencobol.add1tocobol.com/occurlrefresh.cbl,occurlrefresh.cbl} @uref{http://opencobol.add1tocobol.com/occurlsym.cpy,occurlsym.cpy} @uref{http://opencobol.add1tocobol.com/occurl.c,occurl.c} and then simply @quotation $ ./occurlrefresh @end quotation to download any new development archives. libCURL tests the modification timestamps@comma{} so this procedure is very resource efficient@comma{} only pulling from the server if there is something new. @node Using OpenCOBOL @section Using OpenCOBOL @menu * How do I install OpenCOBOL?:: * What are the configure options available for building OpenCOBOL?:: * Does OpenCOBOL have any other dependencies?:: * How does the OpenCOBOL compiler work?:: * What is cobc?:: * What is cobcrun?:: * What is cob-config?:: * What compiler options are supported?:: * What dialects are supported by OpenCOBOL?:: * What are the OpenCOBOL compile time configuration files?:: * Do you have a reasonable source code skeleton for OpenCOBOL?:: * What is ocdoc?:: * Does OpenCOBOL support any SQL databases?:: * What are the OpenCOBOL RESERVED WORDS?:: * Does OpenCOBOL support modules?:: * What is COB_PRE_LOAD?:: * What is the OpenCOBOL LINKAGE SECTION for?:: * What does the -fstatic-linkage OpenCOBOL compiler option do?:: * Can OpenCOBOL interface with Ada?:: * Does OpenCOBOL support SCREEN SECTION?:: * What are the OpenCOBOL SCREEN SECTION colour values?:: * Does OpenCOBOL support CRT STATUS?:: * What is CobCurses?:: * What is CobXRef?:: * Does OpenCOBOL implement Report Writer?:: * Does OpenCOBOL implement LINAGE?:: * Does OpenCOBOL implement any Intrinsic FUNCTIONs?:: * Can you clarify the use of FUNCTION in OpenCOBOL?:: * What is the difference between the LENGTH verb and FUNCTION LENGTH?:: * What STOCK CALL LIBRARY does OpenCOBOL offer?:: * What are the XF4 XF5 and X91 routines?:: * What is CBL_OC_NANOSLEEP OpenCOBOL library routine?:: * Can I run background processes using OpenCOBOL?:: * Can I use ctags with OpenCOBOL?:: * What about debugging OpenCOBOL programs?:: * Is there a C interface to OpenCOBOL?:: * What are some idioms for dealing with C char * data from OpenCOBOL?:: * Does OpenCOBOL support COPY includes?:: * Does OpenCOBOL support WHEN-COMPILED?:: * What is PI in OpenCOBOL?:: * Does OpenCOBOL support the Object features of the 2002 standard?:: * Does OpenCOBOL implement PICTURE 78?:: * Does OpenCOBOL implement CONSTANT?:: * What source formats are accepted by OpenCOBOL?:: * Does OpenCOBOL support continuation lines?:: * Does OpenCOBOL support string concatenation?:: * Does OpenCOBOL support D indicator debug lines?:: * Does OpenCOBOL support mixed case source code?:: * What is the shortest OpenCOBOL program?:: * What is the shortest Hello World program in OpenCOBOL?:: * How do I get those nifty sequential sequence numbers in a source file?:: * Is there a way to count trailing spaces in data fields using OpenCOBOL?:: * Is there a way to left justify an edited numeric field?:: * Is there a way to detemermine when OpenCOBOL is running ASCII or EBCDIC?:: * Is there a way to determine when OpenCOBOL is running on 32 or 64 bits?:: * Does OpenCOBOL support recursion?:: * Does OpenCOBOL capture arithmetic overflow?:: * Can OpenCOBOL be used for plotting?:: @end menu @node How do I install OpenCOBOL? @subsection How do I install OpenCOBOL? Installation instructions can be found at `OpenCOBOL Install`_. @table @asis @item Debian The Debian binary package makes installing OpenCOBOL 1.0 a snap. From @strong{root} or using sudo @end table @quotation $ apt-get open-cobol @end quotation @table @asis @item Windows Build from sources under Cygwin or MinGW. Follow the instructions from the site listed above. @end table Also see `What is the current version of OpenCOBOL?`_ @node What are the configure options available for building OpenCOBOL? @subsection What are the configure options available for building OpenCOBOL? @emph{configure} is a defacto standard development tool for POSIX compliant operating systems@comma{} in particular GNU/Linux. It examines the current environment and creates a Makefile suitable for the target computer and the package being built. For OpenCOBOL@comma{} the @emph{configure} script accepts @strong{--help} as a command line option to display all of the available configuration choices. @verbatim `configure' configures OpenCOBOL 1.1 to adapt to many kinds of systems. Usage: ./configure [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit ---quiet, --silent do not print `checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for `--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or `..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [/usr/local] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, `make install' will install all the files in `/usr/local/bin', `/usr/local/lib' etc. You can specify an installation prefix other than `/usr/local' using `--prefix', for instance `--prefix=$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --infodir=DIR info documentation [PREFIX/info] --mandir=DIR man documentation [PREFIX/man] Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --enable-experimental (OpenCOBOL) enable experimental code (Developers only!) --enable-param-check (OpenCOBOL) enable CALL parameter checking --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --disable-rpath do not hardcode runtime library paths --disable-nls do not use Native Language Support Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-cc= (OpenCOBOL) specify the C compiler used by cobc --with-seqra-extfh (OpenCOBOL) Use external SEQ/RAN file handler --with-cisam (OpenCOBOL) Use CISAM for ISAM I/O --with-disam (OpenCOBOL) Use DISAM for ISAM I/O --with-vbisam (OpenCOBOL) Use VBISAM for ISAM I/O --with-index-extfh (OpenCOBOL) Use external ISAM file handler --with-db1 (OpenCOBOL) use Berkeley DB 1.85 (libdb-1.85) --with-db (OpenCOBOL) use Berkeley DB 3.0 or later (libdb)(default) --with-lfs64 (OpenCOBOL) use large file system for file I/O (default) --with-dl (OpenCOBOL) use system dynamic loader (default) --with-patch-level (OpenCOBOL) define a patch level (default 0) --with-varse (OpenCOBOL) define variable sequential format (default 0) --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-pic try to use only PIC/non-PIC objects [default=use both] --with-tags[=TAGS] include additional configurations [automatic] --with-gnu-ld assume the C compiler uses GNU ld default=no --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib --without-libiconv-prefix don't search for libiconv in includedir and libdir --with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib --without-libintl-prefix don't search for libintl in includedir and libdir Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor CXXCPP C++ preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . @end verbatim @node Does OpenCOBOL have any other dependencies? @subsection Does OpenCOBOL have any other dependencies? OpenCOBOL relies on a native C compiler with POSIX compatibility. GCC being a freely available compiler collection supported by most operating systems |currently| in use. OpenCOBOL requires the following external libraries to be installed: @table @asis @item GNU MP (libgmp) 4.1.2 or later libgmp is used to implement decimal arithmetic. GNU MP is licensed under GNU Lesser General Public License. @item GNU Libtool (libltdl) libltdl is used to implement dynamic CALL statements. GNU Libtool is licensed under GNU Lesser General Public License. @end table NOTE - Libtool is not required for Linux and Windows (including MinGW and Cygwin) The following libraries are optional: @table @asis @item Berkeley DB (libdb) 1.85 or later libdb can be used to implement indexed file I/O and SORT/MERGE. Berkeley DB is licensed under the original BSD License (1.85) or their own open-source license (2.x or later). Note that@comma{} as of 2.x@comma{} if you linked your software with Berkeley DB@comma{} you must distribute the source code of your software along with your software@comma{} or you have to pay royalty to Oracle Corporation. For more information about Oracle Berkeley DB dual licensing go to : Oracle / Embedded / Oracle Berkeley DB @item Ncurses (libncurses) 5.2 or later libncurses can be used to implement SCREEN SECTION. Ncurses is licensed under a BSD-style license. @end table @node How does the OpenCOBOL compiler work? @subsection How does the OpenCOBOL compiler work? OpenCOBOL is a multi-stage command line driven compiler. Command line options control what stages are performed during processing. 1. Preprocess #. Translate #. Compile #. Assemble #. Link #. Build OpenCOBOL produces intermediate C source code that is then passed to a configured C compiler and other tools. the GNU C compiler@comma{} @strong{gcc} being a standard. The main tool@comma{} @strong{cobc}@comma{} by default@comma{} produces modules@comma{} linkable shared object files. Example @quotation $ cat hello.cob @end quotation Original source code; @quotation 000100* HELLO.COB OpenCOBOL FAQ example 000200 IDENTIFICATION DIVISION. 000300 PROGRAM-ID. hello. 000400 PROCEDURE DIVISION. 000500 DISPLAY "Hello World!". 000600 STOP RUN. @end quotation OpenCOBOL stages. Preprocess @quotation $ cobc -E hello.cob @end quotation Preprocess only; For one thing@comma{} FIXED format becomes FREE format. For another COPY is processed. Displays @quotation # 1 "hello.cob" IDENTIFICATION DIVISION. PROGRAM-ID. hello. PROCEDURE DIVISION. DISPLAY "Hello World!". STOP RUN. @end quotation to standard out. Translate @quotation $ cobc -C hello.cob @end quotation Translate only; preprocesses and then translates the COBOL sources into C. You can examine these files to get a good sense of how the OpenCOBOL environment interacts with the native C facilities. OpenCOBOL 1.1 produced @strong{hello.c.h} and @strong{hello.c}. hello.c.h @quotation /* Generated by cobc 1.1.0 @emph{/ /} Generated from hello.cob @emph{/ /} Generated at Oct 04 2008 00:19:36 EDT @emph{/ /} OpenCOBOL build date Oct 01 2008 22:15:19 @emph{/ /} OpenCOBOL package date Oct 01 2008 16:31:26 CEST @emph{/ /} Compile command cobc -C hello.cob */ /* PROGRAM-ID : hello */ static unsigned char b_5[4] __attribute__((aligned)); /* COB-CRT-STATUS @emph{/ static unsigned char b_1[4] __attribute__((aligned)); /} RETURN-CODE @emph{/ static unsigned char b_2[4] __attribute__((aligned)); /} SORT-RETURN @emph{/ static unsigned char b_3[4] __attribute__((aligned)); /} NUMBER-OF-CALL-PARAMETERS */ /* attributes */ static cob_field_attr a_1 = @{16@comma{} 4@comma{} 0@comma{} 0@comma{} NULL@}; static cob_field_attr a_2 = @{33@comma{} 0@comma{} 0@comma{} 0@comma{} NULL@}; /* fields @emph{/ static cob_field f_5 = @{4@comma{} b_5@comma{} &a_1@}; /} COB-CRT-STATUS */ /* constants @emph{/ static cob_field c_1 = @{12@comma{} (unsigned char})"Hello World!"@comma{} &a_2@}; /* ---------------------------------------------- */ @end quotation hello.c @quotation /* Generated by cobc 1.1.0 @emph{/ /} Generated from hello.cob @emph{/ /} Generated at Oct 04 2008 00:19:36 EDT @emph{/ /} OpenCOBOL build date Oct 01 2008 22:15:19 @emph{/ /} OpenCOBOL package date Oct 01 2008 16:31:26 CEST @emph{/ /} Compile command cobc -C hello.cob */ #define __USE_STRING_INLINES 1 #include #include #include #include #include #define COB_SOURCE_FILE "hello.cob" #define COB_PACKAGE_VERSION "1.1" #define COB_PATCH_LEVEL 0 /* function prototypes */ static int hello_ (const int); int hello (void); /* functions */ int hello () @{ return hello_ (0); @} /* end functions */ static int hello_ (const int entry) @{ #include "hello.c.h" /* local variables */ @quotation static int initialized = 0; static cob_field *cob_user_parameters[COB_MAX_FIELD_PARAMS]; static cob_module module = @{ NULL@comma{} NULL@comma{} &f_5@comma{} NULL@comma{} cob_user_parameters@comma{} 0@comma{} '.'@comma{} '$'@comma{} '@comma{}'@comma{} 1@comma{} 1@comma{} 1@comma{} 0@}; /* perform frame stack @emph{/ int frame_index; struct frame @{ int perform_through; void}return_address; @} frame_stack[255]; /* Start of function code */ @table @asis @item if (unlikely(entry < 0)) @{ @table @asis @item if (!initialized) @{ return 0; @end table @} initialized = 0; return 0; @end table @} module.next = cob_current_module; cob_current_module = &module; @table @asis @item if (unlikely(initialized == 0)) @table @asis @item @{ @table @asis @item if (!cob_initialized) @{ cob_fatal_error (COB_FERROR_INITIALIZED); @end table @} cob_check_version (COB_SOURCE_FILE@comma{} COB_PACKAGE_VERSION@comma{} COB_PATCH_LEVEL); if (module.next) cob_set_cancel ((const char @emph{)"hello"@comma{} (void})hello@comma{} (void @emph{)hello_); (}(int @emph{) (b_1)) = 0; (}(int @emph{) (b_2)) = 0; (}(int *) (b_3)) = 0; memset (b_5@comma{} 48@comma{} 4); initialized = 1; @end table @} @end table /* initialize frame stack */ frame_index = 0; frame_stack[0].perform_through = -1; /* initialize number of call params @emph{/ (}(int *) (b_3)) = cob_call_params; cob_save_call_params = cob_call_params; goto l_2; /* PROCEDURE DIVISION */ /* hello: */ l_2:; /* MAIN SECTION: */ /* MAIN PARAGRAPH: */ /* hello.cob:5: DISPLAY @emph{/ @{ cob_new_display (0@comma{} 1@comma{} 1@comma{} &c_1); @} /} hello.cob:6: STOP @emph{/ @{ cob_stop_run ((}(int *) (b_1))); @} cob_current_module = cob_current_module->next; return (@emph{(int}) (b_1)); @end quotation @} /* end function stuff */ @end quotation Generate assembler: @verbatim $ cobc -S hello.cob @end verbatim hello.s @quotation .file "cob9141_0.c" .text @end quotation @quotation @table @asis @item .globl hello .type hello@comma{} @@function @item hello: pushl %ebp movl %esp@comma{} %ebp subl $8@comma{} %esp movl $0@comma{} (%esp) call hello_ leave ret .size hello@comma{} .-hello .data .align 4 .type module.5786@comma{} @@object .size module.5786@comma{} 28 @item module.5786: .long 0 .long 0 .long f_5.5782 .long 0 .long cob_user_parameters.5785 .byte 0 .byte 46 .byte 36 .byte 44 .byte 1 .byte 1 .byte 1 .byte 0 .local cob_user_parameters.5785 .comm cob_user_parameters.5785@comma{}256@comma{}32 .local initialized.5784 .comm initialized.5784@comma{}4@comma{}4 .section .rodata @item .LC0: .string "Hello World!" .data .align 4 .type c_1.5783@comma{} @@object .size c_1.5783@comma{} 12 @item c_1.5783: .long 12 .long .LC0 .long a_2.5781 .align 4 .type f_5.5782@comma{} @@object .size f_5.5782@comma{} 12 @item f_5.5782: .long 4 .long b_5.5776 .long a_1.5780 .align 4 .type a_2.5781@comma{} @@object .size a_2.5781@comma{} 8 @item a_2.5781: .byte 33 .byte 0 .byte 0 .byte 0 .long 0 .align 4 .type a_1.5780@comma{} @@object .size a_1.5780@comma{} 8 @item a_1.5780: .byte 16 .byte 4 .byte 0 .byte 0 .long 0 .local b_3.5779 .comm b_3.5779@comma{}4@comma{}16 .local b_2.5778 .comm b_2.5778@comma{}4@comma{}16 .local b_1.5777 .comm b_1.5777@comma{}4@comma{}16 .local b_5.5776 .comm b_5.5776@comma{}4@comma{}16 .section .rodata @item .LC1: .string "1.1" @item .LC2: .string "hello.cob" @item .LC3: .string "hello" .text .type hello_@comma{} @@function @item hello_: pushl %ebp movl %esp@comma{} %ebp subl $2072@comma{} %esp movl 8(%ebp)@comma{} %eax shrl $31@comma{} %eax testl %eax@comma{} %eax je .L4 movl initialized.5784@comma{} %eax testl %eax@comma{} %eax jne .L5 movl $0@comma{} -2052(%ebp) jmp .L6 @item .L5: movl $0@comma{} initialized.5784 movl $0@comma{} -2052(%ebp) jmp .L6 @item .L4: movl cob_current_module@comma{} %eax movl %eax@comma{} module.5786 movl $module.5786@comma{} cob_current_module movl initialized.5784@comma{} %eax testl %eax@comma{} %eax sete %al movzbl %al@comma{} %eax testl %eax@comma{} %eax je .L7 movl cob_initialized@comma{} %eax testl %eax@comma{} %eax jne .L8 movl $0@comma{} (%esp) call cob_fatal_error @item .L8: movl $0@comma{} 8(%esp) movl $.LC1@comma{} 4(%esp) movl $.LC2@comma{} (%esp) call cob_check_version movl module.5786@comma{} %eax testl %eax@comma{} %eax je .L9 movl $hello_@comma{} 8(%esp) movl $hello@comma{} 4(%esp) movl $.LC3@comma{} (%esp) call cob_set_cancel @item .L9: movl $b_1.5777@comma{} %eax movl $0@comma{} (%eax) movl $b_2.5778@comma{} %eax movl $0@comma{} (%eax) movl $b_3.5779@comma{} %eax movl $0@comma{} (%eax) movl $4@comma{} 8(%esp) movl $48@comma{} 4(%esp) movl $b_5.5776@comma{} (%esp) call memset movl $1@comma{} initialized.5784 @item .L7: movl $0@comma{} -4(%ebp) movl $-1@comma{} -2044(%ebp) movl $b_3.5779@comma{} %edx movl cob_call_params@comma{} %eax movl %eax@comma{} (%edx) movl cob_call_params@comma{} %eax movl %eax@comma{} cob_save_call_params @item .L10: movl $c_1.5783@comma{} 12(%esp) movl $1@comma{} 8(%esp) movl $1@comma{} 4(%esp) movl $0@comma{} (%esp) call cob_new_display movl $b_1.5777@comma{} %eax movl (%eax)@comma{} %eax movl %eax@comma{} (%esp) call cob_stop_run @item .L6: movl -2052(%ebp)@comma{} %eax leave ret .size hello_@comma{} .-hello_ .ident "GCC: (Debian 4.3.1-9) 4.3.1" .section .note.GNU-stack@comma{}""@comma{}@@progbits @end table @end quotation Compile only; outputs assembly file. Produces @strong{hello.s}. Produce object code @quotation $ cobc -c hello.cob @end quotation Compile and assemble@comma{} do not link. Produces @strong{hello.o}. Build modules @quotation $ cobc -m hello.cob @end quotation Build dynamically loadable module. The is the @emph{default behaviour}. This example produces @strong{hello.so} or @strong{hello.dll}. Module run @quotation $ cobcrun hello @end quotation Will scan the DSO_ hello.so@comma{} and then link@comma{} load@comma{} and execute hello. @quotation $ cobc -x hello.cob @end quotation Build an executable program. This examples produces @strong{hello} or @strong{hello.exe}. @strong{This is important}. @emph{cobc} produces a @emph{Dynamic Shared Object} by default. @emph{To create executables}@comma{} you need to use @strong{-x}. @quotation $ ./hello Hello World! @end quotation OpenCOBOL also supports features for multiple source@comma{} multiple language programming@comma{} detailed in the FAQ at `Does OpenCOBOL support modules?`_. @node What is cobc? @subsection What is cobc? @strong{cobc} is the OpenCOBOL compiler. See `What compiler options are supported?`_ for more information. @node What is cobcrun? @subsection What is cobcrun? @strong{cobcrun} is the OpenCOBOL driver program that allows the execution of programs stored in OpenCOBOL modules. The @strong{cobc} compiler@comma{} by default@comma{} produces modules (the @emph{-m} option). These modules are linkable dynamic shared objects (DSO). Using GNU/Linux for example @quotation $ cobc -x hello.cob $ ./hello Hello World! $ cobc hello.cob $ cobcrun hello Hello World! @end quotation The @strong{cobc -x hello.cob} built an executable binary called hello. The @strong{cobc hello.cob} produced a DSO_ hello.so@comma{} and cobcrun resolves the entry point and executes the code@comma{} right from the DSO_. @strong{cobcrun} @emph{is the compiler author's preferred way to manage OpenCOBOL development.} It alleviates knowing which source file needs @emph{-x} while encouraging proper modular programming@comma{} a mainstay of OpenCOBOL. @node What is cob-config? @subsection What is cob-config? @strong{cob-config} is a program that can be used to find the C compiler flags and libraries required for compiling. Using GNU/Linux for example: @verbatim $ cob-config Usage: cob-config [OPTIONS] Options: [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libs] [--cflags] $ cob-config --libs -L/usr/local/lib -lcob -lm -lgmp -lncurses -ldb $ cob-config --cflags -I/usr/local/include @end verbatim You may need to use these features during mixed source language development@comma{} usually by back-ticking the command output inline with other @strong{gcc} commands. @node What compiler options are supported? @subsection What compiler options are supported? The OpenCOBOL system strives to be standards compliant@comma{} yet also remain a viable compiler option for the many billions of existing lines of COBOL sources. Many details of the compile can be controlled with command line options. Please also see `What are the OpenCOBOL compile time configuration files?`_ for more details on this finely tuned control. @verbatim $ cobc -V cobc (OpenCOBOL) 1.1.0 Copyright (C) 2001-2008 Keisuke Nishida / Roger While Built Oct 29 2008 16:32:02 Packaged Oct 28 2008 19:05:45 CET $ cobc --help Usage: cobc [options] file... Options: --help Display this message --version, -V Display compiler version -v Display the programs invoked by the compiler -x Build an executable program -m Build a dynamically loadable module (default) -std= Compile for a specific dialect : cobol2002 Cobol 2002 cobol85 Cobol 85 ibm IBM Compatible mvs MVS Compatible bs2000 BS2000 Compatible mf Micro Focus Compatible default When not specified See config/default.conf and config/*.conf -free Use free source format -fixed Use fixed source format (default) -O, -O2, -Os Enable optimization -g Produce debugging information in the output -debug Enable all run-time error checking -o Place the output into -b Combine all input files into a single dynamically loadable module -E Preprocess only; do not compile, assemble or link -C Translation only; convert COBOL to C -S Compile only; output assembly file -c Compile and assemble, but do not link -t Generate and place a program listing into -I Add to copy/include search path -L Add to library search path -l Link the library -D Pass to the C compiler -conf= User defined dialect configuration - See -std= --list-reserved Display reserved words --list-intrinsics Display intrinsic functions --list-mnemonics Display mnemonic names -save-temps(=) Save intermediate files (default current directory) -MT Set target file used in dependency list -MF Place dependency list into -ext Add default file extension -W Enable ALL warnings -Wall Enable all warnings except as noted below -Wobsolete Warn if obsolete features are used -Warchaic Warn if archaic features are used -Wredefinition Warn incompatible redefinition of data items -Wconstant Warn inconsistent constant -Wparentheses Warn lack of parentheses around AND within OR -Wstrict-typing Warn type mismatch strictly -Wimplicit-define Warn implicitly defined data items -Wcall-params Warn non 01/77 items for CALL params (NOT set with -Wall) -Wcolumn-overflow Warn text after column 72 (FIXED format, NOT set with -Wall) -Wterminator Warn lack of scope terminator (END-XXX, NOT set with -Wall) -Wtruncate Warn possible field truncation (NOT set with -Wall) -Wlinkage Warn dangling LINKAGE items (NOT set with -Wall) -ftrace Generate trace code (Executed SECTION/PARAGRAPH) -ftraceall Generate trace code (Executed SECTION/PARAGRAPH/STATEMENTS) -fsyntax-only Syntax error checking only; don't emit any output -fdebugging-line Enable debugging lines ('D' in indicator column) -fsource-location Generate source location code (Turned on by -debug or -g) -fimplicit-init Do automatic initialization of the Cobol runtime system -fsign-ascii Numeric display sign ASCII (Default on ASCII machines) -fsign-ebcdic Numeric display sign EBCDIC (Default on EBCDIC machines) -fstack-check PERFORM stack checking (Turned on by -debug or -g) -ffold-copy-lower Fold COPY subject to lower case (Default no transformation) -ffold-copy-upper Fold COPY subject to upper case (Default no transformation) -fnotrunc Do not truncate binary fields according to PICTURE -ffunctions-all Allow use of intrinsic functions without FUNCTION keyword -fmfcomment '*' or '/' in column 1 treated as comment (FIXED only) -fnull-param Pass extra NULL terminating pointers on CALL statements @end verbatim @node What dialects are supported by OpenCOBOL? @subsection What dialects are supported by OpenCOBOL? Using the @strong{std=} compiler option@comma{} OpenCOBOL can be configured to compile using specific historical COBOL compiler features and quirks. Supported dialects include: @itemize @item default @item cobol85 @item cobol2002 @item ibm @item mvs @item mf @item bs2000 @end itemize For details on what options and switches are used to support these dialect compiles@comma{} see the @strong{config/} directory of your OpenCOBOL installation. For Debian GNU/Linux@comma{} that will be @strong{/usr/share/open-cobol/config/} if you used APT to install an OpenCOBOL package or @strong{/usr/local/share/open-cobol/config/} after a build from the source archive. For example: the @emph{bs2000.conf} file restricts data representations to 2@comma{} 4 or 8 byte binary while @emph{mf.conf} allows data representations from 1 thru 8 bytes. @emph{cobol85.conf} allows debugging lines@comma{} @emph{cobol2002.conf} configures the compiler to warn that this feature is obsolete. @node What are the OpenCOBOL compile time configuration files? @subsection What are the OpenCOBOL compile time configuration files? To assist in the support of the various existent COBOL compilers@comma{} OpenCOBOL reads configuration files controlling various aspects of a compile pass. Each supported dialect will also have a @emph{.conf} file in the @strong{config/} sub-directory of its installation. For Debian GNU/Linux@comma{} these will be in @strong{/usr/share/open-cobol/config/} or @strong{/usr/local/share/open-cobol/config} under default package and default @emph{make} conditions. For example@comma{} the default configuration@comma{} @emph{default.conf} is: @verbatim # COBOL compiler configuration -*- sh -*- # Value: any string name: "OpenCOBOL" # Value: int tab-width: 8 text-column: 72 # Value: `cobol2002', `mf', `ibm' # assign-clause: mf # If yes, file names are resolved at run time using environment variables. # For example, given ASSIGN TO "DATAFILE", the actual file name will be # 1. the value of environment variable `DD_DATAFILE' or # 2. the value of environment variable `dd_DATAFILE' or # 3. the value of environment variable `DATAFILE' or # 4. the literal "DATAFILE" # If no, the value of the assign clause is the file name. # # Value: `yes', `no' filename-mapping: yes # Value: `yes', `no' pretty-display: yes # Value: `yes', `no' auto-initialize: yes # Value: `yes', `no' complex-odo: no # Value: `yes', `no' indirect-redefines: no # Value: signed unsigned bytes # ------ -------- ----- # `2-4-8' 1 - 4 2 # 5 - 9 4 # 10 - 18 8 # # `1-2-4-8' 1 - 2 1 # 3 - 4 2 # 5 - 9 4 # 10 - 18 8 # # `1--8' 1 - 2 1 - 2 1 # 3 - 4 3 - 4 2 # 5 - 6 5 - 7 3 # 7 - 9 8 - 9 4 # 10 - 11 10 - 12 5 # 12 - 14 13 - 14 6 # 15 - 16 15 - 16 7 # 17 - 18 17 - 18 8 binary-size: 1-2-4-8 # Value: `yes', `no' binary-truncate: yes # Value: `native', `big-endian' binary-byteorder: big-endian # Value: `yes', `no' larger-redefines-ok: no # Value: `yes', `no' relaxed-syntax-check: no # Perform type OSVS - If yes, the exit point of any currently executing perform # is recognized if reached. # Value: `yes', `no' perform-osvs: no # If yes, non-parameter linkage-section items remain allocated # between invocations. # Value: `yes', `no' sticky-linkage: no # If yes, allow non-matching level numbers # Value: `yes', `no' relax-level-hierarchy: no # not-reserved: # Value: Word to be taken out of the reserved words list # (case independent) # Dialect features # Value: `ok', `archaic', `obsolete', `skip', `ignore', `unconformable' author-paragraph: obsolete memory-size-clause: obsolete multiple-file-tape-clause: obsolete label-records-clause: obsolete value-of-clause: obsolete data-records-clause: obsolete top-level-occurs-clause: skip synchronized-clause: ok goto-statement-without-name: obsolete stop-literal-statement: obsolete debugging-line: obsolete padding-character-clause: obsolete next-sentence-phrase: archaic eject-statement: skip entry-statement: obsolete move-noninteger-to-alphanumeric: error odo-without-to: ok @end verbatim @node Do you have a reasonable source code skeleton for OpenCOBOL? @subsection Do you have a reasonable source code skeleton for OpenCOBOL? Maybe. Style is a very personal developer choice. OpenCOBOL pays homage to this freedom of choice. Here is the FIXED form header that this author uses. It includes @strong{ocdoc} lines. @quotation @table @asis @item @emph{>}* @emph{>>SOURCE FORMAT IS FIXED}> @strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{* @emph{><} =========== @emph{><} @emph{><} =========== @emph{><} :Author: @emph{><} :Date: @emph{><} :Purpose: @emph{><} :Tectonics: cobc @emph{>}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} identification division. program-id. . environment division. configuration section. input-output section. file-control. @item @emph{> select}> assign to @emph{> organization is}> . @quotation data division. file section. @end quotation @emph{>fd .}> 01 . @quotation working-storage section. local-storage section. linkage section. screen section. @end quotation @table @asis @item @emph{>}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{*}}}}}}}}}}}}}}}* procedure division. goback. end program . @end table @emph{><} @emph{><} Last Update: dd-Mmm-yyyy @end table @end quotation Fill in the @emph{program-id} and @emph{end program} to compile. Fill in the ocdoc title for generating documentation. See `What is ocdoc?`_ for more information on @emph{(one method of)} inline documentation. Here are some templates that can cut and pasted. Fixed form in lowercase @quotation @table @asis @item @emph{>}* @emph{>>SOURCE FORMAT IS FIXED}> @strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{* @emph{> Author:}> Date: @emph{> Purpose:}> Tectonics: cobc @emph{>}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} identification division. program-id. . environment division. configuration section. input-output section. @item @emph{> file-control.}> select @emph{> assign to}> organization is *> . @quotation data division. @end quotation @emph{> file section.}> fd . *> 01 . @quotation working-storage section. local-storage section. linkage section. screen section. @end quotation @table @asis @item @emph{>}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{*}}}}}}}}}}}}}}}* procedure division. goback. end program . @end table @end table @end quotation Fixed form in UPPERCASE @quotation @table @asis @item OCOBOL >>SOURCE FORMAT IS FIXED @table @asis @item @strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@emph{*} Author: * Date: * Purpose: * Tectonics: cobc}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}** IDENTIFICATION DIVISION. PROGRAM-ID. . ENVIRONMENT DIVISION. CONFIGURATION SECTION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT ASSIGN TO ORGANIZATION IS . DATA DIVISION. FILE SECTION. FD . 01 . WORKING-STORAGE SECTION. LOCAL-STORAGE SECTION. LINKAGE SECTION. SCREEN SECTION. @item @strong{*}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@emph{*}}}}}}}}}}}}}}}** PROCEDURE DIVISION. GOBACK. END PROGRAM . @end table @end table @end quotation The OCOBOL "sequence number" can safely be removed. It is there to ensure proper alignment in the browser. Free form. Due to an indentation formatting problem with ReST documentation sources@comma{} the first line is separated out: @verbatim >>SOURCE FORMAT IS FREE @end verbatim the above line must start in column 7@comma{} or use @strong{cobc -free} @quotation @emph{>}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@emph{*}> Author: @emph{> Date:}> Purpose: @emph{> Tectonics: cobc -free}>}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}@emph{*} identification division. program-id. . environment division. configuration section. input-output section. file-control. select assign to organization is . data division. file section. fd . 01 . working-storage section. local-storage section. linkage section. screen section. procedure division. goback. end program . @end quotation These files can be downloaded from @itemize @item @uref{http://opencobol.add1tocobol.com/sources/headfix.cob,headfix.cob} @item @uref{http://opencobol.add1tocobol.com/sources/headfixupper.cob,headfixuppper.cob} @item @uref{http://opencobol.add1tocobol.com/sources/headfree.cob,headfree.cob} @end itemize @node What is ocdoc? @subsection What is ocdoc? @strong{ocdoc} is a small utility used to annotate sample programs and to support generation of Usage Documentation using COBOL sourced ReStructuredText extract lines. ocdoc.cob @quotation @table @asis @item @emph{>}* @emph{>>SOURCE FORMAT IS FIXED}> @strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{* @emph{><} ===================== @emph{><} ocdoc.cob usage guide @emph{><} ===================== @emph{><} .. sidebar:: Table of Contents @emph{><} @emph{><} .. contents:: :local: @emph{><} @emph{><} :Author: Brian Tiffin @emph{><} :Date: 30-Sep-2008 @emph{><} :Rights: Copyright (c) 2008@comma{} Brian Tiffin. @emph{><} GNU FDL License. @emph{><} :Purpose: Extract usage document lines from COBOL sources. @emph{><} Using OpenCOBOL 1.1pr. OpenCOBOL is tasty. @emph{><} :Tectonics: cobc -x ocdoc.cob @emph{><} :Docgen: $ ./ocdoc ocdoc.cob ocdoc.rst ocdoc.html skin.css @emph{>}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} @emph{><} @emph{><} ------------@emph{><} Command line @emph{><} ------------@emph{><} @emph{ocdoc} runs in two forms. @emph{><} @emph{><} Without arguments@comma{} @emph{ocdoc} will act as a pipe filter. @emph{><} Reading from standard in and writing the extract to standard @emph{><+ out.}><* @emph{><} The @emph{ocdoc} command also takes an input file@comma{} an extract @emph{><+ filename@comma{} an optional result file (with optional}><+ stylesheet) and a verbosity option @emph{-v} or a @emph{><+ special}-fixed* flag (to force skipping sequence numbers). @emph{><} If a result file is given@comma{} ocdoc will automatically @emph{><} run an @emph{rst2html} command using the SYSTEM service. @emph{><} @emph{><} Due to an overly simplistic argument handler@comma{} you can only @emph{><+ turn on verbosity or -fixed when using all four filenames.}><* @emph{><} Examples:: @emph{><} @emph{><} $ cat ocdoc.cob | ocdoc >ocdoc.rst @emph{><} $ ./ocdoc ocdoc.cob ocdoc.rst @emph{><} $ ./ocdoc ocdoc.cob ocdoc.rst @emph{><+ ocdoc.html skin.css -fixed}><* ... @emph{><} Input : ocdoc.cob @emph{><} Output : ocdoc.rst @emph{><} Command: rst2html --stylesheet=skin.css @emph{><+ ocdoc.rst ocdoc.html}><* @emph{><} -----------------@emph{><} What is extracted @emph{><} -----------------@emph{><} - Lines that begin with *><* @emph{ignoring spaces}@comma{} are @emph{><+ extracted.}><* @emph{><} - Lines that begin with *><+ are appended to the @emph{><+ previous output line. As lines are trimmed of trailing}><+ spaces@comma{} and @emph{ocdoc} removes the space following the @emph{><+ extract triggers@comma{} you may need two spaces after an}><+ ocdoc append. @emph{><} @emph{><} - Lines that begin with *><[ begin a here document @emph{><+ with lines that follow extracted as is.}><* @emph{><} - Lines that begin with *><] close a here document. @emph{><+ Here document start and end lines are excluded from the}><+ extract. @emph{><} @emph{><} -----------@emph{><} Source code @emph{><} -----------@emph{><} `Download ocdoc.cob @emph{><+ <@uref{http://opencobol.add1tocobol.com/ocdoc.cob,http://opencobol.add1tocobol.com/ocdoc.cob}>`_}><* `See ocdocseq.cob @emph{><+ <@uref{http://opencobol.add1tocobol.com/ocdocseq.html,http://opencobol.add1tocobol.com/ocdocseq.html}>`_}><* @emph{><* @emph{><} -----------------------@emph{><} identification division @emph{><} -----------------------@emph{><} @emph{><} :: @emph{><} *><[ identification division. program-id. OCDOC. @quotation environment division. input-output section. file-control. select standard-input assign to KEYBOARD. select standard-output assign to DISPLAY. @quotation select source-input assign to source-name organization is line sequential . select doc-output assign to doc-name organization is line sequential . @end quotation @end quotation @emph{><]}><* @emph{><} -------------@emph{><} data division @emph{><} -------------@emph{><} @emph{><} :: @emph{><} *><[ data division. file section. fd standard-input. 01 stdin-record pic x(256). fd standard-output. 01 stdout-record pic x(256). @quotation @table @asis @item fd source-input. 01 source-record pic x(256). @item fd doc-output. 01 doc-record pic x(256). @end table working-storage section. 01 arguments pic x(256). 01 source-name pic x(256). 01 doc-name pic x(256). 01 result-name pic x(256). 01 style-name pic x(256). 01 verbosity pic x(9). 88 verbose values "-v" "--v" "-verbose" "--verbose". 88 skipseqnum values "-fix" "-fixed" "--fix" "--fixed". 01 usagehelp pic x(6). 88 helping values "-h" "--h" "-help" "--help". 01 filter-flag pic x value low-value. 88 filtering value high-value. 01 line-count usage binary-long. 01 line-display pic z(8)9. @end quotation @emph{><]}><* @emph{><} Note the conditional test for end of here doc @emph{><} @emph{><} :: @emph{><} @emph{><[ 01 trimmed pic x(256). 88 herestart value "}><[". 88 hereend value "*><]". @quotation @table @asis @item 01 hereflag pic x value low-value. 88 heredoc value high-value. 88 herenone value low-value. @end table @end quotation @emph{><]}><* @emph{><} Note the here-record adds an ocdoc extract to lines that @emph{><+ follow.}><* @emph{><} :: @emph{><} @emph{><[ 01 here-record. 02 filler pic x(5) value "}><* ". 02 here-data pic x(251). @quotation @table @asis @item 01 seq-record. 02 filler pic x(7) value " ". 02 seq-data pic x(249). @end table 01 doc-buffer pic x(256). 01 buffer-offset pic 999 usage comp-5 value 1. 01 buffer-flag pic x value low-value. 88 buffer-empty value low-value. 88 buffered-output value high-value. 01 counter pic 999 usage comp-5. 01 len-of-comment pic 999 usage comp-5. @table @asis @item 01 first-part pic x(8). 88 special values "@emph{><}" "@emph{><+". 88 autodoc value "}><@emph{". 88 autoappend value "}><+". @end table 01 rst-command pic x(256). 01 result usage binary-long. @end quotation @emph{><]}><* @emph{><} ------------------@emph{><} procedure division @emph{><} ------------------@emph{><} @emph{><} :: @emph{><} @emph{><[}> @strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@emph{*}}}}}}}}}}}}}}}} procedure division. @emph{><]}><* @emph{><} Accept command line arguments. See if help requested. @emph{><} @emph{><} :: @emph{><} *><[ accept arguments from command-line end-accept @quotation move arguments to usagehelp if helping display "$ ./ocdoc source markover [output [skin [--fixed]]]" end-display display "$ ./ocdoc" end-display display " without arguments extracts stdin to stdout" end-display goback end-if @end quotation @emph{><]}><* @emph{><} Either run as filter or open given files. Two filenames @emph{><+ will generate an extract. Three will run the extract}><+ through @emph{rst2html} using an optional fourth filename @emph{><+ as a stylesheet.}><* @emph{><} :: @emph{><} @emph{><[}> Determine if this is running as a filter if arguments not equal spaces unstring arguments delimited by all spaces into source-name doc-name result-name style-name verbosity end-unstring @quotation open input source-input open output doc-output @end quotation @quotation @table @asis @item else set filtering to true open input standard-input open output standard-output @end table end-if @end quotation @emph{><]}><* @emph{><} Initialize the output buffer@comma{} and line count. @emph{><} @emph{><} :: @emph{><} *><[ set buffer-empty to true move 1 to buffer-offset move spaces to doc-record move 0 to line-count @emph{><]}><* @emph{><} The read is either from file or stdin. Start with the @emph{><+ first record.}><* @emph{><} :: @emph{><} @emph{><[}> filtering requires different reader loop if filtering read standard-input at end move high-values to stdin-record end-read move stdin-record to source-record else read source-input at end move high-values to source-record end-read end-if @emph{><]}><* @emph{><} The main loop starts here@comma{} having done a pre-read to start @emph{><+ things off.}><* @emph{><} :: @emph{><} *><[ perform until source-record = high-values add 1 to line-count @emph{><]}><* @emph{><} Small wrinkle if processing fixed form with sequence numbers@comma{} @emph{><+ as the heredoc end marker needs to be recognized}><+ but we still want the sequence numbers in the heredoc. @emph{><} @emph{><} So files processed --fixed play some data shuffling games. @emph{><} @emph{><} :: @emph{><} *><[ if skipseqnum if heredoc move source-record(7 : 248) to trimmed move source-record to seq-data move seq-record to source-record else move source-record(7 : 248) to source-record move source-record to trimmed end-if else move function trim(source-record leading) to trimmed end-if @emph{><]}><* @emph{><} First to check for here doc start and end@comma{} setting flag @emph{><+ if trimmed conditional the heredoc start or heredoc end}><+ strings. @emph{><} @emph{><} :: @emph{><} *><[ if herestart set heredoc to true end-if @quotation @table @asis @item if hereend set herenone to true @end table end-if @end quotation @emph{><]}><* @emph{><} Inside the loop@comma{} we skip over heredoc entries. @emph{><+ If it is normal@comma{} than check for heredoc and include}><+ source lines that follow@comma{} by prepending the extract tag @emph{><} @emph{><} :: @emph{><} *><[ if (not herestart) and (not hereend) if heredoc move source-record to here-data move here-record to trimmed end-if @emph{><]}><* @emph{><} Unstring the line@comma{} looking for special tags in the first @emph{><+ part.}><* @emph{><} :: @emph{><} *><[ unstring trimmed delimited by all spaces into first-part count in counter end-unstring @emph{><]}><* @emph{><} If special@comma{} we either buffer or append to buffer @emph{><} @emph{><} :: @emph{><} *><[ evaluate true when special if autoappend and buffer-empty move spaces to doc-record move 1 to buffer-offset end-if @quotation @table @asis @item if autodoc and buffered-output @table @asis @item if filtering move doc-record to stdout-record write stdout-record end-write @item else write doc-record end-write @end table end-if if verbose display function trim(doc-record trailing) end-display end-if move spaces to doc-record set buffer-empty to true move 1 to buffer-offset @end table end-if @end quotation @emph{><]}><* @emph{><} Skip over where the tag was found plus an extra space. @emph{><} Adding 2 skips over the assumed space after a special tag @emph{><} @emph{><} :: @emph{><} *><[ add 2 to counter compute len-of-comment = function length(trimmed) - counter end-compute @quotation @table @asis @item if len-of-comment > 0 @table @asis @item move trimmed(counter : len-of-comment) to doc-buffer @end table @item else move spaces to doc-buffer @end table end-if @end quotation @emph{><]}><* @emph{><} Buffer the line@comma{} either to position 1 or appending to last. @emph{><} @emph{><} :: @emph{><} @emph{><[ string function trim(doc-buffer trailing) delimited by size into doc-record with pointer buffer-offset on overflow move line-count to line-display display "}@emph{* truncation}** reading line " line-display end-display end-string set buffered-output to true end-evaluate end-if @emph{><]}><* @emph{><} Again@comma{} we either read the next record from file or stdin. @emph{><} @emph{><} :: @emph{><} *><[ if filtering read standard-input at end move high-values to stdin-record end-read move stdin-record to source-record else read source-input at end move high-values to source-record end-read end-if end-perform @emph{><]}><* @emph{><} We may or may not end up with buffered data @emph{><} @emph{><} :: @emph{><} *><[ if buffered-output set buffer-empty to true move 1 to buffer-offset if filtering move doc-record to stdout-record write stdout-record end-write else write doc-record end-write end-if if verbose display function trim(doc-record trailing) end-display end-if move spaces to doc-record end-if @emph{><]}><* @emph{><} Close the OpenCOBOL files @emph{><} @emph{><} :: @emph{><} *><[ if filtering close standard-output close standard-input else close doc-output close source-input end-if @quotation @table @asis @item if verbose display "Input : " function trim(source-name) end-display display "Output : " function trim(doc-name) end-display @end table end-if @end quotation @emph{><]}><* @emph{><} If we have a result file@comma{} use the SYSTEM service to @emph{><+ generate an HTML file@comma{} possibly with stylesheet.}><* @emph{><} :: @emph{><} @emph{><[}> pass the extract through a markover@comma{} in this case ReST move spaces to rst-command if result-name not equal spaces if style-name equal spaces string "rst2html " delimited by size doc-name delimited by space " " delimited by size result-name delimited by space into rst-command end-string else string "rst2html --stylesheet=" delimited by size style-name delimited by space " " delimited by size doc-name delimited by space " " delimited by size result-name delimited by space into rst-command end-string end-if @quotation @table @asis @item if verbose @table @asis @item display "Command: " function trim(rst-command trailing) @end table end-display @end table end-if @table @asis @item call "SYSTEM" using rst-command returning result @end table end-call @table @asis @item if result not equal zero display "HTML generate failed: " result end-display @end table end-if @end quotation @quotation end-if @end quotation @emph{><]}><* @emph{><} And before you know it@comma{} we are done. @emph{><} @emph{><} :: @emph{><} *><[ goback. @quotation end program OCDOC. @end quotation @emph{><]}><* @emph{><} Don't forget to visit @uref{http://opencobol.org,http://opencobol.org} @emph{><} @emph{><} Cheers @emph{><} @emph{><} @emph{Last edit:} 03-Oct-2008 @end table @end quotation See @uref{http://opencobol.add1tocobol.com/ocdoc.html,ocdoc.html} for the output from processing @emph{ocdoc.cob} with @strong{ocdoc}. @node Does OpenCOBOL support any SQL databases? @subsection Does OpenCOBOL support any SQL databases? Yes and no. There is no embedded SQL in OpenCOBOL in terms of EXEC but there are at least two usable CALL extensions. There are |currently| quite a few active developments for external SQL engine access. There are early prototypes for SQLite at @uref{http://opencobol.add1tocobol.com/ocshell.c,ocshell.c} with a sample usage program at @uref{http://opencobol.add1tocobol.com/sqlscreen.cob,sqlscreen.cob} and supporting documentation at @uref{http://opencobol.add1tocobol.com/sqlscreen.html,sqlscreen.html} The SQLite extension comes in two flavours; a shell mode discussed above and a direct API interface housed at @uref{http://add1tocobol.com/tiki-list_file_gallery.php?galleryId=12,ocsqlite.c} A libdbi (generic database access) extension is also available. See @uref{http://add1tocobol.com/tiki-read_article.php?articleId=1,cobdbi} for full details. Rumours of a potential Postgres layer have also been heard. @node What are the OpenCOBOL RESERVED WORDS? @subsection What are the OpenCOBOL RESERVED WORDS? COBOL_ is a reserved word rich language. The OpenCOBOL compiler recognizes: @table @asis @item .. Note to maintainers. Built with $ cobc --list-reserved@comma{} followed by a 74 column wide reformat and 4 space indent. The counts were calculated from $ wc and grepping for the literal "-1" in the cobc/reserved.c source. @end table _`Reserved Words` ======================= ======================= ======================= * ACCEPT_ * ENTRY * POINTER * ACCESS_ x. ENTRY-CONVENTION * POSITION x. ACTIVE-CLASS_ * ENVIRONMENT * POSITIVE * ADD_ * ENVIRONMENT-NAME x. PRESENT * ADDRESS_ * ENVIRONMENT-VALUE * PREVIOUS * ADVANCING_ x. EO * PRINTER * AFTER_ * EOL x. PRINTING x. ALIGNED * EOP * PROCEDURE * ALL_ * EOS * PROCEDURE-POINTER * ALLOCATE_ * EQUAL * PROCEDURES * ALPHABET_ * EQUALS * PROCEED * ALPHABETIC_ * ERASE * PROGRAM * ALPHABETIC-LOWER_ * ERROR * PROGRAM-ID * ALPHABETIC-UPPER_ * ESCAPE * PROGRAM-POINTER * ALPHANUMERIC_ x. ESI * PROMPT * ALPHANUMERIC-EDITED_ * EVALUATE x. PROPERTY * ALSO_ * EXCEPTION x. PROTOTYPE * ALTER_ x. EXCEPTION-OBJECT x. PURGE * ALTERNATE_ * EXCLUSIVE x. QUEUE * AND_ * EXIT * QUOTE * ANY_ x. EXPANDS * QUOTES x. ANYCASE * EXTEND x. RAISE * ARE_ * EXTERNAL x. RAISING * AREA_ x. FACTORY * RANDOM x. AREAS * FALSE x. RD * ARGUMENT-NUMBER * FD * READ * ARGUMENT-VALUE_ * FILE x. RECEIVE x. ARITHMETIC * FILE-CONTROL * RECORD * AS * FILE-ID * RECORDING * ASCENDING * FILLER * RECORDS * ASSIGN x. FINAL * RECURSIVE * AT * FIRST * REDEFINES x. ATTRIBUTE x. FLOAT-EXTENDED * REEL * AUTO * FLOAT-LONG * REFERENCE * AUTO-SKIP * FLOAT-SHORT x. RELATION * AUTOMATIC * FOOTING * RELATIVE * AUTOTERMINATE * FOR * RELEASE x. B-AND * FOREGROUND-COLOR * REMAINDER x. B-NOT x. FOREVER * REMOVAL x. B-OR x. FORMAT * RENAMES x. B-XOR * FREE x. REPLACE * BACKGROUND-COLOR_ * FROM * REPLACING * BASED_ * FULL x. REPORT * BEEP_ * FUNCTION_ x. REPORTING * BEFORE x. FUNCTION-ID x. REPORTS * BELL_ x. GENERATE x. REPOSITORY * BINARY x. GET * REQUIRED * BINARY-C-LONG * GIVING_ * RESERVE * BINARY-CHAR * GLOBAL x. RESET * BINARY-DOUBLE * GO x. RESUME * BINARY-LONG * GOBACK_ x. RETRY * BINARY-SHORT * GREATER * RETURN x. BIT x. GROUP * RETURNING * BLANK_ x. GROUP-USAGE * REVERSE-VIDEO * BLINK x. HEADING * REWIND * BLOCK * HIGH-VALUE * REWRITE x. BOOLEAN * HIGH-VALUES x. RF * BOTTOM * HIGHLIGHT x. RH * BY * I-O * RIGHT x. BYTE-LENGTH * I-O-CONTROL * ROLLBACK * CALL_ * ID * ROUNDED * CANCEL * IDENTIFICATION * RUN x. CD * IF * SAME x. CENTER * IGNORING * SCREEN x. CF x. IMPLEMENTS * SD x. CH * IN * SEARCH x. CHAIN * INDEX x. SECONDS * CHAINING * INDEXED * SECTION * CHARACTER x. INDICATE * SECURE * CHARACTERS x. INHERITS x. SEGMENT * CLASS * INITIAL * SELECT x. CLASS-ID * INITIALIZE x. SELF x. CLASSIFICATION * INITIALIZED x. SEND * CLOSE x. INITIATE * SENTENCE x. CODE * INPUT * SEPARATE * CODE-SET * INPUT-OUTPUT * SEQUENCE * COL * INSPECT * SEQUENTIAL * COLLATING x. INTERFACE * SET * COLS x. INTERFACE-ID * SHARING * COLUMN * INTO * SIGN * COLUMNS x. INTRINSIC * SIGNED * COMMA * INVALID * SIGNED-INT * COMMAND-LINE x. INVOKE * SIGNED-LONG * COMMIT * IS * SIGNED-SHORT * COMMON * JUST * SIZE x. COMMUNICATION * JUSTIFIED * SORT_ * COMP * KEY * SORT-MERGE_ * COMP-1 * LABEL * SOURCE * COMP-2 x. LAST * SOURCE-COMPUTER * COMP-3 x. LC_ALL x. SOURCES * COMP-4 x. LC_COLLATE * SPACE * COMP-5 x. LC_CTYPE * SPACES * COMP-X x. LC_MESSAGES * SPECIAL-NAMES_ * COMPUTATIONAL x. LC_MONETARY * STANDARD * COMPUTATIONAL-1 x. LC_NUMERIC * STANDARD-1 * COMPUTATIONAL-2 x. LC_TIME * STANDARD-2 * COMPUTATIONAL-3 * LEADING * START * COMPUTATIONAL-4 * LEFT x. STATEMENT * COMPUTATIONAL-5 * LENGTH * STATUS * COMPUTATIONAL-X * LESS x. STEP * COMPUTE x. LIMIT * STOP x. CONDITION x. LIMITS * STRING * CONFIGURATION * LINAGE_ x. STRONG * CONSTANT * LINAGE-COUNTER_ x. SUB-QUEUE-1 * CONTAINS * LINE x. SUB-QUEUE-2 * CONTENT x. LINE-COUNTER x. SUB-QUEUE-3 * CONTINUE * LINES * SUBTRACT x. CONTROL * LINKAGE x. SUM x. CONTROLS * LOCAL-STORAGE x. SUPER * CONVERTING * LOCALE x. SUPPRESS * COPY * LOCK x. SYMBOL * CORR * LOW-VALUE_ * SYMBOLIC * CORRESPONDING * LOW-VALUES_ * SYNC * COUNT * LOWLIGHT_ * SYNCHRONIZED * CRT * MANUAL x. SYSTEM-DEFAULT * CURRENCY * MEMORY x. TABLE * CURSOR * MERGE * TALLYING * CYCLE x. MESSAGE * TAPE * DATA x. METHOD x. TERMINAL x. DATA-POINTER x. METHOD-ID x. TERMINATE * DATE * MINUS * TEST * DAY * MODE x. TEXT * DAY-OF-WEEK * MOVE_ * THAN x. DE * MULTIPLE * THEN * DEBUGGING * MULTIPLY * THROUGH * DECIMAL-POINT * NATIONAL * THRU * DECLARATIVES * NATIONAL-EDITED * TIME * DEFAULT * NATIVE * TIMES * DELETE * NEGATIVE * TO * DELIMITED x. NESTED * TOP * DELIMITER * NEXT * TRAILING * DEPENDING * NO * TRUE * DESCENDING x. NONE x. TYPE x. DESTINATION x. NORMAL x. TYPEDEF x. DETAIL * NOT x. UCS-4 x. DISABLE * NULL * UNDERLINE * DISK * NULLS * UNIT * DISPLAY * NUMBER x. UNIVERSAL * DIVIDE * NUMBERS * UNLOCK * DIVISION * NUMERIC * UNSIGNED * DOWN * NUMERIC-EDITED * UNSIGNED-INT * DUPLICATES x. OBJECT * UNSIGNED-LONG * DYNAMIC * OBJECT-COMPUTER * UNSIGNED-SHORT * EBCDIC_ x. OBJECT-REFERENCE * UNSTRING x. EC * OCCURS * UNTIL x. EGI * OF * UP * ELSE * OFF * UPDATE x. EMI * OMITTED * UPON x. ENABLE * ON * USAGE_ * END * ONLY * USE * END-ACCEPT * OPEN x. USER-DEFAULT * END-ADD * OPTIONAL * USING * END-CALL x. OPTIONS x. UTF-16 * END-COMPUTE * OR x. UTF-8 * END-DELETE * ORDER x. VAL-STATUS * END-DISPLAY * ORGANIZATION x. VALID * END-DIVIDE * OTHER x. VALIDATE * END-EVALUATE * OUTPUT x. VALIDATE-STATUS * END-IF * OVERFLOW * VALUE * END-MULTIPLY * OVERLINE * VALUES * END-OF-PAGE x. OVERRIDE * VARYING * END-PERFORM * PACKED-DECIMAL * WHEN * END-READ * PADDING * WITH x. END-RECEIVE * PAGE * WORKING-STORAGE * END-RETURN x. PAGE-COUNTER * WRITE * END-REWRITE * PARAGRAPH * YYYYDDD * END-SEARCH * PERFORM * YYYYMMDD * END-START x. PF * ZERO * END-STRING x. PH * ZEROES * END-SUBTRACT * PIC * ZEROS * END-UNSTRING * PICTURE_ * SORT-RETURN_ * END-WRITE * PLUS ======================= ======================= ======================= 514 words in OC 1.1@comma{} 136 of which are marked not yet implemented. 378 functional reserved words@comma{} as of August 2008. @menu * ACCEPT:: * ACCESS:: * ACTIVE-CLASS:: * ADD:: * ADDRESS:: * ADVANCING:: * AFTER:: * ALIGNED:: * ALL:: * ALLOCATE:: * ALPHABET:: * ALPHABETIC:: * ALPHABETIC-LOWER:: * ALPHABETIC-UPPER:: * ALPHANUMERIC:: * ALPHANUMERIC-EDITED:: * ALSO:: * ALTER:: * ALTERNATE:: * AND:: * ANY:: * ANYCASE:: * ARE:: * AREA:: * AREAS:: * ARGUMENT-NUMBER:: * ARGUMENT-VALUE:: * ARITHMETIC:: * ASx:: * ASCENDING:: * ASSIGN:: * ATx:: * ATTRIBUTE:: * AUTO:: * AUTO-SKIP:: * AUTOMATIC:: * AUTOTERMINATE:: * B-AND:: * B-NOT:: * B-OR:: * B-XOR:: * BACKGROUND-COLOR:: * BASED:: * BEEP:: * BEFORE:: * BELL:: * BINARY:: * BINARY-C-LONG:: * BINARY-CHAR:: * BINARY-DOUBLE:: * BINARY-LONG:: * BINARY-SHORT:: * BIT:: * BLANK:: * BLINK:: * BLOCK:: * BOOLEAN:: * BOTTOM:: * BYx:: * BYTE-LENGTH:: * CALL:: * CANCEL:: * CDx:: * CENTER:: * CFx:: * CHx:: * CHAIN:: * CHAINING:: * CHARACTER:: * CHARACTERS:: * CLASS:: * CLASS-ID:: * CLASSIFICATION:: * CLOSE:: * CODE:: * CODE-SET:: * COL:: * COLLATING:: * COLS:: * COLUMN:: * COLUMNS:: * COMMA:: * COMMAND-LINE:: * COMMIT:: * COMMON:: * COMMUNICATION:: * COMP:: * COMP-1:: * COMP-2:: * COMP-3:: * COMP-4:: * COMP-5:: * COMP-X:: * COMPUTATIONAL:: * COMPUTATIONAL-1:: * COMPUTATIONAL-2:: * COMPUTATIONAL-3:: * COMPUTATIONAL-4:: * COMPUTATIONAL-5:: * COMPUTATIONAL-X:: * COMPUTE:: * CONDITION:: * CONFIGURATION:: * CONSTANT:: * CONTAINS:: * CONTENT:: * CONTINUE:: * CONTROL:: * CONTROLS:: * CONVERTING:: * COPY:: * CORR:: * CORRESPONDING:: * COUNT:: * CRT:: * CURRENCY:: * CURSOR:: * CYCLE:: * DATA:: * DATA-POINTER:: * DATE:: * DAY:: * DAY-OF-WEEK:: * DEx:: * DEBUGGING:: * DECIMAL-POINT:: * DECLARATIVES:: * DEFAULT:: * DELETE:: * DELIMITED:: * DELIMITER:: * DEPENDING:: * DESCENDING:: * DESTINATION:: * DETAIL:: * DISABLE:: * DISK:: * DISPLAY:: * DIVIDE:: * DIVISION:: * DOWN:: * DUPLICATES:: * DYNAMIC:: * EBCDIC:: * ECx:: * EGI:: * ELSE:: * EMI:: * ENABLE:: * END:: * END-ACCEPT:: * END-ADD:: * END-CALL:: * END-COMPUTE:: * END-DELETE:: * END-DISPLAY:: * END-DIVIDE:: * END-EVALUATE:: * END-IF:: * END-MULTIPLY:: * END-OF-PAGE:: * END-PERFORM:: * END-READ:: * END-RECEIVE:: * END-RETURN:: * END-REWRITE:: * END-SEARCH:: * END-START:: * END-STRING:: * END-SUBTRACT:: * END-UNSTRING:: * END-WRITE:: * ENTRY:: * ENTRY-CONVENTION:: * ENVIRONMENT:: * ENVIRONMENT-NAME:: * ENVIRONMENT-VALUE:: * EOx:: * EOL:: * EOP:: * EOS:: * EQUAL:: * EQUALS:: * ERASE:: * ERROR:: * ESCAPE:: * ESI:: * EVALUATE:: * EXCEPTION:: * EXCEPTION-OBJECT:: * EXCLUSIVE:: * EXIT:: * EXPANDS:: * EXTEND:: * EXTERNAL:: * FACTORY:: * FALSE:: * FDx:: * FILE:: * FILE-CONTROL:: * FILE-ID:: * FILLER:: * FINAL:: * FIRST:: * FLOAT-EXTENDED:: * FLOAT-LONG:: * FLOAT-SHORT:: * FOOTING:: * FOR:: * FOREGROUND-COLOR:: * FOREVER:: * FORMAT:: * FREE:: * FROM:: * FULL:: * FUNCTION:: * FUNCTION-ID:: * GENERATE:: * GET:: * GIVING:: * GLOBAL:: * GOx:: * GOBACK:: * GREATER:: * GROUP:: * GROUP-USAGE:: * HEADING:: * HIGH-VALUE:: * HIGH-VALUES:: * HIGHLIGHT:: * I-O:: * I-O-CONTROL:: * IDx:: * IDENTIFICATION:: * IFx:: * IGNORING:: * IMPLEMENTS:: * INx:: * INDEX:: * INDEXED:: * INDICATE:: * INHERITS:: * INITIAL:: * INITIALIZE:: * INITIALIZED:: * INITIATE:: * INPUT:: * INPUT-OUTPUT:: * INSPECT:: * INTERFACE:: * INTERFACE-ID:: * INTO:: * INTRINSIC:: * INVALID:: * INVOKE:: * ISx:: * JUST:: * JUSTIFIED:: * KEY:: * KEYBOARD:: * LABEL:: * LAST:: * LC_ALL:: * LC_COLLATE:: * LC_CTYPE:: * LC_MESSAGES:: * LC_MONETARY:: * LC_NUMERIC:: * LC_TIME:: * LEADING:: * LEFT:: * LENGTH:: * LESS:: * LIMIT:: * LIMITS:: * LINAGE:: * LINAGE-COUNTER:: * LINE:: * LINE-COUNTER:: * LINES:: * LINKAGE:: * LOCAL-STORAGE:: * LOCALE:: * LOCK:: * LOW-VALUE:: * LOW-VALUES:: * LOWLIGHT:: * MANUAL:: * MEMORY:: * MERGE:: * MESSAGE:: * METHOD:: * METHOD-ID:: * MINUS:: * MODE:: * MOVE:: * MULTIPLE:: * MULTIPLY:: * NATIONAL:: * NATIONAL-EDITED:: * NATIVE:: * NEGATIVE:: * NESTED:: * NEXT:: * NOx:: * NONE:: * NORMAL:: * NOT:: * NULL:: * NULLS:: * NUMBER:: * NUMBERS:: * NUMERIC:: * NUMERIC-EDITED:: * OBJECT:: * OBJECT-COMPUTER:: * OBJECT-REFERENCE:: * OCCURS:: * OFx:: * OFF:: * OMITTED:: * ONx:: * ONLY:: * OPEN:: * OPTIONAL:: * OPTIONS:: * ORx:: * ORDER:: * ORGANIZATION:: * OTHER:: * OUTPUT:: * OVERFLOW:: * OVERLINE:: * OVERRIDE:: * PACKED-DECIMAL:: * PADDING:: * PAGE:: * PAGE-COUNTER:: * PARAGRAPH:: * PERFORM:: * PFx:: * PHx:: * PIC:: * PICTURE:: * PLUS:: * POINTER:: * POSITION:: * POSITIVE:: * PRESENT:: * PREVIOUS:: * PRINTER:: * PRINTING:: * PROCEDURE:: * PROCEDURE-POINTER:: * PROCEDURES:: * PROCEED:: * PROGRAM:: * PROGRAM-ID:: * PROGRAM-POINTER:: * PROMPT:: * PROPERTY:: * PROTOTYPE:: * PURGE:: * QUEUE:: * QUOTE:: * QUOTES:: * RAISE:: * RAISING:: * RANDOM:: * RDx:: * READ:: * RECEIVE:: * RECORD:: * RECORDING:: * RECORDS:: * RECURSIVE:: * REDEFINES:: * REEL:: * REFERENCE:: * RELATION:: * RELATIVE:: * RELEASE:: * REMAINDER:: * REMOVAL:: * RENAMES:: * REPLACE:: * REPLACING:: * REPORT:: * REPORTING:: * REPORTS:: * REPOSITORY:: * REQUIRED:: * RESERVE:: * RESET:: * RESUME:: * RETRY:: * RETURN:: * RETURNING:: * REVERSE-VIDEO:: * REWIND:: * REWRITE:: * RFx:: * RHx:: * RIGHT:: * ROLLBACK:: * ROUNDED:: * RUN:: * SAME:: * SCREEN:: * SDx:: * SEARCH:: * SECONDS:: * SECTION:: * SECURE:: * SEGMENT:: * SELECT:: * SELF:: * SEND:: * SENTENCE:: * SEPARATE:: * SEQUENCE:: * SEQUENTIAL:: * SET:: * SHARING:: * SIGN:: * SIGNED:: * SIGNED-INT:: * SIGNED-LONG:: * SIGNED-SHORT:: * SIZE:: * SORT:: * SORT-MERGE:: * SORT-RETURN:: * SOURCE:: * SOURCE-COMPUTER:: * SOURCES:: * SPACE:: * SPACES:: * SPECIAL-NAMES:: * STANDARD:: * STANDARD-1:: * STANDARD-2:: * START:: * STATEMENT:: * STATUS:: * STEP:: * STOP:: * STRING:: * STRONG:: * SUB-QUEUE-1:: * SUB-QUEUE-2:: * SUB-QUEUE-3:: * SUBTRACT:: * SUM:: * SUPER:: * SUPPRESS:: * SYMBOL:: * SYMBOLIC:: * SYNC:: * SYNCHRONIZED:: * SYSTEM-DEFAULT:: * TABLE:: * TALLYING:: * TAPE:: * TERMINAL:: * TERMINATE:: * TEST:: * TEXT:: * THAN:: * THEN:: * THROUGH:: * THRU:: * TIME:: * TIMES:: * TOx:: * TOPx:: * TRAILING:: * TRUE:: * TYPE:: * TYPEDEF:: * UCS-4:: * UNDERLINE:: * UNIT:: * UNIVERSAL:: * UNLOCK:: * UNSIGNED:: * UNSIGNED-INT:: * UNSIGNED-LONG:: * UNSIGNED-SHORT:: * UNSTRING:: * UNTIL:: * UPx:: * UPDATE:: * UPON:: * USAGE:: * USE:: * USER-DEFAULT:: * USING:: * UTF-16:: * UTF-8:: * VAL-STATUS:: * VALID:: * VALIDATE:: * VALIDATE-STATUS:: * VALUE:: * VALUES:: * VARYING:: * WHEN:: * WITH:: * WORKING-STORAGE:: * WRITE:: * YYYYDDD:: * YYYYMMDD:: * ZERO:: * ZEROES:: * ZEROS:: @end menu @node ACCEPT @subsubsection ACCEPT @quotation ACCEPT variable FROM CONSOLE. ACCEPT variable FROM ENVIRONMENT "path". ACCEPT variable FROM COMMAND LINE. ACCEPT screen-variable. @end quotation @node ACCESS @subsubsection ACCESS @quotation @table @asis @item SELECT filename ASSIGN TO "filename.dat" ACCESS MODE IS RANDOM RELATIVE KEY IS keyfield. @end table @end quotation @node ACTIVE-CLASS @subsubsection ACTIVE-CLASS Not yet implemented. Object COBOL feature. @node ADD @subsubsection ADD @quotation ADD 1 TO cobol GIVING OpenCOBOL END-ADD. @end quotation @node ADDRESS @subsubsection ADDRESS @quotation SET pointer-variable TO ADDRESS OF linkage-store. @end quotation @node ADVANCING @subsubsection ADVANCING @quotation DISPLAY "Legend: " WITH NO ADVANCING END-DISPLAY. WRITE printrecord AFTER ADVANCING PAGE END-WRITE. @end quotation @node AFTER @subsubsection AFTER @quotation @table @asis @item PERFORM WITH TEST AFTER VARYING variable FROM 1 BY 1 UNTIL variable > 10 DISPLAY variable END-DISPLAY @end table END-PERFORM. @end quotation @node ALIGNED @subsubsection ALIGNED @node ALL @subsubsection ALL @quotation INSPECT variable REPLACING ALL "123" WITH "456". @end quotation @node ALLOCATE @subsubsection ALLOCATE @quotation ALLOCATE based-var INITIALIZED RETURNING pointer-var. @end quotation @node ALPHABET @subsubsection ALPHABET @quotation @table @asis @item * Set up for a mixed case SORT COLLATING SEQUENCE IS CONFIGURATION SECTION. SPECIAL-NAMES. ALPHABET name IS "AaBbCcDdEe..". @end table @end quotation @node ALPHABETIC @subsubsection ALPHABETIC @quotation @table @asis @item IF variable IS ALPHABETIC DISPLAY "alphabetic" END-DISPLAY @end table END-IF @end quotation @node ALPHABETIC-LOWER @subsubsection ALPHABETIC-LOWER @quotation @table @asis @item IF variable IS ALPHABETIC-LOWER DISPLAY "alphabetic-lower" END-DISPLAY @end table END-IF @end quotation @node ALPHABETIC-UPPER @subsubsection ALPHABETIC-UPPER @quotation DISPLAY variable "alphabetic-upper " WITH NO ADVANCING IF variable IS ALPHABETIC-UPPER DISPLAY "true" END-DISPLAY ELSE DISPLAY "false" END-DISPLAY END-IF @end quotation @node ALPHANUMERIC @subsubsection ALPHANUMERIC @quotation INITIALIZE data-record REPLACING ALPHANUMERIC BY literal-value @end quotation @node ALPHANUMERIC-EDITED @subsubsection ALPHANUMERIC-EDITED @quotation @table @asis @item INITIALIZE data-record REPLACING ALPHANUMERIC-EDITED BY identifier-1 @end table @end quotation @node ALSO @subsubsection ALSO @quotation @table @asis @item EVALUATE variable ALSO second-test WHEN "A" ALSO 1 THRU 5 PERFORM first-case WHEN "A" ALSO 6 PERFORM second-case WHEN "A" ALSO 7 THRU 9 PERFORM third-case WHEN OTHER PERFORM invalid-case @end table END-EVALUATE @end quotation @node ALTER @subsubsection ALTER Yeah@comma{} just don't. @node ALTERNATE @subsubsection ALTERNATE @quotation @table @asis @item SELECT file ASSIGN TO filename ACCESS MODE IS RANDOM RECORD KEY IS key-field ALTERNATE KEY IS alt-key WITH DUPLICATES. @end table @end quotation @node AND @subsubsection AND COBOL rules of precedence are; NOT@comma{} AND@comma{} OR. @quotation @table @asis @item IF field = "A" AND num = 3 DISPLAY "got 3" END-DISPLAY @end table END-IF @end quotation COBOL also allows abbreviated combined relational conditions. @quotation @table @asis @item IF NOT (a NOT > b AND c AND NOT d) code @end table END-IF @end quotation is equivalent to @quotation @table @asis @item IF NOT (((a NOT > b) AND (a NOT > c)) AND (NOT (a NOT > d))) code @end table END-IF @end quotation @node ANY @subsubsection ANY @quotation @table @asis @item EVALUATE TRUE ALSO TRUE @table @asis @item WHEN a > 3 ALSO ANY @emph{> b can be any value}* PERFORM a-4-b-any @item WHEN a = 3 ALSO b = 1 PERFORM a-3-b-1 @end table @end table END-EVALUATE @end quotation @node ANYCASE @subsubsection ANYCASE @node ARE @subsubsection ARE @quotation @table @asis @item 01 cond-1 PIC X. 88 first-truth VALUES ARE "A" "B" "C". 88 second-truth VALUES ARE "X" "Y" "Z". @end table @end quotation @node AREA @subsubsection AREA @quotation @table @asis @item I-O-CONTROL. SAME RECORD AREA FOR file1@comma{} file2. @end table @end quotation @node AREAS @subsubsection AREAS @node ARGUMENT-NUMBER @subsubsection ARGUMENT-NUMBER @node ARGUMENT-VALUE @subsubsection ARGUMENT-VALUE Returns the next command line argument. This post from John on opencobol.org_ is an excellent idiom for parsing command line arguments without too much worry as to the order. @quotation >>source format is free @end quotation @quotation @emph{>}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@emph{*}> Author: jrls (John Ellis) @emph{> Date: Nov-2008}> Purpose: command line processing @emph{>}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}@emph{* identification division. program-id. cmdline. data division.}> working-storage section. @emph{>}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@emph{*}}}}}}}}}}@emph{* 01 argv pic x(100) value spaces. 88 recv value "-r"@comma{} "--recv". 88 email value "-e"@comma{} "--email". 88 delivered value "-d"@comma{} "--delivered". 01 cmdstatus pic x value spaces. 88 lastcmd value "l". 01 reptinfo. 05 rept-recv pic x(30) value spaces. 05 rept-howsent pic x(10) value spaces.}> procedure division. 0000-start. @emph{> perform until lastcmd move low-values to argv accept argv from argument-value if argv > low-values perform 0100-process-arguments else move "l" to cmdstatus end-if end-perform display reptinfo. stop run.}> 0100-process-arguments. @emph{> evaluate true when recv if rept-recv = spaces accept rept-recv from argument-value else display "duplicate " argv end-if when email move "email" to rept-howsent when delivered move "delivered" to rept-howsent when other display "invalid switch: " argv end-evaluate.}><* @end quotation Example run: @verbatim ./cmdline --recv "john ellis" -e -f invalid switch: -f john ellis email @end verbatim @node ARITHMETIC @subsubsection ARITHMETIC @node ASx @subsubsection ASx @node ASCENDING @subsubsection ASCENDING @node ASSIGN @subsubsection ASSIGN @node ATx @subsubsection ATx @node ATTRIBUTE @subsubsection ATTRIBUTE @node AUTO @subsubsection AUTO @node AUTO-SKIP @subsubsection AUTO-SKIP @node AUTOMATIC @subsubsection AUTOMATIC @node AUTOTERMINATE @subsubsection AUTOTERMINATE @node B-AND @subsubsection B-AND @node B-NOT @subsubsection B-NOT @node B-OR @subsubsection B-OR @node B-XOR @subsubsection B-XOR @node BACKGROUND-COLOR @subsubsection BACKGROUND-COLOR @quotation 05 BLANK SCREEN BACKGROUND-COLOR 7 FOREGROUND-COLOR 0. @end quotation @node BASED @subsubsection BASED @quotation 01 based-var PIC X(80) BASED. @end quotation A sample posted by [human]_ @quotation @table @asis @item @emph{----------------------------------------------------------------- IDENTIFICATION DIVISION. PROGRAM-ID. 'MEMALL'. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. DECIMAL-POINT IS COMMA. INPUT-OUTPUT SECTION. FILE-CONTROL. DATA DIVISION. FILE SECTION.} WORKING-STORAGE SECTION. @item * 77 mychar pic x. 01 REC-TEST BASED. 03 REC-TEST-PART1 PIC X(5500000). 03 REC-TEST-PART2 PIC X(0100000). 03 REC-TEST-PART3 PIC X(1200000). 03 REC-TEST-PART4 PIC X(1200000). 03 REC-TEST-PART5 PIC X(1700000). @item @emph{----------------------------------------------------------------- LINKAGE SECTION.}----------------------------------------------------------------- PROCEDURE DIVISION. declaratives. end declaratives. @item @emph{----------------------------------------------------------------- main section. 00. FREE ADDRESS OF REC-TEST display 'MEMALL loaded and REC-TEST FREEd before ALLOCATE' accept mychar} @table @asis @item IF ADDRESS OF REC-TEST = NULL display 'REC-TEST was not allocated before' @item ELSE display 'REC-TEST was allocated before' @end table END-IF accept mychar @item * ALLOCATE REC-TEST move all '9' to REC-TEST display 'REC-TEST allocated and filled with ' REC-TEST (1:9) end-display accept mychar @item * @table @asis @item IF ADDRESS OF REC-TEST = NULL display 'REC-TEST was not allocated before' ALLOCATE REC-TEST display 'REC-TEST allocated again@comma{} filled with ' REC-TEST (1:9) end-display @item ELSE display 'REC-TEST was allocated before' @end table END-IF accept mychar @end table * @quotation FREE ADDRESS OF REC-TEST display 'REC-TEST FREEd' accept mychar @end quotation @table @asis @item * stop run @item * continue. @end table @quotation ex. exit program. @end quotation @emph{-----------------------------------------------------------------}--- End of program MEMALL --------------------------------------- @end quotation @node BEEP @subsubsection BEEP @quotation DISPLAY "Beeeeep" LINE 3 COLUMN 1 WITH BEEP END-DISPLAY. @end quotation @node BEFORE @subsubsection BEFORE @node BELL @subsubsection BELL @quotation DISPLAY "Beeeeep" LINE 3 COLUMN 1 WITH BELL END-DISPLAY. @end quotation @node BINARY @subsubsection BINARY @node BINARY-C-LONG @subsubsection BINARY-C-LONG @node BINARY-CHAR @subsubsection BINARY-CHAR @node BINARY-DOUBLE @subsubsection BINARY-DOUBLE @node BINARY-LONG @subsubsection BINARY-LONG @node BINARY-SHORT @subsubsection BINARY-SHORT @node BIT @subsubsection BIT @node BLANK @subsubsection BLANK @quotation 05 BLANK SCREEN BACKGROUND-COLOR 7 FOREGROUND-COLOR 0. @end quotation @node BLINK @subsubsection BLINK @node BLOCK @subsubsection BLOCK @node BOOLEAN @subsubsection BOOLEAN @node BOTTOM @subsubsection BOTTOM @node BYx @subsubsection BYx @node BYTE-LENGTH @subsubsection BYTE-LENGTH @node CALL @subsubsection CALL The OpenCOBOL CALL verb accepts literal or identifier stored names when resolving the transfer address. The USING phrase allows argument passing and OpenCOBOL includes internal rules for the data representation of the call stack entities that depend on the COBOL PICTURE_ and USAGE_ clauses. Return values are captured with RETURNING identifier. See `What STOCK CALL LIBRARY does OpenCOBOL offer?`_. For more information see @uref{http://www.opencobol.org/modules/bwiki/index.php?cmd=read&page=UserManual%2F2_3#content_1_0,http://www.opencobol.org/modules/bwiki/index.php?cmd=read&page=UserManual%2F2_3#content_1_0} @node CANCEL @subsubsection CANCEL @node CDx @subsubsection CDx @node CENTER @subsubsection CENTER @node CFx @subsubsection CFx @node CHx @subsubsection CHx @node CHAIN @subsubsection CHAIN @node CHAINING @subsubsection CHAINING Passes procedure division data through WORKING-STORAGE and can be used for shell command line arguments as well as in CALL "myprog" USING string. from opencobol.org_ by human_ @quotation @table @asis @item WORKING-STORAGE SECTION. @table @asis @item 01 cmd-argument. 02 some-text pic x(256). @end table @end table procedure division Chaining cmd-argument. @table @asis @item display 'You wrote:' '>"' function trim(some-text) '"' 'from shell command line' @end table end-display @end quotation @node CHARACTER @subsubsection CHARACTER @node CHARACTERS @subsubsection CHARACTERS @node CLASS @subsubsection CLASS @node CLASS-ID @subsubsection CLASS-ID @node CLASSIFICATION @subsubsection CLASSIFICATION @node CLOSE @subsubsection CLOSE @node CODE @subsubsection CODE @node CODE-SET @subsubsection CODE-SET @node COL @subsubsection COL @node COLLATING @subsubsection COLLATING @node COLS @subsubsection COLS @node COLUMN @subsubsection COLUMN @node COLUMNS @subsubsection COLUMNS @node COMMA @subsubsection COMMA @node COMMAND-LINE @subsubsection COMMAND-LINE @node COMMIT @subsubsection COMMIT @node COMMON @subsubsection COMMON @node COMMUNICATION @subsubsection COMMUNICATION @node COMP @subsubsection COMP @node COMP-1 @subsubsection COMP-1 @node COMP-2 @subsubsection COMP-2 @node COMP-3 @subsubsection COMP-3 @node COMP-4 @subsubsection COMP-4 @node COMP-5 @subsubsection COMP-5 @node COMP-X @subsubsection COMP-X @node COMPUTATIONAL @subsubsection COMPUTATIONAL @node COMPUTATIONAL-1 @subsubsection COMPUTATIONAL-1 @node COMPUTATIONAL-2 @subsubsection COMPUTATIONAL-2 @node COMPUTATIONAL-3 @subsubsection COMPUTATIONAL-3 @node COMPUTATIONAL-4 @subsubsection COMPUTATIONAL-4 @node COMPUTATIONAL-5 @subsubsection COMPUTATIONAL-5 @node COMPUTATIONAL-X @subsubsection COMPUTATIONAL-X @node COMPUTE @subsubsection COMPUTE @node CONDITION @subsubsection CONDITION @node CONFIGURATION @subsubsection CONFIGURATION @node CONSTANT @subsubsection CONSTANT @node CONTAINS @subsubsection CONTAINS @node CONTENT @subsubsection CONTENT @node CONTINUE @subsubsection CONTINUE @node CONTROL @subsubsection CONTROL @node CONTROLS @subsubsection CONTROLS @node CONVERTING @subsubsection CONVERTING @node COPY @subsubsection COPY @node CORR @subsubsection CORR @node CORRESPONDING @subsubsection CORRESPONDING @node COUNT @subsubsection COUNT @node CRT @subsubsection CRT @node CURRENCY @subsubsection CURRENCY @node CURSOR @subsubsection CURSOR @node CYCLE @subsubsection CYCLE @node DATA @subsubsection DATA @node DATA-POINTER @subsubsection DATA-POINTER @node DATE @subsubsection DATE @node DAY @subsubsection DAY @node DAY-OF-WEEK @subsubsection DAY-OF-WEEK @node DEx @subsubsection DEx @node DEBUGGING @subsubsection DEBUGGING @node DECIMAL-POINT @subsubsection DECIMAL-POINT @node DECLARATIVES @subsubsection DECLARATIVES @node DEFAULT @subsubsection DEFAULT @node DELETE @subsubsection DELETE @node DELIMITED @subsubsection DELIMITED @node DELIMITER @subsubsection DELIMITER @node DEPENDING @subsubsection DEPENDING @node DESCENDING @subsubsection DESCENDING @node DESTINATION @subsubsection DESTINATION @node DETAIL @subsubsection DETAIL @node DISABLE @subsubsection DISABLE @node DISK @subsubsection DISK @node DISPLAY @subsubsection DISPLAY @node DIVIDE @subsubsection DIVIDE @node DIVISION @subsubsection DIVISION @node DOWN @subsubsection DOWN @node DUPLICATES @subsubsection DUPLICATES @node DYNAMIC @subsubsection DYNAMIC @node EBCDIC @subsubsection EBCDIC Extended Binary Coded Decimal Interchange Code. A character encoding common to mainframe systems@comma{} therefore COBOL@comma{} therefore OpenCOBOL. Different than ASCII_ and OpenCOBOL supports both through efficient mappings. See @uref{http://en.wikipedia.org/wiki/EBCDIC,http://en.wikipedia.org/wiki/EBCDIC} for more info. ASCII to EBCDIC conversion the OpenCOBOL way: @verbatim SPECIAL-NAMES. ALPHABET ALPHA IS NATIVE. ALPHABET BETA IS EBCDIC. PROCEDURE DIVISION. INSPECT variable CONVERTING ALPHA TO BETA @end verbatim @node ECx @subsubsection ECx @node EGI @subsubsection EGI @node ELSE @subsubsection ELSE @node EMI @subsubsection EMI @node ENABLE @subsubsection ENABLE @node END @subsubsection END @node END-ACCEPT @subsubsection END-ACCEPT @node END-ADD @subsubsection END-ADD @node END-CALL @subsubsection END-CALL @node END-COMPUTE @subsubsection END-COMPUTE @node END-DELETE @subsubsection END-DELETE @node END-DISPLAY @subsubsection END-DISPLAY @node END-DIVIDE @subsubsection END-DIVIDE @node END-EVALUATE @subsubsection END-EVALUATE @node END-IF @subsubsection END-IF @node END-MULTIPLY @subsubsection END-MULTIPLY @node END-OF-PAGE @subsubsection END-OF-PAGE @node END-PERFORM @subsubsection END-PERFORM @node END-READ @subsubsection END-READ @node END-RECEIVE @subsubsection END-RECEIVE @node END-RETURN @subsubsection END-RETURN @node END-REWRITE @subsubsection END-REWRITE @node END-SEARCH @subsubsection END-SEARCH @node END-START @subsubsection END-START @node END-STRING @subsubsection END-STRING @node END-SUBTRACT @subsubsection END-SUBTRACT @node END-UNSTRING @subsubsection END-UNSTRING @node END-WRITE @subsubsection END-WRITE @node ENTRY @subsubsection ENTRY @node ENTRY-CONVENTION @subsubsection ENTRY-CONVENTION @node ENVIRONMENT @subsubsection ENVIRONMENT @node ENVIRONMENT-NAME @subsubsection ENVIRONMENT-NAME @node ENVIRONMENT-VALUE @subsubsection ENVIRONMENT-VALUE @node EOx @subsubsection EOx @node EOL @subsubsection EOL @node EOP @subsubsection EOP @node EOS @subsubsection EOS @node EQUAL @subsubsection EQUAL @node EQUALS @subsubsection EQUALS @node ERASE @subsubsection ERASE @node ERROR @subsubsection ERROR @node ESCAPE @subsubsection ESCAPE @node ESI @subsubsection ESI @node EVALUATE @subsubsection EVALUATE @node EXCEPTION @subsubsection EXCEPTION @node EXCEPTION-OBJECT @subsubsection EXCEPTION-OBJECT @node EXCLUSIVE @subsubsection EXCLUSIVE @node EXIT @subsubsection EXIT @node EXPANDS @subsubsection EXPANDS @node EXTEND @subsubsection EXTEND @node EXTERNAL @subsubsection EXTERNAL @node FACTORY @subsubsection FACTORY @node FALSE @subsubsection FALSE @node FDx @subsubsection FDx @node FILE @subsubsection FILE @node FILE-CONTROL @subsubsection FILE-CONTROL @node FILE-ID @subsubsection FILE-ID @node FILLER @subsubsection FILLER @node FINAL @subsubsection FINAL @node FIRST @subsubsection FIRST @node FLOAT-EXTENDED @subsubsection FLOAT-EXTENDED @node FLOAT-LONG @subsubsection FLOAT-LONG @node FLOAT-SHORT @subsubsection FLOAT-SHORT @node FOOTING @subsubsection FOOTING @node FOR @subsubsection FOR @node FOREGROUND-COLOR @subsubsection FOREGROUND-COLOR @node FOREVER @subsubsection FOREVER @node FORMAT @subsubsection FORMAT @node FREE @subsubsection FREE @node FROM @subsubsection FROM @node FULL @subsubsection FULL @node FUNCTION @subsubsection FUNCTION @quotation DISPLAY FUNCTION TRIM(" trim off leading spaces" LEADING) END-DISPLAY. @end quotation @node FUNCTION-ID @subsubsection FUNCTION-ID @node GENERATE @subsubsection GENERATE @node GET @subsubsection GET @node GIVING @subsubsection GIVING @quotation ADD 1 TO cobol GIVING OpenCOBOL. @end quotation @node GLOBAL @subsubsection GLOBAL @node GOx @subsubsection GOx @node GOBACK @subsubsection GOBACK @verbatim GOBACK. @end verbatim @node GREATER @subsubsection GREATER @node GROUP @subsubsection GROUP @node GROUP-USAGE @subsubsection GROUP-USAGE @node HEADING @subsubsection HEADING @node HIGH-VALUE @subsubsection HIGH-VALUE @node HIGH-VALUES @subsubsection HIGH-VALUES @node HIGHLIGHT @subsubsection HIGHLIGHT @node I-O @subsubsection I-O @node I-O-CONTROL @subsubsection I-O-CONTROL @node IDx @subsubsection IDx @node IDENTIFICATION @subsubsection IDENTIFICATION @node IFx @subsubsection IFx @node IGNORING @subsubsection IGNORING @node IMPLEMENTS @subsubsection IMPLEMENTS @node INx @subsubsection INx @node INDEX @subsubsection INDEX @node INDEXED @subsubsection INDEXED @node INDICATE @subsubsection INDICATE @node INHERITS @subsubsection INHERITS @node INITIAL @subsubsection INITIAL @node INITIALIZE @subsubsection INITIALIZE A sample of the INITIALIZE verb posted `opencobol.org`_ by `human`_ @quotation @table @asis @item @emph{----------------------------------------------------------------- IDENTIFICATION DIVISION. PROGRAM-ID. 'INITTEST'. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. DECIMAL-POINT IS COMMA. INPUT-OUTPUT SECTION. DATA DIVISION.} WORKING-STORAGE SECTION. @item * 77 mychar pic x. 77 mynumeric pic 9. 01 REC-TEST BASED. 03 REC-TEST-PART1 PIC X(10) value all '9'. 03 REC-TEST-PART2 PIC X(10) value all 'A'. 01 fillertest. 03 fillertest-1 PIC 9(10) value 2222222222. 03 filler PIC X value '|'. 03 fillertest-2 PIC X(10) value all 'A'. 03 filler PIC 9(03) value 111. 03 filler PIC X value '.'. @end table @emph{----------------------------------------------------------------- LINKAGE SECTION.}----------------------------------------------------------------- PROCEDURE DIVISION. @emph{----------------------------------------------------------------- Main section. 00.} display 'fillertest ' 'on start:' end-display display fillertest end-display accept mychar * initialize fillertest display 'fillertest ' 'after initialize:' end-display display fillertest end-display accept mychar * initialize fillertest replacing numeric by 9 display 'fillertest ' 'after initialize replacing numeric by 9:' end-display display fillertest end-display accept mychar * initialize fillertest replacing alphanumeric by 'X' display 'fillertest ' 'after initialize replacing alphanumeric by "X":' end-display display fillertest end-display accept mychar * initialize fillertest replacing alphanumeric by all 'X' display 'fillertest ' 'after initialize replacing alphanumeric by all "X":' end-display display fillertest end-display accept mychar * initialize fillertest with filler display 'fillertest ' 'after initialize with filler:' end-display display fillertest end-display accept mychar * initialize fillertest all to value display 'fillertest ' 'after initialize all to value:' end-display display fillertest end-display accept mychar * ALLOCATE REC-TEST display 'REC-TEST after allocating:' end-display display REC-TEST end-display accept mychar * initialize REC-TEST all to value display 'REC-TEST after initalize all to value:' end-display display REC-TEST end-display accept mychar * stop run * continue. ex. exit program. @emph{-----------------------------------------------------------------}--- End of program INITTEST ------------------------------------- @end quotation Outputs: @verbatim fillertest on start: 2222222222|AAAAAAAAAA111. fillertest after initialize: 0000000000| 111. fillertest after initialize replacing numeric by 9: 0000000009| 111. fillertest after initialize replacing alphanumeric by "X": 0000000009|X 111. fillertest after initialize replacing alphanumeric by all "X": 0000000009|XXXXXXXXXX111. fillertest after initialize with filler: 0000000000 000 fillertest after initialize all to value: 2222222222|AAAAAAAAAA111. REC-TEST after allocating: REC-TEST after initalize all to value: 9999999999AAAAAAAAAA @end verbatim @node INITIALIZED @subsubsection INITIALIZED @node INITIATE @subsubsection INITIATE @node INPUT @subsubsection INPUT @node INPUT-OUTPUT @subsubsection INPUT-OUTPUT @node INSPECT @subsubsection INSPECT @node INTERFACE @subsubsection INTERFACE @node INTERFACE-ID @subsubsection INTERFACE-ID @node INTO @subsubsection INTO @node INTRINSIC @subsubsection INTRINSIC @node INVALID @subsubsection INVALID @node INVOKE @subsubsection INVOKE @node ISx @subsubsection ISx @node JUST @subsubsection JUST @node JUSTIFIED @subsubsection JUSTIFIED @node KEY @subsubsection KEY @node KEYBOARD @subsubsection KEYBOARD A special value for Standard Input @quotation @table @asis @item file-control. select cgi-in assign to keyboard. @end table @end quotation @node LABEL @subsubsection LABEL @node LAST @subsubsection LAST @node LC_ALL @subsubsection LC_ALL @node LC_COLLATE @subsubsection LC_COLLATE @node LC_CTYPE @subsubsection LC_CTYPE @node LC_MESSAGES @subsubsection LC_MESSAGES @node LC_MONETARY @subsubsection LC_MONETARY @node LC_NUMERIC @subsubsection LC_NUMERIC @node LC_TIME @subsubsection LC_TIME @node LEADING @subsubsection LEADING @node LEFT @subsubsection LEFT @node LENGTH @subsubsection LENGTH @node LESS @subsubsection LESS @node LIMIT @subsubsection LIMIT @node LIMITS @subsubsection LIMITS @node LINAGE @subsubsection LINAGE LINAGE is a @emph{SPECIAL-REGISTER} supported by OpenCOBOL. A counter is maintained for file WRITE_ and can be used for pageing @emph{and other} control. @quotation @table @asis @item COBOL @strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{* * Example of LINAGE File Descriptor * Author: Brian Tiffin * Date: 10-July-2008 * Tectonics: $ cocb -x linage.cob * $ ./linage * $ cat -n mini-report}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}* IDENTIFICATION DIVISION. PROGRAM-ID. linage-demo. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. @item select optional data-file assign to file-name organization is line sequential file status is data-file-status. @end table @quotation select mini-report assign to "mini-report". @quotation DATA DIVISION. FILE SECTION. FD data-file. 01 data-record. @end quotation 88 endofdata value high-values. 02 data-line pic x(80). FD mini-report linage is 16 lines with footing at 15 lines at top 2 lines at bottom 2. 01 report-line pic x(80). @quotation WORKING-STORAGE SECTION. 01 command-arguments pic x(1024). 01 file-name pic x(160). 01 data-file-status pic 99. 01 lc pic 99. 01 report-line-blank. @end quotation @table @asis @item 02 filler pic x(18) value all "@emph{". 02 filler pic x(05) value spaces. 02 filler pic x(34) VALUE "THIS PAGE INTENTIONALLY LEFT BLANK". 02 filler pic x(05) value spaces. 02 filler pic x(18) value all "}". 01 report-line-data. @end table 02 body-tag pic 9(6). 02 line-3 pic x(74). 01 report-line-header. 02 filler pic x(6) VALUE "PAGE: ". 02 page-no pic 9999. 02 filler pic x(24). 02 filler pic x(5) VALUE " LC: ". 02 header-tag pic 9(6). 02 filler pic x(23). 02 filler pic x(6) VALUE "DATE: ". 02 page-date pic x(6). @quotation 01 page-count pic 9999. PROCEDURE DIVISION. accept command-arguments from command-line end-accept. string @end quotation command-arguments delimited by space into file-name end-string. if file-name equal spaces move "linage.cob" to file-name end-if. @quotation open input data-file. read data-file @end quotation @table @asis @item at end @table @asis @item display "File: " function trim(file-name) " open error" @end table end-display perform early-exit @end table @quotation end-read. open output mini-report. write report-line @end quotation @table @asis @item from report-line-blank end-write. move 1 to page-count. accept page-date from date end-accept. move page-count to page-no. write report-line @end table from report-line-header after advancing page end-write. @quotation perform readwrite-loop until endofdata. display @end quotation "Normal termination@comma{} file name: " function trim(file-name) " ending status: " data-file-status end-display. close mini-report. @table @asis @item * Goto considered harmful? Bah! :) early-exit. close data-file. exit program. stop run. @item *@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@emph{*}}}}}}}}}}}}}}}} readwrite-loop. move data-record to report-line-data move linage-counter to body-tag write report-line from report-line-data @item end-of-page add 1 to page-count end-add move page-count to page-no move linage-counter to header-tag write report-line from report-line-header after advancing page end-write @item end-write read data-file @item at end set endofdata to true end-read . @item @strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{* * Commentary * LINAGE is set at a 20 line logical page * 16 body lines * 2 top lines * A footer line at 15 (inside the body count) * 2 bottom lines * Build with: * $ cobc -x -Wall -Wtruncate linage.cob * Evaluate with: * $ ./linage * This will read in linage.cob and produce a useless mini-report * $ cat -n mini-report}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}* END PROGRAM linage-demo. @end table @end quotation @end quotation Using @quotation $ ./linage except.cob @end quotation Produces a @emph{mini-report} of: @verbatim ****************** THIS PAGE INTENTIONALLY LEFT BLANK ****************** PAGE: 0001 LC: 000000 DATE: 090206 000001 IDENTIFICATION DIVISION. 000002 PROGRAM-ID. MINIPROG. 000003 ENVIRONMENT DIVISION. 000004 CONFIGURATION SECTION. 000005 SOURCE-COMPUTER. LINUX. 000006 OBJECT-COMPUTER. LINUX. 000007 SPECIAL-NAMES. 000008 INPUT-OUTPUT SECTION. 000009 FILE-CONTROL. 000010 SELECT PRINTFILE ASSIGN TO "XXRXWXX" 000011 FILE STATUS RXWSTAT. 000012 DATA DIVISION. 000013 FILE SECTION. 000014 FD PRINTFILE. PAGE: 0002 LC: 000015 DATE: 090206 000001 01 PRINTREC PIC X(132). 000002 WORKING-STORAGE SECTION. 000003 01 RXWSTAT PIC XX. 000004 01 str pic x(4). 000005 PROCEDURE DIVISION. 000006 A00-MAIN SECTION. 000007 001-MAIN-PROCEDURE. 000008 OPEN INPUT PRINTFILE. 000009 DISPLAY "File Status: " RXWSTAT. 000010 DISPLAY "EXCEPTION-FILE: " FUNCTION EXCEPTION-FILE. 000011 DISPLAY "Return Length: " 000012 FUNCTION LENGTH (FUNCTION EXCEPTION-FILE). 000013 DISPLAY "EXCEPTION-STATUS: " FUNCTION EXCEPTION-STATUS. 000014 DISPLAY "EXCEPTION-STATEMENT: " FUNCTION EXCEPTION-STATEMENT. PAGE: 0003 LC: 000015 DATE: 090206 000001 STRING "TOOLONG" DELIMITED SIZE INTO RXWSTAT. 000002 DISPLAY "EXCEPTION-STATUS: " FUNCTION EXCEPTION-STATUS. 000003 DISPLAY "EXCEPTION-STATEMENT: " FUNCTION EXCEPTION-STATEMENT. 000004 DISPLAY "EXCEPTION-LOCATION: " FUNCTION EXCEPTION-LOCATION. 000005 STOP RUN. @end verbatim See @emph{except.cob} under the EXCEPTION-STATUS_ entry. @node LINAGE-COUNTER @subsubsection LINAGE-COUNTER An internal OpenCOBOL noun@comma{} or @emph{Special Register}. Value is readonly and is maintained during WRITEs to files that have a LINAGE_ clause. Useful for quick reports and logical page layouts. @node LINE @subsubsection LINE @node LINE-COUNTER @subsubsection LINE-COUNTER @node LINES @subsubsection LINES @node LINKAGE @subsubsection LINKAGE @node LOCAL-STORAGE @subsubsection LOCAL-STORAGE @node LOCALE @subsubsection LOCALE @node LOCK @subsubsection LOCK @node LOW-VALUE @subsubsection LOW-VALUE A figurative constant for the lowest value of a COBOL field. @quotation MOVE LOW-VALUE TO numeric-1. @table @asis @item IF alphanumeric-1 EQUALS LOW-VALUE DISPLAY "Failed validation" END-DISPLAY @end table END-IF. @end quotation @node LOW-VALUES @subsubsection LOW-VALUES A pluralized form of LOW-VALUE_. Equivalent. @quotation MOVE LOW-VALUES TO alphanumeric-1. @end quotation @node LOWLIGHT @subsubsection LOWLIGHT A screen attribute for DISPLAY and SCREEN SECTION fields. @quotation SCREEN SECTION. 01 example. 05 FILLER LINE 1 COLUMN 10 VALUE IS "Example:" LOWLIGHT. @end quotation Will display the @emph{Example:} legend in a dimmed video if supported with the current terminal settings. @node MANUAL @subsubsection MANUAL @node MEMORY @subsubsection MEMORY @node MERGE @subsubsection MERGE @node MESSAGE @subsubsection MESSAGE @node METHOD @subsubsection METHOD @node METHOD-ID @subsubsection METHOD-ID @node MINUS @subsubsection MINUS @node MODE @subsubsection MODE @node MOVE @subsubsection MOVE A workhorse of the COBOL paradigm. MOVE is highly flexible@comma{} intelligent@comma{} safe and sometimes perplexing data movement verb. @quotation 01 alphanum-3 PIC XXX. 01 num2 PIX 99. MOVE "ABCDEFG" TO xvar3 DISPLAY xvar3 END-DISPLAY MOVE 12345 TO num2 DISPLAY num2 END-DISPLAY @end quotation displays: @verbatim ABC 45 @end verbatim Note the 45@comma{} MOVE uses a right to left rule when moving numerics. Groups can be moved with @quotation MOVE CORRESPONDING ident-1 TO ident-2 @end quotation in which case only the group items of the same name will be transferred from the ident-1 group to the ident-2 fields. @node MULTIPLE @subsubsection MULTIPLE @node MULTIPLY @subsubsection MULTIPLY @node NATIONAL @subsubsection NATIONAL @node NATIONAL-EDITED @subsubsection NATIONAL-EDITED @node NATIVE @subsubsection NATIVE @node NEGATIVE @subsubsection NEGATIVE @node NESTED @subsubsection NESTED @node NEXT @subsubsection NEXT @node NOx @subsubsection NOx @node NONE @subsubsection NONE @node NORMAL @subsubsection NORMAL @node NOT @subsubsection NOT @node NULL @subsubsection NULL @node NULLS @subsubsection NULLS @node NUMBER @subsubsection NUMBER @node NUMBERS @subsubsection NUMBERS @node NUMERIC @subsubsection NUMERIC @node NUMERIC-EDITED @subsubsection NUMERIC-EDITED @node OBJECT @subsubsection OBJECT @node OBJECT-COMPUTER @subsubsection OBJECT-COMPUTER @node OBJECT-REFERENCE @subsubsection OBJECT-REFERENCE @node OCCURS @subsubsection OCCURS @node OFx @subsubsection OFx @node OFF @subsubsection OFF @node OMITTED @subsubsection OMITTED @node ONx @subsubsection ONx @node ONLY @subsubsection ONLY @node OPEN @subsubsection OPEN @node OPTIONAL @subsubsection OPTIONAL @node OPTIONS @subsubsection OPTIONS @node ORx @subsubsection ORx @node ORDER @subsubsection ORDER @node ORGANIZATION @subsubsection ORGANIZATION @node OTHER @subsubsection OTHER @node OUTPUT @subsubsection OUTPUT @node OVERFLOW @subsubsection OVERFLOW @node OVERLINE @subsubsection OVERLINE @node OVERRIDE @subsubsection OVERRIDE @node PACKED-DECIMAL @subsubsection PACKED-DECIMAL @node PADDING @subsubsection PADDING @node PAGE @subsubsection PAGE @node PAGE-COUNTER @subsubsection PAGE-COUNTER @node PARAGRAPH @subsubsection PARAGRAPH @node PERFORM @subsubsection PERFORM @node PFx @subsubsection PFx @node PHx @subsubsection PHx @node PIC @subsubsection PIC @node PICTURE @subsubsection PICTURE Full standards support of all alpha@comma{} alphanumeric and numeric storage specifiers as well as full support for edit and numeric-edit clauses. An example of some of the PICTURE options @quotation @emph{>>source format is free}>@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{* @emph{> Author: jrls (John Ellis)}> Date: Oct-2008 @emph{> Purpose: formated output examples using pic strings.}>}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}* identification division. program-id. picstring. data division. working-storage section. *> @table @asis @item 01 header. 05 filler pic xxx value "ln". 05 filler pic x(11) value " disp1". 05 filler pic x(11) value " disp2". 05 filler pic x(11) value " disp3". 05 filler pic x(11) value " disp4". 05 filler pic x(12) value " disp5". 05 filler pic x(9) value " an1". 05 filler pic x(14) value " phone". 05 filler pic x(10) value " date". @end table @emph{> 01 headerLines pic x(90) value all "-".}> 01 displayformats. 05 linenum pic 99 value 1. 05 disp1 pic zzz@comma{}zz9.99 value zero. 05 filler pic x value spaces. 05 disp2 pic $zz@comma{}zz9.99 value zero. 05 filler pic x value spaces. 05 disp3 pic ---@comma{}--9.99 value zero. 05 filler pic x value spaces. 05 disp4 pic $-z@comma{}zz9.99 value zero. 05 filler pic x value spaces. 05 disp5 pic -zz@comma{}zz9.zz- blank zero value zero. 05 filler pic x value spaces. @emph{><}an1 is actually a string field because of the embedded blanks@comma{} thus you put value spaces. 05 an1 pic 99b99b99 value spaces. 05 filler pic x value spaces. 05 phone pic bxxxbxxxbxxxx value spaces. 05 filler pic x value spaces. 05 dispdate pic 99/99/9999 value zero. *> procedure division. 0000-start. @emph{> display headerLines. display header. display headerLines.}><@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{*}}}}}}}}}}@strong{@emph{*}}*@emph{*} move 220.22 to disp1@comma{} disp2. move -220.22 to disp3@comma{} disp4@comma{} disp5. @quotation @table @asis @item inspect disp5 replacing first "-" by "("@comma{} first "-" by ")". @end table move 10122008 to dispdate. @end quotation @table @asis @item @emph{><}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{* @emph{><}Please note the results of moving 'abcd' to an1. @emph{><}an1 will show up as 00 00 00 because alpha data was @emph{><}moved into instead of numeric data. @emph{><} @emph{><}The phone field will display " abc def ghij" because @emph{><}'b' in the pic string. @emph{><}}}}}}}}}}}}}}}}}}}}}}}}}}* move "abcd" to an1. move "abcdefghij" to phone. display displayformats. add 1 to linenum. move zero to disp4@comma{} disp5. @item @emph{><}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{* @emph{><}Here after moving data to an1 and phone@comma{} I use the @emph{><}inspect statement to replace the blanks. @emph{><}}}}}}}}}}}}}}}}}}}}}}}}}}* move "123456" to an1. move "5555551234" to phone. inspect an1 replacing all " " by "-". @table @asis @item inspect phone replacing first " " by "("@comma{} first " " by ")"@comma{} first " " by "-". @end table display displayformats. inspect phone converting "23456789" to "adgjmptw". display phone. perform 0010-endProgram. @end table @emph{> 0010-endProgram. stop run.}> @end quotation Outputs: @verbatim ------------------------------------------------------------------------------------------ ln disp1 disp2 disp3 disp4 disp5 an1 phone date ------------------------------------------------------------------------------------------ 01 220.22 $220.22 -220.22 $-220.22 (220.22) 00 00 00 abc def ghij 10/12/2008 02 220.22 $220.22 -220.22 $ 0.00 12-34-56 (555)555-1234 10/12/2008 (jjj)jjj-1adg @end verbatim @node PLUS @subsubsection PLUS @node POINTER @subsubsection POINTER @quotation 01 C-HANDLE USAGE IS POINTER. CALL "open-lib" USING C-HANDLE @end quotation @node POSITION @subsubsection POSITION @node POSITIVE @subsubsection POSITIVE @node PRESENT @subsubsection PRESENT @node PREVIOUS @subsubsection PREVIOUS @node PRINTER @subsubsection PRINTER @node PRINTING @subsubsection PRINTING @node PROCEDURE @subsubsection PROCEDURE @node PROCEDURE-POINTER @subsubsection PROCEDURE-POINTER @node PROCEDURES @subsubsection PROCEDURES @node PROCEED @subsubsection PROCEED @node PROGRAM @subsubsection PROGRAM @node PROGRAM-ID @subsubsection PROGRAM-ID @node PROGRAM-POINTER @subsubsection PROGRAM-POINTER @node PROMPT @subsubsection PROMPT @node PROPERTY @subsubsection PROPERTY @node PROTOTYPE @subsubsection PROTOTYPE @node PURGE @subsubsection PURGE @node QUEUE @subsubsection QUEUE @node QUOTE @subsubsection QUOTE @node QUOTES @subsubsection QUOTES @node RAISE @subsubsection RAISE @node RAISING @subsubsection RAISING @node RANDOM @subsubsection RANDOM @node RDx @subsubsection RDx @node READ @subsubsection READ @node RECEIVE @subsubsection RECEIVE @node RECORD @subsubsection RECORD @node RECORDING @subsubsection RECORDING @node RECORDS @subsubsection RECORDS @node RECURSIVE @subsubsection RECURSIVE @node REDEFINES @subsubsection REDEFINES @node REEL @subsubsection REEL @node REFERENCE @subsubsection REFERENCE @node RELATION @subsubsection RELATION @node RELATIVE @subsubsection RELATIVE @node RELEASE @subsubsection RELEASE @node REMAINDER @subsubsection REMAINDER @node REMOVAL @subsubsection REMOVAL @node RENAMES @subsubsection RENAMES @node REPLACE @subsubsection REPLACE @node REPLACING @subsubsection REPLACING @node REPORT @subsubsection REPORT @node REPORTING @subsubsection REPORTING @node REPORTS @subsubsection REPORTS @node REPOSITORY @subsubsection REPOSITORY @node REQUIRED @subsubsection REQUIRED @node RESERVE @subsubsection RESERVE @node RESET @subsubsection RESET @node RESUME @subsubsection RESUME @node RETRY @subsubsection RETRY @node RETURN @subsubsection RETURN @node RETURNING @subsubsection RETURNING @node REVERSE-VIDEO @subsubsection REVERSE-VIDEO @node REWIND @subsubsection REWIND @node REWRITE @subsubsection REWRITE @node RFx @subsubsection RFx @node RHx @subsubsection RHx @node RIGHT @subsubsection RIGHT @node ROLLBACK @subsubsection ROLLBACK @node ROUNDED @subsubsection ROUNDED @node RUN @subsubsection RUN @node SAME @subsubsection SAME @node SCREEN @subsubsection SCREEN @node SDx @subsubsection SDx @node SEARCH @subsubsection SEARCH @node SECONDS @subsubsection SECONDS @node SECTION @subsubsection SECTION @node SECURE @subsubsection SECURE @node SEGMENT @subsubsection SEGMENT @node SELECT @subsubsection SELECT @node SELF @subsubsection SELF @node SEND @subsubsection SEND @node SENTENCE @subsubsection SENTENCE @node SEPARATE @subsubsection SEPARATE @node SEQUENCE @subsubsection SEQUENCE @node SEQUENTIAL @subsubsection SEQUENTIAL @node SET @subsubsection SET @node SHARING @subsubsection SHARING @node SIGN @subsubsection SIGN @node SIGNED @subsubsection SIGNED @node SIGNED-INT @subsubsection SIGNED-INT @node SIGNED-LONG @subsubsection SIGNED-LONG @node SIGNED-SHORT @subsubsection SIGNED-SHORT @node SIZE @subsubsection SIZE @node SORT @subsubsection SORT @quotation @table @asis @item * OpenCOBOL SORT verb example using standard in and standard out identification division. program-id. sorting. environment division. input-output section. file-control. select sort-in assign keyboard organization line sequential. select sort-out assign display organization line sequential. select sort-work assign "sortwork". data division. file section. fd sort-in. 01 in-rec pic x(255). fd sort-out. 01 out-rec pic x(255). sd sort-work. 01 work-rec pic x(255). procedure division. sort sort-work ascending key work-rec using sort-in giving sort-out. goback. exit program. end program sorting. @end table @end quotation Here is a snippet describing TABLE sorts by [jrls_swla]_ @quotation table define @quotation 01 nbr-of-columns pic 9(4) value zero. 01 tcindex2 usage is index. 01 dbtables. 03 tables-columns occurs 1 to 1000 times depending on nbr-of-columns ascending key tcTable@comma{} tcColumn indexed by tcindex. 05 tcTable pic x(64) value spaces. 05 tcColumn pic x(64) value spaces. 05 tcAlias pic x(10) value spaces. 05 tcOrder pic 9(4) value zero. 05 tcType pic x(10) value spaces. 05 tcMaxLen pic 9(4) value zero. *> 01 aliasName. 05 pic x value "t". 05 anVal pic 9(3) value zero. @quotation @table @asis @item 01 showdata. 05 sdTable pic x(17) value spaces. 05 sdColumn pic x(17) value spaces. 05 sdType pic x(10) value spaces. 05 sdOrder pic zzzzz-. 05 sdMaxLen pic zzzzz. @end table @end quotation @end quotation table load @quotation @table @asis @item perform varying rows from 1 by 1 until rows > dbNumRows call "dbNextRow" using by value dbResult@comma{} by reference ColumnBuff@comma{} by reference CbuffDesc returning dbResult add 1 to nbr-of-columns set tcindex up by 1 move cbTable to tcTable(tcindex) move cbColumn to tcColumn(tcindex) move cbType to tcType(tcindex) move cbOrder to tcOrder(tcindex) move cbMaxLen to tcMaxLen(tcindex) if nbr-of-columns = 1 add 1 to anVal else set tcindex2 to tcindex set tcindex2 down by 1 if cbTable <> tcTable(tcindex2) add 1 to anVal end-if end-if move aliasName to tcAlias(tcindex) @end table end-perform. @end quotation table sort @quotation sort tables-columns ascending key tcTable@comma{} tcColumn. @end quotation display table @quotation @table @asis @item perform varying tcindex from 1 by 1 until tcindex > nbr-of-columns move tcTable(tcindex) to sdTable move tcColumn(tcindex) to sdColumn move tcOrder(tcindex) to sdOrder move tcType(tcindex) to sdType move tcMaxLen(tcindex) to sdMaxLen display showdata @end table end-perform. @end quotation @end quotation @node SORT-MERGE @subsubsection SORT-MERGE Used in an I-O-CONTROL paragraph with the SAME clause: @verbatim SAME SORT-MERGE AREA FOR filename-1. @end verbatim The SORT-MERGE keyword and SORT keyword are equivalent in this case. @node SORT-RETURN @subsubsection SORT-RETURN A @emph{SPECIAL-REGISTER} used by the OpenCOBOL SORT routines. @itemize @item +000000000 for success @item +000000016 for failure @end itemize A programmer may set SORT-RETURN in an INPUT PROCEDURE. @node SOURCE @subsubsection SOURCE @node SOURCE-COMPUTER @subsubsection SOURCE-COMPUTER @node SOURCES @subsubsection SOURCES @node SPACE @subsubsection SPACE @node SPACES @subsubsection SPACES @node SPECIAL-NAMES @subsubsection SPECIAL-NAMES OpenCOBOL supports a fair complete set of the SPECIAL-NAMES in common use. @node STANDARD @subsubsection STANDARD @node STANDARD-1 @subsubsection STANDARD-1 @node STANDARD-2 @subsubsection STANDARD-2 @node START @subsubsection START @node STATEMENT @subsubsection STATEMENT @node STATUS @subsubsection STATUS @node STEP @subsubsection STEP @node STOP @subsubsection STOP @node STRING @subsubsection STRING @node STRONG @subsubsection STRONG @node SUB-QUEUE-1 @subsubsection SUB-QUEUE-1 @node SUB-QUEUE-2 @subsubsection SUB-QUEUE-2 @node SUB-QUEUE-3 @subsubsection SUB-QUEUE-3 @node SUBTRACT @subsubsection SUBTRACT @node SUM @subsubsection SUM @node SUPER @subsubsection SUPER @node SUPPRESS @subsubsection SUPPRESS @node SYMBOL @subsubsection SYMBOL @node SYMBOLIC @subsubsection SYMBOLIC @node SYNC @subsubsection SYNC @node SYNCHRONIZED @subsubsection SYNCHRONIZED @node SYSTEM-DEFAULT @subsubsection SYSTEM-DEFAULT @node TABLE @subsubsection TABLE @node TALLYING @subsubsection TALLYING @node TAPE @subsubsection TAPE @node TERMINAL @subsubsection TERMINAL @node TERMINATE @subsubsection TERMINATE @node TEST @subsubsection TEST @node TEXT @subsubsection TEXT @node THAN @subsubsection THAN @node THEN @subsubsection THEN @node THROUGH @subsubsection THROUGH @node THRU @subsubsection THRU @node TIME @subsubsection TIME @node TIMES @subsubsection TIMES @node TOx @subsubsection TOx @node TOPx @subsubsection TOPx @node TRAILING @subsubsection TRAILING @node TRUE @subsubsection TRUE @node TYPE @subsubsection TYPE @node TYPEDEF @subsubsection TYPEDEF @node UCS-4 @subsubsection UCS-4 @node UNDERLINE @subsubsection UNDERLINE @node UNIT @subsubsection UNIT @node UNIVERSAL @subsubsection UNIVERSAL @node UNLOCK @subsubsection UNLOCK @node UNSIGNED @subsubsection UNSIGNED @node UNSIGNED-INT @subsubsection UNSIGNED-INT @node UNSIGNED-LONG @subsubsection UNSIGNED-LONG @node UNSIGNED-SHORT @subsubsection UNSIGNED-SHORT @node UNSTRING @subsubsection UNSTRING @node UNTIL @subsubsection UNTIL @node UPx @subsubsection UPx @node UPDATE @subsubsection UPDATE @node UPON @subsubsection UPON @node USAGE @subsubsection USAGE OpenCOBOL uses standard big-endian_ internal storage by default. USAGE clauses influence the data representation. The INTEL architecture uses little-endian_ form and OpenCOBOL programmers developing for this common chipset may need to pay heed to this for performance purposes. As per the standards@comma{} OpenCOBOL supports COMPUTATIONAL-5 native usage. OpenCOBOL enables use of one to eight byte binary representations in both big and little endian forms. Along with full support of all common COBOL_ PICTURE_ clauses both storage and display@comma{} OpenCOBOL supports USAGE clauses of: @itemize @item BINARY @item COMPUTATIONAL@comma{} COMP @item COMP-1 @item COMP-2 @item COMP-3 @item COMP-4 @item COMP-5 @item COMP-X @item DISPLAY @item INDEX @item PACKED-DECIMAL @item POINTER @item PROGRAM-POINTER @item SIGNED-SHORT @item SIGNED-INT @item SIGNED-LONG @item UNSIGNED-SHORT @item UNSIGNED-INT @item UNSIGNED-LONG @item BINARY-CHAR SIGNED @item BINARY-CHAR UNSIGNED @item BINARY-CHAR @item BINARY-SHORT SIGNED @item BINARY-SHORT UNSIGNED @item BINARY-SHORT @item BINARY-LONG SIGNED @item BINARY-LONG UNSIGNED @item BINARY-LONG @item BINARY-DOUBLE SIGNED @item BINARY-DOUBLE UNSIGNED @item BINARY-DOUBLE @item BINARY-C-LONG SIGNED @item BINARY-C-LONG UNSIGNED @item BINARY-C-LONG @end itemize @node USE @subsubsection USE @node USER-DEFAULT @subsubsection USER-DEFAULT @node USING @subsubsection USING @node UTF-16 @subsubsection UTF-16 @node UTF-8 @subsubsection UTF-8 @node VAL-STATUS @subsubsection VAL-STATUS @node VALID @subsubsection VALID @node VALIDATE @subsubsection VALIDATE @node VALIDATE-STATUS @subsubsection VALIDATE-STATUS @node VALUE @subsubsection VALUE @node VALUES @subsubsection VALUES @node VARYING @subsubsection VARYING @node WHEN @subsubsection WHEN @node WITH @subsubsection WITH @node WORKING-STORAGE @subsubsection WORKING-STORAGE @node WRITE @subsubsection WRITE @node YYYYDDD @subsubsection YYYYDDD @node YYYYMMDD @subsubsection YYYYMMDD @node ZERO @subsubsection ZERO @node ZEROES @subsubsection ZEROES @node ZEROS @subsubsection ZEROS @node Does OpenCOBOL support modules? @subsection Does OpenCOBOL support modules? Yes. Quite nicely in fact. Dynamically! COBOL_ modules@comma{} and object files of many other languages are linkable. As OpenCOBOL uses intermediate C@comma{} linkage to other languages is well supported across many platforms. The OpenCOBOL CALL_ instruction maps COBOL USAGE_ to many common C stack frame data representations. Multipart@comma{} complex system development is well integrated in the OpenCOBOL model. @quotation $ cobc -b hello.cob goodbye.cob @end quotation Combines both source files into a single dynamically loadable module. Example produces @strong{hello.so}. Using the @strong{-l} link library option@comma{} OpenCOBOL has access to most shared libraries supported on it's platforms. @quotation $ cobc -x -lcurl showcurl.cob @end quotation Will link the /usr/lib/libcurl.so (@emph{from the cURL project}) to showcurl. The OpenCOBOL CALL_ verb will use this linked library to resolve calls at runtime. Large scale systems are at the heart of COBOL development and OpenCOBOL is no exception. For more information@comma{} see `What is COB_PRE_LOAD?`_. @node What is COB_PRE_LOAD? @subsection What is COB_PRE_LOAD? COB_PRE_LOAD is an environment variable that controls what dynamic link modules are included in a run. For example: @quotation $ cobc occurl.c $ cobc occgi.c $ cobc -x myprog.cob $ export COB_PRE_LOAD=occurl:occgi $ ./myprog @end quotation That will allow the OpenCOBOL runtime link resolver to find the entry point for CALL "CBL_OC_CURL_INIT" in the occurl.so module. @emph{Note:} the modules listed in the COB_PRE_LOAD environment variable DO NOT have extensions. OpenCOBOL will do the right thing on the various platforms. If the DSO_ files are not in the current working directory along with the executable@comma{} the COB_LIBRARY_PATH can be set to find them. @node What is the OpenCOBOL LINKAGE SECTION for? @subsection What is the OpenCOBOL LINKAGE SECTION for? Argument passing in COBOL is normally accomplished through the @strong{LINKAGE SECTION}. This section does not allocate or initialize memory as would definitions in the WORKING-STORAGE SECTION. Care must be taken to inform COBOL of the actual source address of these variables before use. Influences CHAINING and USING phrases. See CALL_ for more details. @node What does the -fstatic-linkage OpenCOBOL compiler option do? @subsection What does the -fstatic-linkage OpenCOBOL compiler option do? Under normal conditions@comma{} the @emph{LINKAGE SECTION} is unallocated and uninitialized. When a LINKAGE SECTION variable@comma{} that is not part of the @emph{USING} phrase (not a named calling argument)@comma{} any memory that has been addressed becomes unaddressable across calls. @emph{-fstatic-linkage} creates static addressing to the LINKAGE SECTION. From [Roger]_: @verbatim This relates to LINKAGE items that are NOT referred to in the USING phrase of the PROCEDURE DIVISION. It also only has relevance when the program is CALL'ed from another prog. This means that the addressability of these items must be programmed (usually with SET ADDRESS) before reference. Per default, the item loses it's addressability on exit from the program. This option causes the module to retain the item's address between CALL invocations of the program. @end verbatim With some rumours that this may become the default in future releases of OpenCOBOL@comma{} and the @emph{-fstatic-linkage} option may be deprecated. @node Can OpenCOBOL interface with Ada? @subsection Can OpenCOBOL interface with Ada? Yes. The freely available @strong{gnat} system can be used and will create object files that can be included in an OpenCOBOL project. This example compiles an gnat package that includes @emph{hello} and @emph{ingress} PROCEDURE and a @emph{echo} FUNCTION. These will be called from an OpenCOBOL @strong{adacaller.cob} program. The gnat specification file @verbatim with Interfaces.C; use Interfaces.C; package HelloAda is procedure hello; procedure ingress(value : in INTEGER); function echo(message : in char_array) return integer; pragma export(C, hello); pragma export(C, ingress); pragma export(C, echo); end HelloAda; @end verbatim The gnat implementation body: @verbatim with Ada.Text_IO, Ada.Integer_Text_IO, Interfaces.C; use Ada.Text_IO, Ada.Integer_Text_IO, Interfaces.C; package body HelloAda is procedure hello is begin Put_Line("Hello from Ada and OpenCOBOL"); New_Line; end hello; procedure ingress(value : in integer) is begin Put_Line("Passing integer to Ada from OpenCOBOL"); Put("OpenCOBOL passed: "); Put(value); New_Line; New_Line; end ingress; function echo(message : in char_array) return integer is begin Put(To_Ada(message, true)); return To_Ada(message, true)'length; end echo; end HelloAda; @end verbatim The adacaller.cob source file @quotation @table @asis @item @strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{* adacaller.cob}}}}}}}}}@strong{@strong{@strong{@strong{@strong{@strong{@emph{* >>SOURCE FORMAT IS FIXED}}}}}}}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{* * Author: Brian Tiffin * Date: 08-Sep-2008 * Purpose: Demonstrate using Ada sub-programs * Tectonics: gnatgcc -c helloada.adb * gnatbind -n helloada * gnatgcc -c b~helloada.abd * cobc -x -lgnat caller.cob helloada.o b~helloada.o}}}}}}}}}}}}}}}}}}}}}}}}}}@strong{@strong{@strong{*}}}* identification division. program-id. caller. data division. working-storage section. 01 ada-message pic x(10) value "Ada echo" & x'0a' & x'00'. 01 result pic s9(9) value high-value. @item @emph{*}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{*}}}}}}}}}}}}}}}* procedure division. begin. call "adainit" end-call call "hello" end-call call "ingress" using by value 42 end-call @table @asis @item call "echo" using by reference ada-message returning result @end table end-call display "Ada return: " result end-display call "adafinal" end-call goback . end program caller. @end table @end quotation And the tectonics; Debian GNU/Linux @emph{build.sh} @quotation gnatgcc -c helloada.adb gnatbind -n helloada gnatgcc -c b~helloada.adb cobc -x -lgnat adacaller.cob helloada.o b~helloada.o @end quotation An important step is the creation of the object file from the @emph{gnatbind} output @emph{with -n} that is used in the final OpenCOBOL executable. Sample run using ./adacaller: @verbatim Hello from Ada and OpenCOBOL Passing integer to Ada from OpenCOBOL OpenCOBOL passed: 42 Ada echo Ada return: +000000009 @end verbatim @node Does OpenCOBOL support SCREEN SECTION? @subsection Does OpenCOBOL support SCREEN SECTION? Yes. The OpenCOBOL 1.1 pre-release now includes support for SCREEN SECTION. Experimental release for this support occurred in early July@comma{} 2008. The compiler recognizes most (if not all) of the @emph{Screen description entry} of the COBOL 2008 Draft standard. External variables that influence screen handling include @table @asis @item COB_SCREEN_EXCEPTIONS=Y To enable exceptions during ACCEPT. @item COB_SCREEN_ESCAPE=Y To enable handling of the escape key. @end table See `Does OpenCOBOL support CRT STATUS?`_ for more information on key codes and exception handling. According to the standard a SCREEN SECTION ACCEPT does not need to be proceeded by a DISPLAY. The extra DISPLAY won't hurt@comma{} but is not necessary. @node What are the OpenCOBOL SCREEN SECTION colour values? @subsection What are the OpenCOBOL SCREEN SECTION colour values? The FOREGROUND-COLOR and BACKGROUND-COLOR clauses will accept @quotation 78 black value 0. 78 blue value 1. 78 green value 2. 78 cyan value 3. 78 red value 4. 78 magenta value 5. 78 brown value 6. 78 white value 7. @end quotation The display of these colours are also influenced by HIGHLIGHT@comma{} LOWLIGHT and REVERSE-VIDEO options. For instance@comma{} brown will display as yellow when HIGHLIGHT is used. @node Does OpenCOBOL support CRT STATUS? @subsection Does OpenCOBOL support CRT STATUS? Yes. @quotation ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. CRT STATUS IS screen-status. DATA DIVISION. WORKING-STORAGE SECTION. COPY screenio. 01 screen-status pic 9(4). PROCEDURE DIVISION. ACCEPT screen-sample. IF screen-status = COB-SCR-F1 ... @end quotation There is also a special OpenCOBOL variable@comma{} @strong{COB-CRT-STATUS} which can be used instead of the CRT STATUS special name. There is also a COPY text that ships with OpenCOBOL@comma{} copy/screenio.cpy that can be included in the DATA DIVISION and provides 78 level constants for supported key status codes. Some values include: @itemize @item COB-SCR-F1 thru @item COB-SCR-F64 @item COB-SCR-ESC @end itemize examine the file to see the other values. @node What is CobCurses? @subsection What is CobCurses? CobCurses is an optional package designed to work with OpenCOBOL 1.0@comma{} before OpenCOBOL 1.1 SCREEN SECTION support was initiated. It has many features beyond simple SCREEN SECTION handling. See @uref{http://sourceforge.net/projects/cobcurses,http://sourceforge.net/projects/cobcurses} for full details. This is a major piece of work by Warren Gay@comma{} ve3wwg. From an opencobol.org_ posting by Warren announcing release 0.95: @verbatim CobCurses is a package designed to allow Open-Cobol programmers to create screens on open system platforms, or those (like Windows) that can use PDCurses. Since handcrafting screens is tedious work, this package includes a "Screen Designer" utility. All User Guides and Programmer Guide documentation can be found on the source forge (see link at bottom). ==== RELEASE NOTES ==== A large number of internal changes were implemented in this release, but first let's cover the user visible improvements: 1. MENUS! Popup menus are now supported, and are available in sdesign with every Action field. In fact, any sdesign field that is marked with a diamond graphic, has the ability to popup a menu with F1 (or ^O). 2. To support menus, FUNCTION keys are now available in Action mode (though CONTROL-O is an alternate way of opening a menu). This included a new event callback NC-FKEY-EVENT. 3. GRAPHIC characters in the screen background. It is now possible using sdesign to draw alternate-charset graphics in your screen background. See the notes in the opening help screen for the "Paint" function. 4. TRACE facilities. CobCurses now includes an environment variable that can enable capturing of trace information to a file for debugging. A routine named NC_TRACE_MSG can also be used to add custom messages to the trace file. INTERNAL CHANGES: The main two major internal changes were: 1. The terminal support has been virtualized, so that the CobCurses routines deal with a "terminal" object (not curses routines). This will eventually lead to other possible windowing interfaces like perhaps graphic X Window or native Windows support. The other motivation for this was to allow CobCurses to have one consistent set of constants for colours, attributes and character sets. Previously, these values were different depending upon the platform and implementation of curses used. 2. Menu support has been provided independently of curses. This is important for portability since PDCurses and some platforms do not provide a curses menu library. This also guarantees that CobCurses menus will behave consistently on all platforms (and overcome menu paging bugs in ncurses). PLANNED FOR THE NEXT RELEASE: Please avoid writing much code that works with colour pairs. In the next release, it is planned to hide the colour pair value altogether by using a TDC (Terminal Drawing Context). This TDC will tie together attributes and colours, and perhaps other "drawing contexts" so that you won't have to manage colour pairs (this will be transparent). This will also pave the way for graphical interfaces where a selected font and line styles etc. may also be supported. NOTES: HPUX users will need to link with ncurses, instead of the native HPUX curses libraries. I didn't have time to fully investigate this, but the native include files define things like MENU and ITEM types that conflict with the CobCurses defined ones. ==== The release is available for download here: http://sourceforge.net/projects/cobcurses @end verbatim @node What is CobXRef? @subsection What is CobXRef? CobXRef is a COBOL cross-referencing utility written by Vincent Coen and ported to OpenCOBOL 1.1. Current source code is available at @uref{http://svn.wp0.org/add1/tools/cobxref,http://svn.wp0.org/add1/tools/cobxref} or @uref{http://sourceforge.net/projects/cobxref/,http://sourceforge.net/projects/cobxref/} and is |currently| in active development. The system ships with full documentation and information for building from source is included in the @emph{readme} file. Fetching the utility @quotation $ svn checkout @uref{http://svn.wp0.org/add1/tools/cobxref,http://svn.wp0.org/add1/tools/cobxref} @end quotation Example @strong{truncated} to 72 and using the ocdoc.cob OpenCOBOL program for source code: @verbatim $ cobc -save-temps ocdoc.cob $ cobxref ocdoc.i -L $ cut -c1-72 ocdoc.lst ACS Cobol Cross Reference Xref v0.95.27 (04/01/2009@11:27) Dictionary Fi Symbols of Module: ocdoc (ocdoc) -------------------------------- Data Section (FILE) Defn Locations ---------------------------------+-------------------------------------- doc-output 000124F 000252 000499 doc-record 000125F 000269 000381 000387 000390 00 000478 000482 000485 source-input 000122F 000251 000287 000458 000500 source-record 000123F 000285 000288 000300 000316 00 000324 000355 000456 000459 standard-input 000117F 000256 000282 000453 000497 standard-output 000119F 000257 000496 stdin-record 000118F 000283 000285 000454 000456 stdout-record 000120F 000387 000388 000475 000476 ACS Cobol Cross Reference Xref v0.95.27 (04/01/2009@11:27) Dictionary Fi Symbols of Module: ocdoc (ocdoc) -------------------------------- Data Section (WORKING-STORAGE) Defn Locations ---------------------------------+-------------------------------------- arguments 000128W 000219 000221 000244 000245 autoappend 000187W 000380 autodoc 000186W 000385 buffer-empty 000178W 000267 000380 000398 000472 buffer-flag 000177W buffer-offset 000176W 000268 000382 000399 000433 00 buffered-output 000179W 000385 000441 000471 counter 000181W 000369 000410 000412 000416 data-field1 000193W data-field2 000194W data-field3 000197W data-record 000192W data-subfield1 000195W data-subfield2 000196W 000218 doc-buffer 000175W 000417 000419 000430 doc-name 000130W 000246 000505 000522 000532 filter-flag 000138W filtering 000139W 000254 000281 000386 000452 00 first-part 000184W 000368 helping 000137W 000222 here-data 000169W 000355 here-record 000167W 000356 heredoc 000156W 000315 000337 000354 hereend 000153W 000340 000353 hereflag 000155W herenone 000157W 000341 herestart 000152W 000336 000353 len-of-comment 000182W 000411 000415 000416 line-count 000141W 000270 000301 000435 line-display 000142W 000435 000438 result 000190W 000548 000551 000552 result-name 000131W 000247 000518 000524 000534 rst-command 000189W 000517 000525 000535 000542 00 seq-data 000173W 000317 seq-record 000171W 000318 skipseqnum 000135W 000314 source-name 000129W 000246 000504 special 000185W 000379 style-name 000132W 000247 000519 000530 trimmed 000151W 000316 000321 000324 000356 00 usagehelp 000136W 000221 verbose 000134W 000392 000480 000503 000539 verbosity 000133W 000248 ACS Cobol Cross Reference Xref v0.95.27 (04/01/2009@11:27) Dictionary Fi Variable Tested [S] Symbol (88-Conditions) -------------------------------------------------------------- buffer-flag buffer-empty buffer-flag buffered-output filter-flag filtering first-part special first-part autodoc first-part autoappend hereflag heredoc hereflag herenone trimmed herestart trimmed hereend usagehelp helping verbosity verbose verbosity skipseqnum ACS Cobol Cross Reference Xref v0.95.27 (04/01/2009@11:27) Dictionary Fi Variable Tested Symbol (88-Conditions) [S] -------------------------------------------------------------- first-part autoappend first-part autodoc buffer-flag buffer-empty buffer-flag buffered-output filter-flag filtering usagehelp helping hereflag heredoc trimmed hereend hereflag herenone trimmed herestart verbosity skipseqnum first-part special verbosity verbose ACS Cobol Cross Reference Xref v0.95.27 (04/01/2009@11:27) Dictionary Fi Procedure Defn Locations ---------------------------------+-------------------------------------- trim 000324P 000394 000430 000482 000504 00 ACS Cobol Cross Reference Xref v0.95.27 (04/01/2009@11:27) Dictionary Fi Unreferenced Working Storage Symbols buffer-flag 000177W data-field1 000193W data-field2 000194W data-field3 000197W data-record 000192W data-subfield1 000195W filter-flag 000138W hereflag 000155W ACS Cobol Cross Reference Xref v0.95.27 (04/01/2009@11:27) Dictionary Fi Unreferenced Procedures None @end verbatim @emph{CobXRef produces 132 column output by default and the commands used here limit the width to 72 characters in order to fit the FAQ file.} @node Does OpenCOBOL implement Report Writer? @subsection Does OpenCOBOL implement Report Writer? Not at this time. @emph{July@comma{} 2008} But it does support LINAGE. See `Does OpenCOBOL implement LINAGE?`_ @node Does OpenCOBOL implement LINAGE? @subsection Does OpenCOBOL implement LINAGE? Yes. LINAGE sets up logical pages inside file descriptors enhancing the WRITE operations and enabling the END-OF-PAGE clause. @quotation FILE SECTION. FD A-REPORT LINAGE IS 13 LINES TOP 2 FOOTING 2 BOTTOM 3. @end quotation LINAGE clauses can set: @verbatim TOP LINES FOOTING BOTTOM @end verbatim The LINAGE-COUNTER_ noun is maintained during writes to LINAGE output files. See LINAGE_ for a sample program. @node Does OpenCOBOL implement any Intrinsic FUNCTIONs? @subsection Does OpenCOBOL implement any Intrinsic FUNCTIONs? Yes@comma{} many. As of the July 2008 1.1 pre-release @verbatim ABS, ACOS, ANNUITY, ASIN, ATAN, BYTE-LENGTH, CHAR, CONCATENATE, COS, CURRENT-DATE, DATE-OF-INTEGER, DATE-TO-YYYYMMDD, DAY-OF-INTEGER, DAY-TO-YYYYDDD, E, EXCEPTION-FILE, EXCEPTION-LOCATION, EXCEPTION-STATEMENT, EXCEPTION-STATUS, EXP, EXP10, FACTORIAL, FRACTION-PART, INTEGER, INTEGER-OF-DATE, INTEGER-OF-DAY, INTEGER-PART, LENGTH, LOCALE-DATE, LOCALE-TIME, LOG, LOG10, LOWER-CASE, MAX, MEAN, MEDIAN, MIDRANGE, MIN, MOD, NUMVAL, NUMVAL-C, ORD, ORD-MAX, ORD-MIN, PI, PRESENT-VALUE, RANDOM, RANGE, REM, REVERSE, SECONDS-FROM-FORMATTED-TIME, SECONDS-PAST-MIDNIGHT, SIGN, SIN, SQRT, STANDARD-DEVIATION, STORED-CHAR-LENGTH, SUBSTITUTE, SUM, TAN, TEST-DATE-YYYYMMDD, TEST-DAY-YYYYMMDD, TRIM, UPPER-CASE, VARIANCE, WHEN-COMPILED, YEAR-TO-YYYY @end verbatim @menu * ABS:: * ACOS:: * ANNUITY:: * ASIN:: * ATAN:: * FUNCTION BYTE-LENGTH:: * CHAR:: * CONCATENATE:: * COS:: * CURRENT-DATE:: * DATE-OF-INTEGER:: * DATE-TO-YYYYMMDD:: * DAY-OF-INTEGER:: * DAY-TO-YYYYDDD:: * E:: * EXCEPTION-FILE:: * EXCEPTION-LOCATION:: * EXCEPTION-STATEMENT:: * EXCEPTION-STATUS:: * EXP:: * EXP10:: * FACTORIAL:: * FRACTION-PART:: * INTEGER:: * INTEGER-OF-DATE:: * INTEGER-OF-DAY:: * INTEGER-PART:: * FUNCTION LENGTH:: * FUNCTION LOCALE-DATE:: * LOCALE-TIME:: * LOG:: * LOG10:: * LOWER-CASE:: * MAX:: * MEAN:: * MEDIAN:: * MIDRANGE:: * MIN:: * MOD:: * NUMVAL:: * NUMVAL-C:: * ORD:: * ORD-MAX:: * ORD-MIN:: * PIx:: * PRESENT-VALUE:: * FUNCTION RANDOM:: * FUNCTION RANGE:: * REM:: * REVERSE:: * SECONDS-FROM-FORMATTED-TIME:: * SECONDS-PAST-MIDNIGHT:: * FUNCTION SIGN:: * SIN:: * SQRT:: * STANDARD-DEVIATION:: * STORED-CHAR-LENGTH:: * SUBSTITUTE:: * SUBSTITUTE-CASE:: * FUNCTION SUM:: * TAN:: * TEST-DATE-YYYYMMDD:: * TEST-DAY-YYYYMMDD:: * TRIM:: * UPPER-CASE:: * VARIANCE:: * WHEN-COMPILED:: * YEAR-TO-YYYY:: @end menu @node ABS @subsubsection ABS Absolute value of numeric argument @quotation DISPLAY FUNCTION ABS(DIFFERENCE). @end quotation @node ACOS @subsubsection ACOS The ACOS function returns a numeric value (in radians) that approximates the arccosine of the argument. The domain of the arccosine function is -1 to +1. Domain errors return a result of 0. The inverse cosine function returns a range of 0 thru |PISYM| @quotation DISPLAY FUNCTION ACOS(-1). @end quotation @node ANNUITY @subsubsection ANNUITY Compute the ratio of an annuity paid based on arguments of interest and number of periods. @quotation WORKING-STORAGE SECTION. 77 INTEREST PIC S9V9999 VALUE 0.08. 77 MONTHLY PIC S9V9999 VALUE ZERO. 77 PERIODS PIC 99 VALUE 36. 77 ANNUITY-VALUE PIC S9V9999 VALUE ZERO. PROCEDURE DIVISION. COMPUTE MONTHLY ROUNDED = INTEREST / 12 COMPUTE ANNUITY-VALUE ROUNDED = FUNCTION ANNUITY (MONTHLY PERIODS) DISPLAY "Monthly rate: " MONTHLY " Periods: " PERIODS " Annuity ratio: " ANNUITY-VALUE END-DISPLAY. @end quotation Outputs: @verbatim Monthly rate: +0.0067 Periods: 36 Annuity ratio: +0.0314 @end verbatim @node ASIN @subsubsection ASIN The ASIN function returns a numeric value (in radians) that approximates the arcsine of the argument. The domain of the arcsine function is -1 to +1. Domain errors return a result of 0. The inverse sine function returns a range of -|PISYM|/2 thru |PISYM|/2 @quotation DISPLAY FUNCTION ASIN(-1). @end quotation @node ATAN @subsubsection ATAN The ATAN function returns a numeric value (in radians) that approximates the arctangent of the argument. The domain of the arctangent function is all real numbers. The inverse tangent function returns a range of -|PISYM|/2 thru |PISYM|/2 @quotation DISPLAY FUNCTION ATAN(1). @end quotation @node FUNCTION BYTE-LENGTH @subsubsection FUNCTION BYTE-LENGTH The BYTE-LENGTH function returns an integer that is the internal storage length of the given argument. @quotation >>SOURCE FORMAT IS FIXED * Purpose: demonstrate intrinsic FUNCTION BYTE-LENGTH identification division. program-id. bytelength. data division. working-storage section. 01 char-var usage binary-char. 01 short-var usage binary-short. 01 long-var usage binary-long. 01 double-var usage binary-double. 01 num1-var pic 9. 01 num4-var pic 99v99. 01 num9-var pic s9(9). 01 num18-var pic s9(18). 01 num18c-var pic s9(18) usage comp. 01 num18p-var pic s9(18) usage comp-3. 01 edit-var pic $zzzz9.99. 01 string-var pic x(10) value "abc". 01 newline pic x value x'0a'. procedure division. display "num1-var len = " function byte-length(num1-var) newline "num4-var len = " function byte-length(num4-var) newline "num9-var len = " function byte-length(num9-var) newline "num18-var len = " function byte-length(num18-var) newline "num18c-var len = " function byte-length(num18c-var) newline "num18p-var len = " function byte-length(num18p-var) newline "edit-var len = " function byte-length(edit-var) newline @quotation "12 len = " function byte-length(12) newline "12.12 len = " function byte-length(12.12) newline "1234567890.123 = " function byte-length(1234567890.123) newline "string-var len = " function byte-length(string-var) newline "trim string = " function byte-length(function trim(string-var)) newline "char-var len = " function byte-length(char-var) newline "short-var len = " function byte-length(short-var) newline "long-var len = " function byte-length(long-var) newline "double-var len = " function byte-length(double-var) @end quotation end-display goback. exit program. @end quotation Outputs: @verbatim num1-var len = 1 num4-var len = 4 num9-var len = 9 num18-var len = 18 num18c-var len = 8 num18p-var len = 10 edit-var len = 9 12 len = 2 12.12 len = 4 1234567890.123 = 13 string-var len = 10 trim string = 00000003 char-var len = 1 short-var len = 2 long-var len = 4 double-var len = 8 @end verbatim @node CHAR @subsubsection CHAR The CHAR function returns a ONE character alphanumeric field whose value is the character in the current collating sequence having the ordinal position equal to the value of the integer argument. The argument must be greater than 0 and less than or equal to the number of positions in the collating sequence. Errors in the argument range return 0 (the LOW-VALUE by default). See ASCII_ or EBCDIC_ and details of the ALPHABET_ clause. @quotation DISPLAY FUNCTION CHAR(66). @end quotation Would output @strong{A} in the ASCII character set. Note this may be different than what some expect. OpenCOBOL CHAR is 1 thru 128 not 0 thru 127 as a C programmer may be used to. @emph{And to add a little confusion@comma{} most personal computers use an extended character set@comma{} usually erroneously called ASCII with a range of 0 to 255. A more appropriate name may be ISO-8859-1 Latin 1.} See ASCII_ for more accurate details. This author is often guilty of this misnomer of the use of the term ASCII. @node CONCATENATE @subsubsection CONCATENATE Concatenate the given fields. @node COS @subsubsection COS The COS function returns a numeric value that approximates the cosine of the argument (in radians). The domain of the cosine function is all real numbers@comma{} with a nominal domain of 0 thru |PISYM| with a zero returned at |PISYM|/2. The cosine function returns a range of -1 thru +1. @quotation DISPLAY FUNCTION COS(1.5707963267949). @end quotation @node CURRENT-DATE @subsubsection CURRENT-DATE Returns an alphanumeric field of length 21 with the current date@comma{} time and timezone information in the form YYYYMMDDhhmmsscc |plusminus| tznn @quotation DISPLAY FUNCTION CURRENT-DATE. @end quotation Example Output: @verbatim 2008080921243796-0400 @end verbatim @node DATE-OF-INTEGER @subsubsection DATE-OF-INTEGER Converts an integer date@comma{} days on the Gregorian since December 31 1600 to YYYYMMDD form @quotation DISPLAY DATE-OF-INTEGER(1) DISPLAY DATE-OF-INTEGER(50000) @end quotation Outputs: @verbatim 16010101 17371123 @end verbatim 50@comma{}000 days after December 31@comma{} 1600 being November 23rd@comma{} 1737. @node DATE-TO-YYYYMMDD @subsubsection DATE-TO-YYYYMMDD Converts a two digit year date format to four digit year form using a sliding window pivot of the optional second argument. The pivot defaults to 50. The OpenCOBOL implementation of DATE-TO-YYYYMMDD also accepts an optional third argument@comma{} replacing the default century value of 1900 and is treated as the years added to the given year portion of the first argument and modified by the sliding 100 window pivot. Domain errors occur for year values less than 1600 and greater than 999@comma{}999. There is no validation of the input date. Because of the sliding window@comma{} this function is dependent on the date of evaluation @quotation DISPLAY FUNCTION DATE-TO-YYYYMMDD(000101) DISPLAY FUNCTION DATE-TO-YYYYMMDD(500101) DISPLAY FUNCTION DATE-TO-YYYYMMDD(610101) DISPLAY FUNCTION DATE-TO-YYYYMMDD(990101) DISPLAY FUNCTION DATE-TO-YYYYMMDD(990101@comma{} 50@comma{} 1900) DISPLAY FUNCTION DATE-TO-YYYYMMDD(990101@comma{} -10@comma{} 1900) DISPLAY FUNCTION DATE-TO-YYYYMMDD(990101@comma{} 50@comma{} 2000) DISPLAY FUNCTION DATE-TO-YYYYMMDD(990101@comma{} 50@comma{} 2100) @end quotation When run in August@comma{} 2008 produces: @verbatim 20000101 20500101 19610101 19990101 18990101 17990101 19990101 20990101 @end verbatim @node DAY-OF-INTEGER @subsubsection DAY-OF-INTEGER Converts a Gregorian integer date form to Julian date form (YYYDDD) based on days since December 31@comma{} 1600. Errors return 0 @quotation DISPLAY FUNCTION DAY-OF-INTEGER(97336). 1867182 @end quotation 97@comma{}336 days after 16001231 being the 182nd day of the year 1867. Canada's date of Confederation and recognized birthday. @node DAY-TO-YYYYDDD @subsubsection DAY-TO-YYYYDDD Converts a Julian 2 digit year and three digit dat integer to a four digit year form. See DATE-TO-YYYYMMDD_ for some of the details of the calculations involved. @node E @subsubsection E @node EXCEPTION-FILE @subsubsection EXCEPTION-FILE This special-register holds the error number and name of the source file that caused an input output exception. See EXCEPTION-STATUS_ for an example. @node EXCEPTION-LOCATION @subsubsection EXCEPTION-LOCATION This special-register can be queried for the location of the last exception. See FUNCTION EXCEPTION-STATUS_ for example source code. Note: This feature requires compilation with @emph{-fsource-location} compiler switch. This option is also turned on with @emph{-g} debugging info compiles. Information includes PROGRAM-ID@comma{} section and source line. @node EXCEPTION-STATEMENT @subsubsection EXCEPTION-STATEMENT This special-register holds the statement that was executing when the latest exception was raised. See FUNCTION EXCEPTION-STATUS_ for an example. Note: This feature requires compilation with @emph{-fsource-location} compiler switch. This option is also turned on with @emph{-g} debugging info compiles. @node EXCEPTION-STATUS @subsubsection EXCEPTION-STATUS This FUNCTION returns the current exception status. The example below is courtesy of Roger While@comma{} from a post he made announcing the @emph{FUNCTION EXCEPTION-} features. Source format is free@comma{} compile with @emph{cobc -x -g -free except.cob} @quotation IDENTIFICATION DIVISION. PROGRAM-ID. MINIPROG. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. LINUX. OBJECT-COMPUTER. LINUX. SPECIAL-NAMES. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT PRINTFILE ASSIGN TO "XXRXWXX" FILE STATUS RXWSTAT. DATA DIVISION. FILE SECTION. FD PRINTFILE. 01 PRINTREC PIC X(132). WORKING-STORAGE SECTION. 01 RXWSTAT PIC XX. PROCEDURE DIVISION. A00-MAIN SECTION. 001-MAIN-PROCEDURE. OPEN INPUT PRINTFILE. DISPLAY "File Status: " RXWSTAT. DISPLAY "EXCEPTION-FILE: " FUNCTION EXCEPTION-FILE. DISPLAY "Return Length: " FUNCTION LENGTH (FUNCTION EXCEPTION-FILE). DISPLAY "EXCEPTION-STATUS: " FUNCTION EXCEPTION-STATUS. DISPLAY "EXCEPTION-STATEMENT: " FUNCTION EXCEPTION-STATEMENT. STRING "TOOLONG" DELIMITED SIZE INTO RXWSTAT. DISPLAY "EXCEPTION-STATUS: " FUNCTION EXCEPTION-STATUS. DISPLAY "EXCEPTION-STATEMENT: " FUNCTION EXCEPTION-STATEMENT. DISPLAY "EXCEPTION-LOCATION: " FUNCTION EXCEPTION-LOCATION. STOP RUN. @end quotation Example output: @verbatim File Status: 35 EXCEPTION-FILE: 35PRINTFILE Return Length: 00000011 EXCEPTION-STATUS: EC-I-O-PERMANENT-ERROR EXCEPTION-STATEMENT: OPEN EXCEPTION-STATUS: EC-OVERFLOW-STRING EXCEPTION-STATEMENT: STRING EXCEPTION-LOCATION: MINIPROG; 001-MAIN-PROCEDURE OF A00-MAIN; 29 @end verbatim @table @asis @item .. TIP:: See the source file libcob/exception.def for a list of the plethora of run-time exceptions supported by OpenCOBOL. @end table @node EXP @subsubsection EXP @node EXP10 @subsubsection EXP10 @node FACTORIAL @subsubsection FACTORIAL @node FRACTION-PART @subsubsection FRACTION-PART @node INTEGER @subsubsection INTEGER @node INTEGER-OF-DATE @subsubsection INTEGER-OF-DATE @node INTEGER-OF-DAY @subsubsection INTEGER-OF-DAY @node INTEGER-PART @subsubsection INTEGER-PART @node FUNCTION LENGTH @subsubsection FUNCTION LENGTH @node FUNCTION LOCALE-DATE @subsubsection FUNCTION LOCALE-DATE @node LOCALE-TIME @subsubsection LOCALE-TIME @node LOG @subsubsection LOG @node LOG10 @subsubsection LOG10 @node LOWER-CASE @subsubsection LOWER-CASE @node MAX @subsubsection MAX @node MEAN @subsubsection MEAN @node MEDIAN @subsubsection MEDIAN @node MIDRANGE @subsubsection MIDRANGE @node MIN @subsubsection MIN @node MOD @subsubsection MOD @node NUMVAL @subsubsection NUMVAL @node NUMVAL-C @subsubsection NUMVAL-C @node ORD @subsubsection ORD @node ORD-MAX @subsubsection ORD-MAX @node ORD-MIN @subsubsection ORD-MIN @node PIx @subsubsection PIx @node PRESENT-VALUE @subsubsection PRESENT-VALUE @node FUNCTION RANDOM @subsubsection FUNCTION RANDOM @node FUNCTION RANGE @subsubsection FUNCTION RANGE @node REM @subsubsection REM @node REVERSE @subsubsection REVERSE @node SECONDS-FROM-FORMATTED-TIME @subsubsection SECONDS-FROM-FORMATTED-TIME @node SECONDS-PAST-MIDNIGHT @subsubsection SECONDS-PAST-MIDNIGHT @node FUNCTION SIGN @subsubsection FUNCTION SIGN @node SIN @subsubsection SIN @node SQRT @subsubsection SQRT @node STANDARD-DEVIATION @subsubsection STANDARD-DEVIATION @node STORED-CHAR-LENGTH @subsubsection STORED-CHAR-LENGTH @node SUBSTITUTE @subsubsection SUBSTITUTE FUNCTION SUBSTITUTE is an OpenCOBOL extension to the suite of intrinsic functions. @quotation @table @asis @item DISPLAY @table @asis @item FUNCTION SUBSTITUTE("this is a test"@comma{} "this"@comma{} "that"@comma{} "is a"@comma{} "was"@comma{} "test"@comma{} "very cool!") @end table @end table END-DISPLAY @end quotation Will display: @verbatim that was very cool! @end verbatim having changed @emph{this} for @emph{that}@comma{} @emph{is a} for @emph{was} and @emph{test} with @strong{very cool!} The new intrinsic accepts: @verbatim SUBSTITUTE(subject, lit-pat-1, repl-1 [, litl-pat-2, repl-2, ...]) @end verbatim @emph{where lit-pat just means the scan is for literals@comma{} not that you have to use literal constants.} WORKING-STORAGE identifiers are fine for any of the subject@comma{} the search patterns or the replacements. As with all intrinsics@comma{} you receive a new field and the subject is untouched. @table @asis @item .. Attention:: The resulting field can be shorter@comma{} the same length or longer than the subject string. @end table This is literal character @strong{global} find and replace@comma{} and there are no wildcards or other pattern expressions. Unlike INSPECT@comma{} this function @strong{does not require same length} patterns and replacements. Each pattern replacement pair uses the original subject@comma{} not any intermediate in progress result. As this is an alphanumeric operation@comma{} a reference modification is also allowed @quotation MOVE FUNCTION SUBSTITUTE(subject@comma{} pat@comma{} repl)(2:4) TO xvar4 @end quotation to result in 4 characters starting at the second position after the substitution. @node SUBSTITUTE-CASE @subsubsection SUBSTITUTE-CASE Similar to SUBSTITUTE@comma{} but ignores upper and lower case of subject when matching patterns. @node FUNCTION SUM @subsubsection FUNCTION SUM @node TAN @subsubsection TAN @node TEST-DATE-YYYYMMDD @subsubsection TEST-DATE-YYYYMMDD @node TEST-DAY-YYYYMMDD @subsubsection TEST-DAY-YYYYMMDD @node TRIM @subsubsection TRIM @node UPPER-CASE @subsubsection UPPER-CASE Returns a copy of the alphanumeric argument with any lower case letters replaced by upper case letters. @node VARIANCE @subsubsection VARIANCE Returns the variance of a series of numbers. The variance is defined as the square of the `STANDARD-DEVIATION`_ @quotation DISPLAY FUNCTION VARIANCE(1 2 3 4 5 6 7 8 9 100) END-DISPLAY. @end quotation @verbatim +818.250000000000000 @end verbatim @node WHEN-COMPILED @subsubsection WHEN-COMPILED Returns a 21 character alphanumeric field of the form YYYYMMDDhhmmsscc |plusminus| zzzz e.g. 2008070505152000-0400 representing when a module or executable is compiled. The WHEN-COMPILED special register reflects when an object module was compiled @quotation program-id. whenpart1. procedure division. display "First part :" FUNCTION WHEN-COMPILED end-display. program-id. whenpart2. procedure division. display "Second part:" FUNCTION WHEN-COMPILED end-display. program-id. whenshow. procedure division. call "whenpart1" end-call. call "whenpart2" end-call. display "Main part :" FUNCTION WHEN-COMPILED end-display. @end quotation @quotation $ cobc -c whenpart1.cob && sleep 15 && cobc -c whenpart2.cob && > sleep 15 && cobc -x whenshow.cob whenpart1.o whenpart2.o $ ./whenshow @end quotation @verbatim First part :2008082721391500-0400 Second part:2008082721393000-0400 Main part :2008082721394500-0400 @end verbatim @node YEAR-TO-YYYY @subsubsection YEAR-TO-YYYY Converts a two digit year to a sliding window four digit year. The optional second argument (default 50) is added to the date at execution time to determine the ending year of a 100 year interval. @node Can you clarify the use of FUNCTION in OpenCOBOL? @subsection Can you clarify the use of FUNCTION in OpenCOBOL? Yes. This information is from [Roger]_@comma{} posted to the opencobol_ forums. @verbatim Just to clarify the use of FUNCTION. (Applies to 0.33) FUNCTION (generally speaking, there are exceptions) can be used anywhere where a source item is valid. It always results in a new temporary field. This will have the desired characteristics dependant on the parameters. eg. FUNCTION MIN (x, y, z) with x PIC 99 y PIC 9(8) COMP z PIC 9(6)V99 will result in returning a field that has at least 8 positions before the (implied) decimal point and 2 after. It does NOT ever change the contents of parameters to the function. FUNCTION's are nestable. eg. DISPLAY FUNCTION REVERSE (FUNCTION UPPER-CASE (myfield)). @end verbatim One clarification to the above quote was pointed out by Roger. The line: @verbatim be used anywhere where a source item is valid. @end verbatim should be: @verbatim be used anywhere where a sending field is valid. @end verbatim @node What is the difference between the LENGTH verb and FUNCTION LENGTH? @subsection What is the difference between the LENGTH verb and FUNCTION LENGTH? From [Roger]_: @verbatim The standard only defines FUNCTION LENGTH. The LENGTH OF phrase is an extension (from MF) @end verbatim @node What STOCK CALL LIBRARY does OpenCOBOL offer? @subsection What STOCK CALL LIBRARY does OpenCOBOL offer? OpenCOBOL 1.0 ships with quite a few callable features. See CALL_. Looking through the source code@comma{} you'll find the current list of service calls in: @verbatim libcob/system.def @end verbatim With the 1.1 pre-release of July 2008@comma{} that list included @quotation /* COB_SYSTEM_GEN (external name@comma{} number of parameters@comma{} internal name) */ COB_SYSTEM_GEN ("SYSTEM"@comma{} 1@comma{} SYSTEM) COB_SYSTEM_GEN ("CBL_ERROR_PROC"@comma{} 2@comma{} CBL_ERROR_PROC) COB_SYSTEM_GEN ("CBL_EXIT_PROC"@comma{} 2@comma{} CBL_EXIT_PROC) COB_SYSTEM_GEN ("CBL_OPEN_FILE"@comma{} 5@comma{} CBL_OPEN_FILE) COB_SYSTEM_GEN ("CBL_CREATE_FILE"@comma{} 5@comma{} CBL_CREATE_FILE) COB_SYSTEM_GEN ("CBL_READ_FILE"@comma{} 5@comma{} CBL_READ_FILE) COB_SYSTEM_GEN ("CBL_WRITE_FILE"@comma{} 5@comma{} CBL_WRITE_FILE) COB_SYSTEM_GEN ("CBL_CLOSE_FILE"@comma{} 1@comma{} CBL_CLOSE_FILE) COB_SYSTEM_GEN ("CBL_FLUSH_FILE"@comma{} 1@comma{} CBL_FLUSH_FILE) COB_SYSTEM_GEN ("CBL_DELETE_FILE"@comma{} 1@comma{} CBL_DELETE_FILE) COB_SYSTEM_GEN ("CBL_COPY_FILE"@comma{} 2@comma{} CBL_COPY_FILE) COB_SYSTEM_GEN ("CBL_CHECK_FILE_EXIST"@comma{} 2@comma{} CBL_CHECK_FILE_EXIST) COB_SYSTEM_GEN ("CBL_RENAME_FILE"@comma{} 2@comma{} CBL_RENAME_FILE) COB_SYSTEM_GEN ("CBL_GET_CURRENT_DIR"@comma{} 3@comma{} CBL_GET_CURRENT_DIR) COB_SYSTEM_GEN ("CBL_CHANGE_DIR"@comma{} 1@comma{} CBL_CHANGE_DIR) COB_SYSTEM_GEN ("CBL_CREATE_DIR"@comma{} 1@comma{} CBL_CREATE_DIR) COB_SYSTEM_GEN ("CBL_DELETE_DIR"@comma{} 1@comma{} CBL_DELETE_DIR) COB_SYSTEM_GEN ("CBL_AND"@comma{} 3@comma{} CBL_AND) COB_SYSTEM_GEN ("CBL_OR"@comma{} 3@comma{} CBL_OR) COB_SYSTEM_GEN ("CBL_NOR"@comma{} 3@comma{} CBL_NOR) COB_SYSTEM_GEN ("CBL_XOR"@comma{} 3@comma{} CBL_XOR) COB_SYSTEM_GEN ("CBL_IMP"@comma{} 3@comma{} CBL_IMP) COB_SYSTEM_GEN ("CBL_NIMP"@comma{} 3@comma{} CBL_NIMP) COB_SYSTEM_GEN ("CBL_EQ"@comma{} 3@comma{} CBL_EQ) COB_SYSTEM_GEN ("CBL_NOT"@comma{} 2@comma{} CBL_NOT) COB_SYSTEM_GEN ("CBL_TOUPPER"@comma{} 2@comma{} CBL_TOUPPER) COB_SYSTEM_GEN ("CBL_TOLOWER"@comma{} 2@comma{} CBL_TOLOWER) COB_SYSTEM_GEN ("364"@comma{} 2@comma{} CBL_XF4) COB_SYSTEM_GEN ("365"@comma{} 2@comma{} CBL_XF5) COB_SYSTEM_GEN ("221"@comma{} 2@comma{} CBL_X91) COB_SYSTEM_GEN ("C$NARG"@comma{} 1@comma{} cob_return_args) COB_SYSTEM_GEN ("C$PARAMSIZE"@comma{} 1@comma{} cob_parameter_size) COB_SYSTEM_GEN ("C$MAKEDIR"@comma{} 1@comma{} cob_acuw_mkdir) COB_SYSTEM_GEN ("C$CHDIR"@comma{} 2@comma{} cob_acuw_chdir) COB_SYSTEM_GEN ("C$SLEEP"@comma{} 1@comma{} cob_acuw_sleep) COB_SYSTEM_GEN ("C$COPY"@comma{} 3@comma{} cob_acuw_copyfile) COB_SYSTEM_GEN ("C$FILEINFO"@comma{} 2@comma{} cob_acuw_file_info) COB_SYSTEM_GEN ("C$DELETE"@comma{} 2@comma{} cob_acuw_file_delete) COB_SYSTEM_GEN ("C$TOUPPER"@comma{} 2@comma{} CBL_TOUPPER) COB_SYSTEM_GEN ("C$TOLOWER"@comma{} 2@comma{} CBL_TOLOWER) COB_SYSTEM_GEN ("C$JUSTIFY"@comma{} 1@comma{} cob_acuw_justify) COB_SYSTEM_GEN ("CBL_OC_NANOSLEEP"@comma{} 1@comma{} cob_oc_nanosleep) @end quotation Note the "SYSTEM". This CALL sends a command string to the shell. It acts as a wrapper to the standard C library "system" call. "SYSTEM" removes any trailing spaces from the argument and appends the null terminator required for the C library "system" call. While shell access opens yet another powerful door for the OpenCOBOL programmer@comma{} diligent delevopers will need to pay heed to cross platform issues when calling the operating system. This small gem of a help file was written up by Vincent Coen@comma{} included here for our benefit. @table @asis @item .. Attention:: This is a work in progress. If you see this attention box; the file is not yet deemed complete. @end table @verbatim System Calls v1.1.0 for OC v1.1 Author: Vincent B Coen dated 12/01/2009 COB_SYSTEM_GEN ("CBL_ERROR_PROC", 2, CBL_ERROR_PROC): Register error proc in Linux??? needs checking Roger? call using install-flag pic x comp-x Indicates operation to be performed (0 = install error procedure) (1 = un-install error procedure) install-addrs Usage procedure pointer Create by 'set install-addr to entry entry-name' (the address of error procedure to install or un-install) COB_SYSTEM_GEN ("CBL_EXIT_PROC", 2, CBL_EXIT_PROC) Register closedown proc call using install-flag pic x comp-x Indicate operation to be performed (0 = install closedown proc. with default priority of 64) (1 = un=install closedown proc.) (2 = query priority of installed proc.) (3 = install closedown proc. with given priority) install-param group item defined as: install-addr USAGE PROCEDURE POINTER (addr of closedown proc to install, uninstall or query) install-prty pic x comp-x (when install-flag = 3, priority of proc. being installed 0 - 127) returning status-code (See section key). on exit install-prty (when install-flag = 2, returns priority of selected proc.) COB_SYSTEM_GEN ("CBL_OPEN_FILE", 5, CBL_OPEN_FILE) Open byte stream file call using file-name pic x(n) space or null terminated access-mode pic x comp-5 (1 = read only, 2 = write only [deny must = 0] 3 = read / write) deny-mode pic x comp-5 (0 = deny both, 1 = deny write, 2 = deny read 3 = deny neither read nor write) device pic x comp-5 (must be zero) file-handle pic x(4) (Returns a file handle for a successful open) returning status-code (See section key) COB_SYSTEM_GEN ("CBL_CREATE_FILE", 5, CBL_CREATE_FILE) Create byte stream file call using file-name pic x(n) (space or null terminated) access-mode pic x comp-x (1 = read only) (2 = write only (deny must be 0) (3 = read / write) deny-mode pic x comp-x (0 = deny both read & write exclusive) (1 = deny write) (2 = deny read) (3 = deny neither read nor write) device pic x comp-x (must be zero) (reserved for future use) file-handle pic x(4) (Returns a file handle for a successful open) returning status-code (See section key) COB_SYSTEM_GEN ("CBL_READ_FILE", 5, CBL_READ_FILE) Read byte stream file call using file-handle pic x(4) (File handke returned when file opened) file-offset pic x(8) comp-x (offset in the file at which to read) (Max limit X"00FFFFFFFF") ?? byte-count pic x(4) comp-x (number of bytes to read. Poss limit x"00FFFF") flags pic x comp-x (0 = standard read, 128 = current file size returned in the file-offset field) buffer pic x(n) returning status-code (See section key) on exit: file-offset (Current file size on return if flags = 128 on entry) buffer pic x(n) (Buffer into which bytes are read. IT IS YOUR RESPONSIBILITY TO ENSURE THAT THE BUFFER IS LARGE ENOUGH TO HOLD ALL BYTES TO BE READ) Remarks: See Introduction to Byte Stream Routines as well as example code taken from old version of CobXref COB_SYSTEM_GEN ("CBL_WRITE_FILE", 5, CBL_WRITE_FILE) Write byte stream file call using file-handle pic x(4) (File handke returned when file opened) file-offset pic x(8) comp-x (offset in the file at which to write) (Max limit X"00FFFFFFFF") ?? byte-count pic x(4) comp-x (number of bytes to write. Poss limit x"00FFFF") Putting a value of zero here causes file to be trancated or extended to the size specified in file-offset) flags pic x comp-x (0 = standard write) buffer pic x(n) (Buffer into which bytes are writen from) returning status-code (See section key) Remarks: See Introduction to Byte Stream Routines as well as example code taken from old version of CobXref COB_SYSTEM_GEN ("CBL_CLOSE_FILE", 1, CBL_CLOSE_FILE) Close byte stream file call using file-handle pic x(4) on entry the file handle returned when file opened returning status-code (see section key) COB_SYSTEM_GEN ("CBL_FLUSH_FILE", 1, CBL_FLUSH_FILE) ?????????????? call using ??????? pic ???? No Idea COB_SYSTEM_GEN ("CBL_DELETE_FILE", 1, CBL_DELETE_FILE) Delete File call using file-name pic x(n) file to delete terminated by space can contain path. returning status-code COB_SYSTEM_GEN ("CBL_COPY_FILE", 2, CBL_COPY_FILE) Copy file call using file-name1 (pic x(n) File to copy, can contain path terniated by space file-name2 (pic x(n) File name of new file, can contain path termiated by space. For both, if no path current directory is assumed. returning status-code (see section key) COB_SYSTEM_GEN ("CBL_CHECK_FILE_EXIST", 2, CBL_CHECK_FILE_EXIST) Check if file exists & return details if it does Call using file-name file-details returning status-code file-name pic x(n) file-details Group item defined as: file-size pic x(8) comp-x file-date day pic x comp-x month pic x comp-x year pic xx comp-x file-time hours pic x comp-x minutes pic x comp-x seconds pic x comp-x hundredths pic x comp-x status-code see section key On entry: file-name The file to look for. name can cotain path and is terminated by a space If no path given current directory is assumed. On Exit: file-size Size if file in bytes file-date Date the file was created file-time Time file created COB_SYSTEM_GEN ("CBL_RENAME_FILE", 2, CBL_RENAME_FILE) Rename file call using old-file-name pic x(n) (file to rename can contain path terminated by space) new-file-name pic x(n) (new file name as above path must be same) returning status-code (see section key) COB_SYSTEM_GEN ("CBL_GET_CURRENT_DIR", 3, CBL_GET_CURRENT_DIR) Get details of current directory call using ??? pic x(n) ??? ??? pic x(n) ??? returning status-code (see section key) COB_SYSTEM_GEN ("CBL_CHANGE_DIR", 1, CBL_CHANGE_DIR) Change current directory Call using path-name pic x(n) (relative or absolute terminated by x"00") returning status-code (see section key) COB_SYSTEM_GEN ("CBL_CREATE_DIR", 1, CBL_CREATE_DIR) Create directory Call using path-name pic x(n) (relative or absolute path-name terminate by x"00") returning status-code (see section key) COB_SYSTEM_GEN ("CBL_DELETE_DIR", 1, CBL_DELETE_DIR) Delete directory Call using path-name pic x(n) (relative or absolute name terminated by space or null [x"00"]) returning status-code (see section key) COB_SYSTEM_GEN ("CBL_AND", 3, CBL_AND) logical AND Call using source (Any data item) target (Any data item) by value length (numeric literal or pic x(4) comp-5 returning status-code (see section key) COB_SYSTEM_GEN ("CBL_OR", 3, CBL_OR) logical OR call using source (Any data item) target (Any data item) by value length (numeric literal or pic x(4) comp-5 returning status-code (see section key) COB_SYSTEM_GEN ("CBL_NOR", 3, CBL_NOR) Logial Not OR ? Call using source (Any data item) target (Any data item) by value length (numeric literal or pic x(4) comp-5 returning status-code (see section key) COB_SYSTEM_GEN ("CBL_XOR", 3, CBL_XOR) logical eXclusive OR Call using source (Any data item) target (Any data item) by value length (numeric literal or pic x(4) comp-5 returning status-code (see section key) COB_SYSTEM_GEN ("CBL_IMP", 3, CBL_IMP) Logical IMPlies call using source Any data item target Any data Item by value length Nuneric literal or pic x(4) comp-5 returning status-code (see section key) COB_SYSTEM_GEN ("CBL_NIMP", 3, CBL_NIMP) Logical Not IMPlies call using source Any data item target Any data Item by value length Nuneric literal or pic x(4) comp-5 returning status-code (see section key) COB_SYSTEM_GEN ("CBL_EQ", 3, CBL_EQ) Logical EQUIVALENCE between bits of both items Call using source (Any data item) target (Any data item) by value length (numeric literal or pic x(4) comp-5 returning status-code (see section key) COB_SYSTEM_GEN ("CBL_NOT", 2, CBL_NOT) Logical NOT Call using target Any data item by value length numeric lit or pic x(4) comp-5 COB_SYSTEM_GEN ("CBL_TOUPPER", 2, CBL_TOUPPER) Convert a string to Upper case Call using string pic x(n) (The string to convert) by value length pic x(4) comp-5 (Number of bytes to change) returning status-code (see section key) COB_SYSTEM_GEN ("CBL_TOLOWER", 2, CBL_TOLOWER) Convert a string to Lower case Call using string pic x(n) (The string to convert) by value length pic x(4) comp-5 (Number of bytes to change) returning status-code (see section key) COB_SYSTEM_GEN ("\364", 2, CBL_XF4) COB_SYSTEM_GEN ("\365", 2, CBL_XF5) COB_SYSTEM_GEN ("\221", 2, CBL_X91) COB_SYSTEM_GEN ("C$NARG", 1, cob_return_args) COB_SYSTEM_GEN ("C$PARAMSIZE", 1, cob_parameter_size) COB_SYSTEM_GEN ("C$MAKEDIR", 1, cob_acuw_mkdir) COB_SYSTEM_GEN ("C$CHDIR", 2, cob_acuw_chdir) COB_SYSTEM_GEN ("C$SLEEP", 1, cob_acuw_sleep) COB_SYSTEM_GEN ("C$COPY", 3, cob_acuw_copyfile) COB_SYSTEM_GEN ("C$FILEINFO", 2, cob_acuw_file_info) COB_SYSTEM_GEN ("C$DELETE", 2, cob_acuw_file_delete) COB_SYSTEM_GEN ("C$TOUPPER", 2, CBL_TOUPPER) Convert string to upper case see cbl_toupper ??? COB_SYSTEM_GEN ("C$TOLOWER", 2, CBL_TOLOWER) Convert string to lower case see cbl_tolower ??? COB_SYSTEM_GEN ("C$JUSTIFY", 1, cob_acuw_justify) COB_SYSTEM_GEN ("CBL_OC_NANOSLEEP", 1, CBL_OC_NANOSLEEP) Key: Option Returning clause will allow all routine to return a value showing result of the operation. Zero = success and nonzero failure. If this field is omitted the value should be returned in the special register RETURN-CODE.. Note that status-code must be capable of holding posative values from 0 to 65535 ie, pic xx comp-5. @end verbatim And a sample program too @verbatim Introduction to Byte Streaming Routines. The byte stream file routines enable you to read, write data files without the need to adhere to Cobol record definitions. For all of these routines, if the routine is successful the RETURN-CODE register is set to zero. If it fails, the RETURN-CODE register contains a file status value which indicates the failure. This file status is always the standard ASNI '74 file status value. If no ANSI '74 file status is defined for the error, an extended error status is returned (9/nnn) where nnn is the runtime error number). MAYBE need to speak to Roger. <<<<<<<<<<<<<<<<<<<< An extract of a example of working Cobol code that shows usage of byte stream file handling @end verbatim @quotation 000100 Identification division. 000200 program-id. cobxref. ... ... 104000 01 File-Handle-Tables. 104100 03 filler occurs 0 to 99 104200 depending on Fht-Table-Size. 104300 05 Fht-File-Handle pic x(4). 104400 05 Fht-File-OffSet pic x(8) comp-x value zero. 104500 05 Fht-File-Size pic x(8) comp-x value zero. 104600 05 Fht-Block-OffSet pic x(8) comp-x value zero. 104700 05 Fht-Byte-Count pic x(4) comp-x value 4096. 104800 05 Fht-CopyRefNo2 pic 9(6) value zero. 104900 05 Fht-Pointer pic s9(5) comp value zero. 105000 05 Fht-Copy-Line-End pic s9(5) comp value zero. 105100 05 Fht-Copy-Words pic s9(5) comp value zero. 105200 05 Fht-sw-Eof pic 9 value zero. 105300 88 Fht-Eof value 1. 105400 05 Fht-Current-Rec pic x(160) value spaces. 105500 05 Fht-File-Name pic x(256). 105600 05 Fht-Buffer pic x(4097). 105700 05 filler pic x value x"FF". 105800 01 Fht-Table-Size pic s9(5) comp value zero. 105900* 106000 01 Cbl-File-Fields. 106100 03 Cbl-File-name pic x(256). 106200 03 Cbl-Access-Mode pic x comp-x value 1. 106300 03 Cbl-Deny-Mode pic x comp-x value 3. 106400 03 Cbl-Device pic x comp-x value zero. 106500 03 Cbl-Flags pic x comp-x value zero. 106600 03 Cbl-File-Handle pic x(4) value zero. 106700 03 Cbl-File-OffSet pic x(8) comp-x value zero. 106800* 106900 01 Cbl-File-Details. 107000 03 Cbl-File-Size pic x(8) comp-x value zero. 107100 03 Cbl-File-Date. 107200 05 Cbl-File-Day pic x comp-x value zero. 107300 05 Cbl-File-Mth pic x comp-x value zero. 107400 05 Cbl-File-Year pic x comp-x value zero. 107500 03 Cbl-File-time. 107600 05 Cbl-File-Hour pic x comp-x value zero. 107700 05 Cbl-File-Min pic x comp-x value zero. 107800 05 Cbl-File-Sec pic x comp-x value zero. 107900 05 Cbl-File-Hund pic x comp-x value zero. ... ... @strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@emph{*} * zz300@comma{} zz400@comma{} zz500 & zz600 all relate to copy files/libraries * via the COPY verb * As it is hoped to only use the filename.i via Open-Cobol * then this lot can be killed off as well as all the other related * code. * NOTE that the COPY verb is implemented in a very basic way despite * the fact that this code allows for 99 levels of COPY@comma{} eg@comma{} there is * NO replacing so hopefully I can remove it all after primary testing * When it is built into cobc * 356400 zz300-Open-File. 356500}}}}}}}} 356600* Open a Copy file using CBL-OPEN-File 356700* filename is using Cbl-File-name 356800* 356900 move zero to Return-Code. 357000 if Fht-Table-Size > 99 357100 move 24 to Return-Code 357200 display Msg11 357300 go to zz300-Exit. 357400* 357500* set up New entry in File Table 357600* 357700 add 1 to Fht-Table-Size. 357800 move Fht-Table-Size to e. 357900 move zeroes to Fht-File-OffSet (e) Fht-File-Size (e) 358000 Fht-File-Handle (e) Fht-Block-OffSet (e) 358100 Fht-CopyRefNo2 (e) Fht-sw-Eof (e) 358200 Fht-Copy-Line-End (e) Fht-Copy-Words (e). 358300 move 4096 to Fht-Byte-Count (e). 358400 move spaces to Fht-Current-Rec (e). 358500 move 1 to Fht-pointer (e). 358600* 358700 perform zz400-Check-File-Exists thru zz400-Exit. 358800 if Return-Code not = zero 358900 subtract 1 from Fht-Table-Size 359000 go to zz300-Exit. 359100* 359200 move Fht-Table-Size to e. 359300 move Cbl-File-Size to Fht-File-Size (e). 359400 move Cbl-File-name to Fht-File-Name (e). 359500 move 1 to Cbl-Access-Mode 359600 Cbl-Deny-Mode. 359700 move zero to Cbl-Device 359800 Cbl-File-Handle. 359900 move zero to Return-Code. 360000 call "CBL_OPEN_FILE" using 360100 Cbl-File-name 360200 Cbl-Access-Mode 360300 Cbl-Deny-Mode 360400 Cbl-Device 360500 Cbl-File-Handle. 360600 if Return-Code not = zero 360700 display Msg12 cbl-File-name 360800 display " This should not happen here" 360900 subtract 1 from Fht-Table-Size 361000 go to zz300-exit. 361100* 361200 move Cbl-File-Handle to Fht-File-Handle (e). 361300 add 1 to Copy-Depth. 361400 move 1 to sw-Copy. 361500 move zero to Fht-CopyRefNo2 (e) 361600 Return-Code. 362000 zz300-Exit. 362100 exit. 362200/ 362300 zz400-Check-File-Exists. 362400* 362500* check for correct filename and extention taken from COPY verb 362600* 362700* input : wsFoundNewWord2 362800* Output : Return-Code = 0 : Cbl-File-Details & Cbl-File-name 362900* Return-Code = 25 : failed fn in wsFoundNewWord2 363000* 363100 move zero to e. 363200 inspect wsFoundNewWord2 tallying e for all ".". 363300 if e not zero 363400 go to zz400-Try1. 363500 perform varying a from 1 by 1 until Return-Code = zero 363600 move 1 to e 363700 move spaces to Cbl-File-name 363800 string wsFoundNewWord2 delimited by space 363900 into Cbl-File-name pointer e 364000 string File-Ext (a) delimited by size 364100 into Cbl-File-name pointer e 364200 move zero to Return-Code 364300 call "CBL_CHECK_FILE_EXIST" using 364400 Cbl-File-name 364500 Cbl-File-Details 364600 end-call 364700 if Return-Code not = zero 364800 and a = 7 364900 exit perform 365000 end-if 365100 end-perform 365200 if Return-Code not = zero 365300 display "zz400A Check File exist err=" Return-Code 365400 display Msg13 wsFoundNewWord2 365500 move 25 to Return-Code 365600 go to zz400-Exit. 365700* ok file now found 365900 go to zz400-Exit. 366000* 366100 zz400-Try1. 366200 move wsFoundNewWord2 to Cbl-File-name. 366300 move zero to Return-Code. 366400 call "CBL_CHECK_FILE_EXIST" using 366500 Cbl-File-name 366600 Cbl-File-Details. 366700 if Return-Code not = zero 366800 move function lower-case (wsFoundNewWord2) to 366900 Cbl-File-name 367000 go to zz400-Try2. 367100* ok file now found 367200 go to zz400-exit. 367300* 367400 zz400-Try2. 367500 move zero to Return-Code. 367600 call "CBL_CHECK_FILE_EXIST" using 367700 Cbl-File-name 367800 Cbl-File-Details. 367900 if Return-Code not = zero 368000 display "zz400C Check File exist err=" Return-Code 368100 display Msg13 wsFoundNewWord2 " or " Cbl-File-name 368200 move 25 to Return-Code 368300 go to zz400-Exit. 368400* 368500* ok file now found 368600* 368700 zz400-Exit. 368800 exit. 368900/ 369000 zz500-Close-File. 369100 call "CBL_CLOSE_FILE" using 369200 Fht-File-Handle (Fht-Table-Size). 369300 if Return-Code not = zero 369400 display Msg14 369500 Cbl-File-name. 369800 subtract 1 from Fht-Table-Size. 369900* 370000 if Fht-Table-Size = zero 370100 move zero to sw-Copy. 370200 subtract 1 from Copy-Depth. 370300 move zero to Return-Code. 370400 go to zz500-Exit. 370500* 370600 zz500-Exit. 370700 exit. 370800/ 370900 zz600-Read-File. 371000}}}}}}}} 371100* called using file-handle 371200* returning CopySourceRecin1 size 160 chars 371300* If buffer enpty read a block 371400* and regardless@comma{} move record terminated by x"0a" 371500* to Fht-Current-Rec (Fht-Table-Size) 371600* 371700 if Fht-Eof (Fht-Table-Size) 371800 perform zz500-Close-File 371900 go to zz600-Exit. 372000* 372100 if Fht-File-OffSet (Fht-Table-Size) = zero 372200 and Fht-Block-OffSet (Fht-Table-Size) = zero 372300 perform zz600-Read-A-Block 372400 go to zz600-Get-A-Record. 372500* 372600 zz600-Get-A-Record. 372700}}}}}}}}}* 372800* Now to extract a record from buffer and if needed read a block 372900* then extract 373000* 373100 move spaces to Fht-Current-Rec (Fht-Table-Size). 373200 add 1 to Fht-Block-OffSet (Fht-Table-Size) giving g. 373300* 373400* note size is buffer size + 2 373500* 373600 unstring Fht-Buffer (Fht-Table-Size) (1:4097) 373700 delimited by x"0A" or x"FF" 373800 into Fht-Current-Rec (Fht-Table-Size) 373900 delimiter Word-Delimit3 374000 pointer g. 374100* 374200* Get next Block of data ? 374300* 374400 if Word-Delimit3 = x"FF" 374500 and g not < 4097 374600 add Fht-Block-OffSet (Fht-Table-Size) 374700 to Fht-File-OffSet (Fht-Table-Size) 374800 perform zz600-Read-A-Block 374900 go to zz600-Get-A-Record. 375000* EOF? 375100 move 1 to Fht-Pointer (Fht-Table-Size). 375200 if Word-Delimit3 = x"FF" 375300 move 1 to Fht-sw-Eof (Fht-Table-Size) 375400 go to zz600-Exit. 375500* Now so tidy up 375600 subtract 1 from g giving Fht-Block-OffSet (Fht-Table-Size). 375700 go to zz600-exit. 375800* 375900 zz600-Read-A-Block.}}}}}}}}@emph{@emph{* 376000 move all x"FF" to Fht-Buffer (Fht-Table-Size). 376100} if Fht-File-Size (Fht-Table-Size) < 4096 and not = zero 376200} move Fht-File-Size (Fht-Table-Size) 376300* to Fht-Byte-Count (Fht-Table-Size). 376400 call "CBL_READ_FILE" using 376500 Fht-File-Handle (Fht-Table-Size) 376600 Fht-File-OffSet (Fht-Table-Size) 376700 Fht-Byte-Count (Fht-Table-Size) 376800 Cbl-Flags 376900 Fht-Buffer (Fht-Table-Size). 377000 if Return-Code not = zero 377100 display Msg15 Return-Code 377200 go to zz600-Exit. 377300* just in case all ff does not work 377400 move x"FF" to Fht-Buffer (Fht-Table-Size) (4097:1). 377500 move zero to Fht-Block-OffSet (Fht-Table-Size). 377600 subtract Fht-Byte-Count (Fht-Table-Size) 377700 from Fht-File-Size (Fht-Table-Size). 377800 zz600-Exit. 377900 exit. @end quotation @node What are the XF4 XF5 and X91 routines? @subsection What are the XF4@comma{} XF5@comma{} and X91 routines? From opencobol.org_ @verbatim The CALL's X"F4", X"F5", X"91" are from MF. You can find them in the online MF doc under Library Routines. F4/F5 are for packing/unpacking bits from/to bytes. 91 is a multi-use call. Implemented are the subfunctions get/set cobol switches (11, 12) and get number of call params (16). Roger @end verbatim Use @quotation @table @asis @item CALL X"F4" USING BYTE-VAR ARRAY-VAR @end table @quotation RETURNING STATUS-VAR @end quotation @end quotation to pack the last bit of each byte in the 8 byte ARRAY-VAR into corresponding bits of the 1 byte BYTE-VAR. The X"F5" routine takes the eight bits of byte and moves them to the corresponding occurrence within array. X"91" is a multi-function routine. @quotation @table @asis @item CALL X"91" USING RESULT-VAR FUNCTION-NUM PARAMETER-VAR @end table @quotation RETURNING STATUS-VAR @end quotation @end quotation As mentioned by Roger@comma{} OpenCOBOL supports FUNCTION-NUM of 11@comma{} 12 and 16. 11 and 12 get and set the on off status of the 8 (eight) run-time OpenCOBOL switches definable in the SPECIAL-NAMES_ paragraph. @node What is CBL_OC_NANOSLEEP OpenCOBOL library routine? @subsection What is CBL_OC_NANOSLEEP OpenCOBOL library routine? CBL_OC_NANOSLEEP allows (upto) nanosecond sleep timing. It accepts a 64 bit integer value which may be in character or numeric data forms. @quotation @table @asis @item CALL "CBL_OC_NANOSLEEP" USING 500000000 RETURNING STATUS @end table END-CALL @end quotation Would wait one-half second. @emph{It may be easier to grok if the source code uses string catenation; "500" & "000000" for example.} @node Can I run background processes using OpenCOBOL? @subsection Can I run background processes using OpenCOBOL? Absolutely. Using the CALL "C$SYSTEM" service. Some care must be shown to properly detach the input output handles@comma{} and to instruct the processes to ignore hangup signals along with the "run in a background subshell" control. @quotation @table @asis @item CALL "C$SYSTEM" @table @asis @item USING "nohup whatever 0mystdout 2>mystderr &" @end table RETURNING result @end table END-CALL @end quotation runs @strong{whatever} in the background@comma{} detaches stdin@comma{} sends standard output to the file @strong{mystdout} and standard error to @strong{mystderr}. @emph{The above example is for POSIX shell operating systems. As always@comma{} the commands sent through C$SYSTEM are VERY operating system dependent.} @node Can I use ctags with OpenCOBOL? @subsection Can I use ctags with OpenCOBOL? Yes. Use the Exuberant version of ctags. Exuberant ctags recognizes COBOL@comma{} producing a TAGS or tags file suitable for @strong{emacs}@comma{} @strong{vi}@comma{} @strong{nedit} and other editors that support the ctags format. @emph{ctags@comma{} by default@comma{} only supports the competition@comma{} C and Fortran.} After running ctags program.cob @quotation $ vi -t WORKING-STORAGE @end quotation will open program.cob and start at the line defining the working-storage section. Note: tags are case-sensitive and for larger projects@comma{} the above vi command would start an edit of the @emph{first} file with an occurrence of WORKING-STORAGE found in the tags. @node What about debugging OpenCOBOL programs? @subsection What about debugging OpenCOBOL programs? OpenCOBOL internal runtime checks are enabled with @strong{-debug}. Support for tracing is enabled with @strong{-ftrace} and @strong{-ftraceall}. Source line location is enabled with @strong{-fsource-location}. Activation of FIXED format @strong{D} indicator debug lines is enabled with @strong{-fdebugging-line}. In FREE format@comma{} @strong{>>D} can be used anywhere on a line. See `Does OpenCOBOL support D indicator debug lines?`_. @strong{-fstack-check} will perform stack checking when @strong{-debug} or @strong{-g} is used. @strong{-fsyntax-only} will ask the compiler to only check for syntax errors@comma{} and not emit any output. To view the intermediate files that are generated@comma{} using @strong{-C} will produce the .c source files and any .c.l.h and c.h header files. @strong{-save-temps[=dir]} will leave all intermediate files in the current directory or the optional directory specified@comma{} including .i files that are the COBOL sources after COPY processing. Support for gdb_ is enabled with @strong{-g}. @verbatim $ gdb hello GNU gdb 6.7.1-debian Copyright (C) 2007 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i486-linux-gnu"... Using host libthread_db library "/lib/i686/cmov/libthread_db.so.1". (gdb) break 106 Breakpoint 1 at 0xOBFUSCA: file hello.c, line 106. (gdb) break 109 Breakpoint 2 at 0xTETHESY: file hello.c, line 109. (gdb) run Starting program: /home/brian/writing/cobol/hello [Thread debugging using libthread_db enabled] [New Thread 0xSTEMADDR (LWP 5782)] [Switching to Thread 0xESSES6b0 (LWP 5782)] Breakpoint 1, hello_ (entry=0) at hello.c:106 106 cob_new_display (0, 1, 1, &c_1); (gdb) cont Continuing. Hello World! Breakpoint 2, hello_ (entry=0) at hello.c:109 109 cob_set_location ("hello", "hello.cob", 6, "MAIN SECTION", "MAIN PARAGRAPH", "STOP"); (gdb) cont Continuing. Program exited normally. (gdb) @end verbatim Setting a break at line 106 and 109 was found by a quick look through the C code from @strong{$ cobc -C hello.cob} and seeing where the DISPLAY call and STOP RUN was located. Note: just because; the gdb displayed addresses were obfuscated from this listing. @menu * Some debugging tricks:: @end menu @node Some debugging tricks @subsubsection Some debugging tricks From [human]_ on opencobol.org: If you want to have different outputs in debug / normal mode use a fake if 1 = 1 like @quotation D IF 1 = 1 D DISPLAY "Debug Line" END-DISPLAY D ELSE DISPLAY "Normal Line" END-DISPLAY D END-IF @end quotation For using the environment Just define @quotation @table @asis @item 01 debugmode pic x. 88 debugmode-on values 'O'@comma{} 'Y'@comma{} 'J'@comma{} 'o'@comma{} 'y'@comma{} 'j'@comma{} '1'. @end table @end quotation put an @quotation accept debugmode from Environment "DEBUGMODE" end-accept @end quotation at the beginning of each program (or define debugmode as external) and use it in your programs like @quotation @table @asis @item IF debugmode-on DISPLAY "Debug Line" END-DISPLAY @item ELSE DISPLAY "Normal Line" END-DISPLAY @end table END-IF @end quotation For having no debug code in runtime you can combine these two @quotation D 01 debugmode pic x. D 88 debugmode-on values 'O'@comma{} 'Y'@comma{} 'J'@comma{} 'o'@comma{} 'y'@comma{} 'j'@comma{} '1'. ... D accept debugmode from Environment "DEBUGMODE" D end-accept ... D IF debugmode-on D DISPLAY "Debug Line" END-DISPLAY D ELSE DISPLAY "Normal Line" END-DISPLAY D END-IF @end quotation In this way you have fast code at runtime (if not compiled with -fdebugging-line) and can switch the output during development. The advantages over a compiler switch to disable the displays are: @itemize @item You can always use display in your program@comma{} not only for debug information. @item You see in the code what you do. @item If compiled with lines that have 'D' indicator you can switch at runtime. @item If compiled without lines that have 'D' indicator you can have faster and smaller modules. @end itemize @node Is there a C interface to OpenCOBOL? @subsection Is there a C interface to OpenCOBOL? Most definitely. See @uref{http://www.opencobol.org/modules/bwiki/index.php?cmd=read&page=UserManual%2F2_3#content_1_0,http://www.opencobol.org/modules/bwiki/index.php?cmd=read&page=UserManual%2F2_3#content_1_0} for details. @node What are some idioms for dealing with C char * data from OpenCOBOL? @subsection What are some idioms for dealing with C char * data from OpenCOBOL? @emph{Thanks to Frank Swarbrick for pointing these idioms out} To add or remove a null terminator@comma{} use the STRING verb. For example @quotation @table @asis @item * Add a null for calling C @table @asis @item STRING current-url DELIMITED BY SPACE X"00" DELIMITED BY SIZE INTO display-url @end table MOVE display-url TO current-url @item * Remove a null for display @table @asis @item STRING current-url DELIMITED BY LOW-VALUE INTO display-url. @end table @end table @end quotation Or to make changes in place @quotation @table @asis @item * Change nulls to spaces @table @asis @item INSPECT current-url REPLACING ALL X"00" WITH SPACE. @end table @end table @end quotation Or there is also modified references in OpenCOBOL @quotation @itemize @item Assume IND is the first trailing space (or picture limit). @item Note: OpenCOBOL auto initializes working-storage to SPACES or ZEROES @item depending on numeric or non-numeric pictures. @end itemize @table @asis @item * Remove null MOVE SPACE TO current-url(IND:1). @item * Add a zero terminator MOVE X"00" TO current-url(IND:1). @end table @end quotation [Roger]_ While points out: @emph{X"00" is almost always interchangeable with LOW-VALUE}. In all of the above snippets@comma{} the source code X"00" can be replaced by the COBOL noun @strong{LOW-VALUE} or @emph{LOW-VALUES}. @emph{Except when a program collating sequence is active and where the first character is not X"00"}. @table @asis @item .. Note to maintainers. The section below is just wrong. BASED is a different thing altogether and simply means the item does not have any permanent storage area. Entry commented out until corrected. @end table .. .. * Create a BASED allocation .. WORKING-STORAGE SECTION. .. 01 current-url PIC X(80) BASED. .. .. This may be a cleaner solution than:: .. .. LINKAGE SECTION. .. 01 current-url PIC X(80). .. .. And a SET ADDRESS OF CARG ... sequence. With the CALL verb@comma{} use ADDRESS OF and/or BY REFERENCE @quotation CALL "CFUNCTION" USING BY REFERENCE ADDRESS OF current-url. @end quotation The above being equivalent to char** in C. COBOL@comma{} by it's nature@comma{} passes all arguments by reference. That can be overridden with the @strong{BY VALUE} clause and the @strong{BY CONTENT} clause. @node Does OpenCOBOL support COPY includes? @subsection Does OpenCOBOL support COPY includes? Yes. COPY is fully supported@comma{} all variations from the standards up to and including the proposed 2008 standards. The @strong{-I} compiler option influences the copybook search path and @strong{-E} can be used to examine the @emph{after} COPY preprocessor output. There is also @strong{-ffold-copy-upper} and @strong{-ffold-copy-lower} compiler controls. @node Does OpenCOBOL support WHEN-COMPILED? @subsection Does OpenCOBOL support WHEN-COMPILED? Both as a noun and as an intrinsic function. @quotation DISPLAY WHEN-COMPILED. DISPLAY FUNCTION WHEN-COMPILED. 07/05/0805.15.20 2008070505152000-0400 @end quotation Note: The noun WHEN-COMPILED is non-standard and was deemed obsolete in the pre 85 standard. @node What is PI in OpenCOBOL? @subsection What is PI in OpenCOBOL? With OpenCOBOL 1.1 @quotation DISPLAY FUNCTION PI. 3.1415926535897932384626433832795029 DISPLAY FUNCTION E. 2.7182818284590452353602874713526625 @end quotation Thats 34 digits after the decimal. Developers that need to know the tolerances for use in calculations are directed to poke around the freely available source code@comma{} and to read up on GMP_. @node Does OpenCOBOL support the Object features of the 2002 standard? @subsection Does OpenCOBOL support the Object features of the 2002 standard? Not yet. @emph{July 2008} @node Does OpenCOBOL implement PICTURE 78? @subsection Does OpenCOBOL implement PICTURE 78? Yes. PICTURE 78 clauses can be used for constants@comma{} translated at compile time. This common non-standard extension is supported in OpenCOBOL. @node Does OpenCOBOL implement CONSTANT? @subsection Does OpenCOBOL implement CONSTANT? Current OC 1.1 has preliminary support for a subset of the standard conforming "CONSTANT" phrase. eg @quotation 01 @ MYCONST CONSTANT AS 1. @end quotation Note: there is a syntax difference between 78 and CONSTANT. @node What source formats are accepted by OpenCOBOL? @subsection What source formats are accepted by OpenCOBOL? Both FIXED and FREE COBOL source formats are supported. FIXED format follows the 1-6@comma{} 7@comma{} 8-72 special columns of the COBOL standards. The compiler directives: @verbatim Column 12345678901234567890 >>SOURCE FORMAT IS FREE >>SOURCE FORMAT IS FIXED @end verbatim can be used. The directive must occur at column 8 or beyond if the ACTIVE scan format is FIXED. As per the 2002 standard this directive can be used to switch formats multiple times within a compilation unit. Continuation indicators in column 7 are not applicable to FREE format and are not supported in this mode of translation. String catenation can always be used; the @strong{&} operator. The special *> @emph{till end of line} comment is supported in both FREE and FIXED forms@comma{} but by necessity will need to be placed at column 7 or greater in FIXED format sources. @table @asis @item .. Note to readers. The comment operator is *> the backslash is for ReST @end table The @strong{-free} and @strong{-fixed} options to @strong{cobc} also influence the expected source formats@comma{} with the default being mandated by the standards as FIXED. @node Does OpenCOBOL support continuation lines? @subsection Does OpenCOBOL support continuation lines? Yes. A dash @strong{-} in column 7 can be used for continuation lines. But@comma{} by necessity continuation lines only apply in FIXED format source code. FREE format COBOL does not support continuation as there is no real meaning to @emph{column 7} in FREE form source. Note that in this example there is no terminating quote on the string continuations@comma{} but there is an extra starting quote following the dash @quotation @table @asis @item 123456789012345678901234567890123456789012345678901234567890123456789012 identification division. program-id. longcont. data division. working-storage section. 01 longstr pic X(80) value "This will all be one string in FIXED forma @item -"t source code". 01 otherstr pic X(148) value "this @item -"string will have spaces between the words THIS and STRING@comma{} as @table @asis @item -"continuation lines always fill to column 72.". procedure division. display longstr. display length longstr. display function length(function trim(longstr trailing)). display otherstr(1:72). display otherstr(73:75). display length otherstr. display function length(function trim(otherstr trailing)). goback. @end table @end table @end quotation @quotation $ cobc longcont.cob $ cobcrun longcont @end quotation @verbatim This will all be one string in FIXED format source code 80 00000055 this string will have spaces between the words THIS and STRING, as continuation lines always fill to column 72. 148 00000139 @end verbatim @emph{Note: The DISPLAY of} @strong{otherstr} @emph{was split to avoid any wide browser scrolling@comma{} not for any COBOL reasons.} @emph{Also note that the rules for continuation lines are quite difficult to describe simply and concerned OpenCOBOL programmers are urged to read through the standards documents for full details.} @node Does OpenCOBOL support string concatenation? @subsection Does OpenCOBOL support string concatenation? Absolutely. Sources that need long strings@comma{} or those wishing to enhance source code readability@comma{} can use the @strong{&} operator @quotation identification division. program-id. longstr. data division. working-storage section. 01 longstr pic X(80) value "This " & "will " & "all " & "be " & "one " & "string " & "in both FIXED and FREE" & " format source code". procedure division. display longstr. goback. @end quotation Run this with @quotation $ cobc longstr.cob $ cobcrun longstr This will all be one string in both FIXED and FREE format source code $ cobc -free longstr.cob $ cobcrun longstr This will all be one string in both FIXED and FREE format source code @end quotation @node Does OpenCOBOL support D indicator debug lines? @subsection Does OpenCOBOL support D indicator debug lines? Yes@comma{} in two forms. As for continuation lines@comma{} column 7 has no meaning for SOURCE FORMAT IS FREE source code so the standard @strong{D} in column 7 can not be used. FORMAT FREE source code can use the @strong{>>D} compiler directive instead. Use @strong{D} lines as a conditional include of a source code line. These debug lines will only be compiled if the @emph{-fdebugging-line} compiler switch is used. From human on opencobol.org_ @verbatim If you put a D in column 7 OC handles this as a comment. These lines are only compiled if you run cobc with -fdebugging-line. By using this you can put some test messages etc. into your program that are only used if necessary (and therefore build with -fdebugging-line). @end verbatim OpenCOBOL also supports a @strong{>>D} debug compile time directive and a handy trick for those that like to write code that be compiled in both FIXED and FREE forms@comma{} is to place the directive in column 5@comma{} 6 and 7. @verbatim Column 12345678901234567890 DISPLAY "Normal Line" END-DISPLAY >>DDISPLAY "Debug Line" END-DISPLAY @end verbatim This allows use of the directive form in FORMAT FREE and also@comma{} with the @strong{D} in column 7@comma{} will compile properly in FORMAT FIXED. In FORMAT FIXED the @strong{>>} in columns 5 and 6 will be ignored as part of the @emph{sequence number} field. For more information on debugging support see `What about debugging OpenCOBOL programs?`_ @node Does OpenCOBOL support mixed case source code? @subsection Does OpenCOBOL support mixed case source code? Absolutely@comma{} kind of. Mixed case and mixed format@comma{} ASCII_ and EBCDIC_. Most COBOL compilers have not required uppercase only source code for quite a few years now. Still@comma{} most COBOL compilers including OpenCOBOL folds parts of the source to uppercase @emph{with certain rules} before translating. The compiler is case insensitive to names @quotation 000100 identification division. 000200 program-id. mixcase. 000300 data division. 000400 working-storage section. 000500 01 SOMEUPPER pic x(9). 000600 01 SomeUpper pic x(9). 000700 01 someupper pic x(9). 000800 000900 procedure division. 001000 move "SOMEUPPER" to SOMEUPPER. 001100 move "SomeUpper" to SomeUpper. 001200 move "someupper" to someupper. 001300 display "SOMEUPPER: " SOMEUPPER end-display. 001400 display "SomeUpper: " SomeUpper end-display. 001500 display "someupper: " someupper end-display. 001600 stop run. @end quotation @quotation $ cobc -x mixcase.cob @end quotation @verbatim mixcase.cob:10: Error: 'SOMEUPPER' ambiguous; need qualification mixcase.cob:5: Error: 'SOMEUPPER' defined here mixcase.cob:6: Error: 'SOMEUPPER' defined here mixcase.cob:7: Error: 'SOMEUPPER' defined here @end verbatim Note; that although the folded declarations conflict@comma{} the DISPLAY quoted strings will NOT be folded@comma{} and would display as expected. @emph{Case sensitivity is also at the mercy of operating system conventions}. Under GNU/Linux@comma{} OpenCOBOL's dynamic link loader is case sensitive. @quotation CALL "C$JUSTIFY" USING center-string "C" END-CALL. @end quotation is not the same as @quotation CALL "c$justify" USING center-string "C" END-CALL. @end quotation In support of case folding and COPY libraries@comma{} OpenCOBOL supports @emph{-ffold-copy-lower} and @emph{-ffold-copy-upper}. For mixing and matching legacy sources. @table @asis @item Trivia The expressions @emph{uppercase} and @emph{lowercase} date back to early moveable type. Typographers would keep two cases of metal casted letters@comma{} Capitalized and normal. Usually set on stacked shelves over the workbench. The small letters@comma{} being used more frequently@comma{} ended up on the lower shelf; the lower case letters. @end table @node What is the shortest OpenCOBOL program? @subsection What is the shortest OpenCOBOL program? All that is needed is a program-id. Doesn't do much. @quotation program-id. a. @end quotation @node What is the shortest Hello World program in OpenCOBOL? @subsection What is the shortest Hello World program in OpenCOBOL? A short version of OpenCOBOL hello world@comma{} compiled -free @quotation program-id.hello.procedure division.display "Hello World!". @end quotation Thanks to human and the opencobol.org_ forums. @emph{Please note:} This is @strong{not good} COBOL form@comma{} and is only shown as an example of the possibilities. @node How do I get those nifty sequential sequence numbers in a source file? @subsection How do I get those nifty sequential sequence numbers in a source file? FIXED format COBOL uses the first 6 positions of each line as a programmer defined @strong{sequence} field. This field is stripped as part of the preprocessing and is not validated. Historically@comma{} the sequence numbers were used to verify that card punch cards were read into a card reader in the proper order. Many legacy COBOL programs have sequentially numbered sequence values. Here is a little @strong{vi} trick to renumber the sequence field by 100s. Given @quotation 000005* HELLO.COB OpenCOBOL FAQ example 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. hello. 000030 PROCEDURE DIVISION. 000040 DISPLAY "Hello World!". 000100 STOP RUN. @end quotation Running the following @strong{ex} filter @quotation :%!perl -ne 'printf("\%06d\%s\n"@comma{} $. * 100@comma{} substr($_@comma{} 6@comma{} -1));' @end quotation @table @asis @item .. Note to readers of the plain text of this FAQ. ReStructuredText uses backslash to escape certain features. That line is actually :%!perl -ne 'printf("%06d%sn"@comma{} $. * 100@comma{} substr($_@comma{} 6@comma{} -1));' @end table produces a nicely resequenced source file. @quotation 000100* HELLO.COB OpenCOBOL FAQ example 000200 IDENTIFICATION DIVISION. 000300 PROGRAM-ID. hello. 000400 PROCEDURE DIVISION. 000500 DISPLAY "Hello World!". 000600 STOP RUN. @end quotation @itemize @item Note: Only use this on already FIXED form source. If used on any FREE format COBOL@comma{} the first 6 columns will be damaged. @end itemize This has no effect on the compilation process@comma{} it only effects the appearance of the sources. @table @asis @item .. Attention:: Be careful not to confuse SEQUENCE NUMBERS with source code LINE NUMBERS. They are not the same. @end table @itemize @item Vim: For users of the Vim editor@comma{} the command @end itemize @verbatim :set number @end verbatim will display the number of each source line. Many editors support the display of line numbers. Even @quotation $ less -N @end quotation can be used to display line numbers of its input. @node Is there a way to count trailing spaces in data fields using OpenCOBOL? @subsection Is there a way to count trailing spaces in data fields using OpenCOBOL? Yes. Quite a few. But instead of resorting to a PERFORM VARYING sequence try @quotation 01 B-COUNT PIC 999 VALUE 0. 01 TEST-CASE PIC X(80) VALUE "This is my string.". @table @asis @item ONE-WAY. @table @asis @item INSPECT FUNCTION REVERSE(TEST-CASE) TALLYING B-COUNT FOR LEADING ' '. @end table DISPLAY B-COUNT. @item TWO-WAY. @table @asis @item INSPECT TEST-CASE TALLYING B-COUNT FOR TRAILING SPACE. @end table DISPLAY B-COUNT. @item THREE-WAY. @table @asis @item IF TEST-CASE EQUAL SPACES COMPUTE B-COUNT = LENGTH OF TEST-CASE @item ELSE @table @asis @item COMPUTE @table @asis @item B-COUNT = LENGTH TEST-CASE - FUNCTION LENGTH(FUNCTION TRIM(TEST-CASE TRAILING)) @end table @end table END-COMPUTE @end table END-IF DISPLAY B-COUNT. @end table @end quotation produces: @verbatim 062 124 062 @end verbatim The second value is 124 as TWO-WAY accumulates another 62 after ONE-WAY. The INSPECT verb does not initialize a TALLYING variable. Information modified from opencobol.org_ forum post. @node Is there a way to left justify an edited numeric field? @subsection Is there a way to left justify an edited numeric field? Yes@comma{} a couple of ways. Assuming a working storage of @quotation 01 mynumber PIC 9(8) VALUE 123. 01 myedit PIC Z(7)9. 01 mychars PIC X(8). 01 spcount PIC 99 USAGE COMPUTATIONAL. MOVE mynumber TO myedit MOVE myedit TO mychars DISPLAY mynumber END-DISPLAY DISPLAY myedit END-DISPLAY @table @asis @item 00000123 123 @end table @end quotation With OpenCOBOL@comma{} the intrinsic @quotation FUNCTION TRIM(myedit LEADING) @end quotation will trim leading whitespace. The LEADING is not really necessary as TRIM removes both leading and trailing whitespace. OpenCOBOL also ships with a library function for justification of strings @quotation CALL "C$JUSTIFY" USING mychars "L" END-CALL @end quotation to left justify an alphanumeric field. "R" for right@comma{} or "C" for centre. But a generic idiom that should work across all capable COBOL systems @quotation MOVE 0 TO spcount INSPECT myedit TALLYING spcount FOR LEADING SPACE MOVE myedit(spcount + 1:) TO mychars DISPLAY myedit END-DISPLAY DISPLAY mychars END-DISPLAY @end quotation @verbatim 123 @end verbatim @quotation 123 @end quotation @quotation MOVE 0 TO spcount INSPECT mynumber TALLYING spcount FOR LEADING ZERO DISPLAY mynumber DISPLAY mynumber(spcount + 1:) @end quotation Uses the INSPECT verb to count leading spaces@comma{} then reference modification to move the characters one past the spaces till the end of the edit field to an alpha field. @node Is there a way to detemermine when OpenCOBOL is running ASCII or EBCDIC? @subsection Is there a way to detemermine when OpenCOBOL is running ASCII or EBCDIC? OpenCOBOL supports both ASCII and EBCDIC character encodings. A simple test such as @quotation @table @asis @item 01 MYSPACE PIC X VALUE X"20". 88 MYISASCII VALUE SPACE. @item IF MYISASCII DISPLAY "I'm ASCII" END-DISPLAY @end table END-IF @end quotation can be used to determine the character set at run-time. @node Is there a way to determine when OpenCOBOL is running on 32 or 64 bits? @subsection Is there a way to determine when OpenCOBOL is running on 32 or 64 bits? OpenCOBOL builds and supports both 32 and 64 bit architectures. A simple test such as @quotation 01 MYPOINTER USAGE POINTER. @table @asis @item IF FUNCTION LENGTH(MYPOINTER) EQUALS 8 DISPLAY "This is a 64 bit machine" END-DISPLAY @end table END-IF @end quotation can be used to determine the native bit size at run-time. @node Does OpenCOBOL support recursion? @subsection Does OpenCOBOL support recursion? Yes. Not completely to standard |currently|@comma{} as there are no restrictions on calling programs in a a recursive manner@comma{} but yes. A made up example using a factorial called program @quotation @table @asis @item @emph{>}* @emph{>}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@emph{*}> Author: Brian Tiffin @emph{> Date: 29-Dec-2008}> Purpose: Horsing around with recursion @emph{> Tectonics: cobc -x recurse.cob}>}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}@emph{*} identification division. program-id. recurse. data division. working-storage section. 78 n value 4. 01 fact usage binary-long. @item @emph{>}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{*}}}}}}}}}}}}}}}* procedure division. call "factorial" using by value n returning fact end-call display n "! = " fact end-display goback. end program recurse. @end table @quotation @emph{>}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@emph{*}>}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}@emph{*} @table @asis @item @emph{>}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{*}}}}}}}}}}}}}}}* identification division. program-id. factorial is recursive. data division. local-storage section. 01 result usage is binary-long. linkage section. 01 num usage is binary-long. @item @emph{>}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{*}}}}}}}}}}}}}}}* procedure division using by value num. display "num: " num end-display if num equal zero move 1 to return-code display "ret: " return-code end-display goback end-if subtract 1 from num end-subtract call "factorial" using by value num returning result end-call compute return-code = (num + 1) * result end-compute display "ret: " return-code end-display goback. end program factorial. @end table @end quotation @end quotation Produces: @verbatim num: +0000000004 num: +0000000003 num: +0000000002 num: +0000000001 num: +0000000000 ret: +000000001 ret: +000000001 ret: +000000002 ret: +000000006 ret: +000000024 4! = +0000000024 @end verbatim Of course the @emph{Intrinsic FUNCTION FACTORIAL} might be a more efficient and much easier way at getting factorials. @node Does OpenCOBOL capture arithmetic overflow? @subsection Does OpenCOBOL capture arithmetic overflow? Yes. Here is one sample using @emph{ADD} with @emph{ON SIZE ERROR}. @quotation @table @asis @item @emph{>}* @emph{>}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@emph{*}> Author: Brian Tiffin @emph{> Date: 04-Feb-2009}> Purpose: Factorial and overflow @emph{> Tectonics: cobc -x overflowing.cob}>}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}@emph{*} identification division. program-id. overflowing. data division. working-storage section. 01 fact usage binary-long. 01 answer usage binary-double. @item @emph{>}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{*}}}}}}}}}}}}}}}* procedure division. 00-main. @table @asis @item perform varying fact from 1 by 1 until fact > 21 add function factorial(fact) to zero giving answer on size error display "overflow at: " fact " is " answer " without test " function factorial(fact) end-display not on size error display fact ": " answer end-display end-add @end table end-perform . 00-leave. goback. end program overflowing. @end table @quotation @emph{>}@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{*}}}}}}}}}}}}}}}* @end quotation @end quotation which outputs: @verbatim +0000000001: +00000000000000000001 +0000000002: +00000000000000000002 +0000000003: +00000000000000000006 +0000000004: +00000000000000000024 +0000000005: +00000000000000000120 +0000000006: +00000000000000000720 +0000000007: +00000000000000005040 +0000000008: +00000000000000040320 +0000000009: +00000000000000362880 +0000000010: +00000000000003628800 +0000000011: +00000000000039916800 +0000000012: +00000000000479001600 +0000000013: +00000000006227020800 +0000000014: +00000000087178291200 +0000000015: +00000001307674368000 +0000000016: +00000020922789888000 +0000000017: +00000355687428096000 +0000000018: +00006402373705728000 +0000000019: +00121645100408832000 overflow at: +0000000020 is +00121645100408832000 without test 432902008176640000 overflow at: +0000000021 is +00121645100408832000 without test 197454024290336768 @end verbatim @node Can OpenCOBOL be used for plotting? @subsection Can OpenCOBOL be used for plotting? Yes? One way is with an external call to @emph{gnuplot}. @quotation @table @asis @item COBOL >>SOURCE FORMAT IS FIXED @table @asis @item @strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@strong{@emph{*} Author: Brian Tiffin * Date: 29-July-2008 * Purpose: Plot trig and a random income/expense/worth report * Tectonics: requires access to gnuplot. @uref{http://www.gnuplot.info,http://www.gnuplot.info} * cobc -Wall -x plotworth.cob * OVERWRITES ocgenplot.gp ocgpdata.txt sincos.png ploworth.png}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}** identification division. program-id. plotworth. environment division. input-output section. file-control. @item select scriptfile assign to "ocgenplot.gp" organization is line sequential. @item select outfile assign to "ocgpdata.txt" organization is line sequential. @item select moneyfile assign to "ocgpdata.txt" organization is line sequential. @item data division. file section. fd scriptfile. @end table @item 01 gnuplot-command pic x(82). fd outfile. @item 01 outrec. 03 x-value pic -zzzzzz9.99. 03 filler pic x. 03 sin-value pic -zzzz9.9999. 03 filler pic x. 03 cos-value pic -zzzz9.9999. @item fd moneyfile. @table @asis @item 01 moneyrec. 03 timefield pic 9(8). 03 filler pic x. 03 income pic -zzzzzz9.99. 03 filler pic x. 03 expense pic -zzzzzz9.99. 03 filler pic x. 03 networth pic -zzzzzz9.99. @item working-storage section. 01 angle pic s9(7)v99. 01 dates pic 9(8). 01 days pic s9(9). 01 worth pic s9(9). 01 amount pic s9(9). 01 gplot pic x(80) value is 'gnuplot -persist ocgenplot.gp'. 01 result pic s9(9). procedure division. @item * Create the script to plot sin and cos open output scriptfile. move "plot 'ocgpdata.txt' using 1:2 with lines title 'sin(x)'" @item - to gnuplot-command. write gnuplot-command. move "replot 'ocgpdata.txt' using 1:3 with lines title 'cos(x)'" @item - to gnuplot-command. write gnuplot-command. move "set terminal png; set output 'sincos.png'; replot" @item - to gnuplot-command. write gnuplot-command. close scriptfile. @item * Create the sinoidal data open output outfile. move spaces to outrec. perform varying angle from -10 by 0.01 @item until angle > 10 move angle to x-value move function sin(angle) to sin-value move function cos(angle) to cos-value write outrec @item end-perform. close outfile. @item * Invoke gnuplot @table @asis @item call "SYSTEM" using gplot returning result. @end table if result not = 0 @item display "Problem: " result @table @asis @item stop run returning result end-if. @item * Generate script to plot the random networth open output scriptfile. move "set xdata time" to gnuplot-command. write gnuplot-command. move 'set timefmt "%Y%m%d"' to gnuplot-command. write gnuplot-command. move 'set format x "%m"' to gnuplot-command. write gnuplot-command. move 'set title "Income and expenses"' to gnuplot-command. write gnuplot-command. move 'set xlabel "2008 / 2009"' to gnuplot-command. write gnuplot-command. move 'plot "ocgpdata.txt" using 1:2 with boxes title "Income" @item -' linecolor rgb "green"' to gnuplot-command. write gnuplot-command. move 'replot "ocgpdata.txt" using 1:3 with boxes title "Expense" @item -' linecolor rgb "red"' to gnuplot-command. write gnuplot-command. move 'replot "ocgpdata.txt" using 1:4 with lines title "Worth"' @item - to gnuplot-command. write gnuplot-command. move 'set terminal png; set output "plotworth.png"; replot' @item - to gnuplot-command. write gnuplot-command. close scriptfile. @item * Generate a bi-weekly dataset with date@comma{} income@comma{} expense@comma{} worth open output moneyfile. move spaces to moneyrec. move function integer-of-date(20080601) to dates. move function random(0) to amount. perform varying days from dates by 14 @item until days > dates + 365 move function date-of-integer(days) to timefield compute amount = function random() * 2000 compute worth = worth + amount move amount to income compute amount = function random() * 1800 compute worth = worth - amount move amount to expense move worth to networth write moneyrec @item end-perform. close moneyfile. @item * Invoke gnuplot again. Will open new window. @table @asis @item call "SYSTEM" using gplot returning result. @end table if result not = 0 @end table display "Problem: " result stop run returning result end-if. @quotation goback. @end quotation @end table @end table @end quotation Which displays and saves: @image{images/sincos,,,image,png} @image{images/plotworth,,,image,png} @node Notes @section Notes @menu * big-endian:: * little-endian:: * ASCII:: * DSO:: * gdb:: * GMP:: @end menu @node big-endian @subsection big-endian Binary values stored with the most significant byte at the lowest memory address. @strong{Big End First}. See @uref{http://en.wikipedia.org/wiki/Endianness,http://en.wikipedia.org/wiki/Endianness} for more details. The OpenCOBOL compiler @emph{default} storage format for USAGE_ BINARY and COMP. @node little-endian @subsection little-endian Binary values stored with the most significant byte at the highest memory address. @strong{Little End First}. @uref{http://en.wikipedia.org/wiki/Endianness,http://en.wikipedia.org/wiki/Endianness} for more details. This is the common Intel architecture form@comma{} and USAGE_ clauses of COMPUTATIONAL-5@comma{} BINARY-CHAR@comma{} BINARY-SHORT@comma{} BINARY-LONG@comma{} BINARY-DOUBLE are a true performance boost on this hardware. See @uref{http://www.opencobol.org/modules/bwiki/index.php?cmd=read&page=UserManual%2F4#content_1_0,http://www.opencobol.org/modules/bwiki/index.php?cmd=read&page=UserManual%2F4#content_1_0} for some details. @node ASCII @subsection ASCII American Symbolic Code for Information Interchange. The character encoding common to personal computers and the Internet Age@comma{} therefore OpenCOBOL. OpenCOBOL also supports the EBCDIC_ character encoding so some data transfers and keyboard handling or console display programs may need programmer attention to detail. Although this is a rare case as OpenCOBOL operates using an intelligent choice of encoding for each platform build. See @uref{http://en.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange,http://en.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange} for more info. @node DSO @subsection DSO Dynamic Shared Objects. Similar to but subtlet different from @emph{share libraries}. @node gdb @subsection gdb The GNU symbolic debugger. Big@comma{} deep@comma{} wide. @verbatim $ info gdb for the details. @end verbatim or visit @uref{http://www.gnu.org/software/gdb/documentation/,http://www.gnu.org/software/gdb/documentation/} @node GMP @subsection GMP GNU MP libgmp. GNU Library for decimal arithmetic. See @uref{http://gmplib.org/,http://gmplib.org/} for complete details on the library advertised as @emph{Arithmetic without limitations}. @node Authors @section Authors @quotation Initial developer and creator of OpenCOBOL. |KeisukeActive| was the primary developer and OpenCOBOL project lead. His efforts are greatly appreciated by the userbase of OpenCOBOL. @end quotation @quotation OpenCOBOL 1.1 is |currently| in development@comma{} and Roger is the lead programmer. |RogerActive|@comma{} Roger has been very active on the opencobol.org_ website@comma{} and is open to feature requests and clarifications to the implementation. Roger has@comma{} since January 2008@comma{} actively monitored an OpenCOBOL 1.1 wishlist on the opencobol.org_ OpenCOBOL forum. @end quotation @node Maintainers and Contributors @section Maintainers and Contributors @quotation Initial FAQ. sample programs for OpenCOBOL 1.1. @end quotation @quotation Hosting@comma{} support. @end quotation @quotation Samples and how-to's and ... @end quotation @quotation Samples and style @end quotation @node ChangeLog @section ChangeLog @table @asis @item 02-July-2008 Experimental version for comment @item 06-July-2008 First 0.0 pre-alpha release @item 07-July-2008 Second 0.0 pre-alpha. @item 11-July-2008 Last 0.0 pre-alpha. Checked in for diffs. @item 13-July-2008 Last-last 0.0 pre-alpha. Verify DIFF functionality. @item 17-July-2008@comma{} 20-July-2008@comma{} 24-July-2008@comma{} 28-July-2008 Last-last-last 0.0 pre-alpha. Second DIFF. Corrections pass. Expanded the SCREEN SECTION questions. Another correction pass@comma{} with clarifications from Roger While @item 10-Aug-2008 Started in on the intrinsic functions. Dropped the pre from the alpha designation. Still some Look into this entries. @item 21-Aug-2008 Move to add1tocobol.com @item 28-Aug-2008 Publish link to 1.0rc @item 29-Aug-2008 Skeleton of the reserved words list @item 30-Aug-2008 Let the tweaking begin @item 23-Sep-2008 Adds and a trial skin @item 13-Oct-2008@comma{} 15-Oct-2008@comma{}19-Oct-2008@comma{} 22-Oct-2008 Added a few samples. Added TABLE SORT sample. Added configure script information. @item 29-Oct-2008 Added dialect configuration information. @item 28-Nov-2008 OpenCOBOL passes the NIST test suite. @item 12-Dec-2008 Added new links to OpenCOBOL 1.1 binary builds by Sergey. @item 16-Dec-2008 Updated header templates. @item 21-Dec-2008 Added a few keywords. @item 28-Dec-2008@comma{} 29-Dec-2008@comma{} 30-Dec-2008 Added info on CobXRef@comma{} some debugging tricks and an entry on recursion. @item 01-Jan-2009@comma{} 10-Jan-2009@comma{} 12-Jan-2009@comma{} 22-Jan-2009 Lame attempt at clarifying (excusing) poor use of Standards references. Small corrections and additions to SQL entry. Added a few RESERVED entries and Vincent's STOCK library expansion. Typos. @item 02-Feb-2009@comma{} 06-Feb-2009 Coloured Source codes. Added info on COB_PRE_LOAD@comma{} added LINAGE sample@comma{} fixed colours (kinda). @end table