OpenCOBOL FAQ Status Attention! This is a 1.0 release candidate of the OpenCOBOL FAQ. Sourced at [http://opencobol.add1tocobol.com/ocfaq.rst|ocfaq.rst] Authors: Brian Tiffin [#btiffin|[btiffin]], John Ellis [#jrls-swla|[jrls_swla]], human [#human|[human]], Joseph James Frantz [#aoirthoir|[aoirthoir]], Roger While [#roger|[Roger]], Keisuke Nishida [#keisuke|[Keisuke]] (with the invaluable assistance of many others) Organization: The OpenCOBOL Project Version: 1.0rc9, October 29, 2008 Status: Release Candidate Copyright: Copyright © 2008 The OpenCOBOL Project Changelog: [#changelog|changelog] Note Each topic is hyperlinked to the table of contents FAQ Contents * [#opencobol|1   OpenCOBOL] ** [#q-what-is-opencobol|1.1   Q. What is OpenCOBOL?] ** [#q-what-is-cobol|1.2   Q. What is COBOL?] ** [#q-how-is-opencobol-licensed|1.3   Q. How is OpenCOBOL licensed?] ** [#q-what-platforms-are-supported-by-opencobol|1.4   Q. What platforms are supported by OpenCOBOL?] ** [#q-are-there-pre-built-opencobol-packages|1.5   Q. Are there pre-built OpenCOBOL packages] ** [#q-what-is-the-most-recent-version-of-opencobol|1.6   Q. What is the most recent version of OpenCOBOL?] ** [#q-how-complete-is-opencobol|1.7   Q. How complete is OpenCOBOL?] ** [#q-will-i-be-amazed-by-opencobol|1.8   Q. Will I be amazed by OpenCOBOL?] ** [#q-who-do-i-thank-for-opencobol|1.9   Q. Who do I thank for OpenCOBOL?] ** [#q-does-opencobol-include-a-test-suite|1.10   Q. Does OpenCOBOL include a Test Suite?] ** [#q-does-opencobol-pass-the-nist-test-suite|1.11   Q. Does OpenCOBOL pass the NIST Test Suite?] ** [#q-what-about-opencobol-and-benchmarks|1.12   Q. What about OpenCOBOL and benchmarks?] ** [#q-can-opencobol-be-used-for-cgi|1.13   Q. Can OpenCOBOL be used for CGI?] ** [#q-can-opencobol-by-used-for-production-applications|1.14   Q. Can OpenCOBOL by used for production applications?] ** [#q-where-can-i-get-more-information-about-cobol|1.15   Q. Where can I get more information about COBOL?] ** [#q-where-can-i-get-more-information-about-opencobol|1.16   Q. Where can I get more information about OpenCOBOL?] ** [#q-can-i-help-out-with-the-opencobol-project|1.17   Q. Can I help out with the OpenCOBOL project?] ** [#q-is-there-an-opencobol-mailing-list|1.18   Q. Is there an OpenCOBOL mailing list?] ** [#q-where-can-i-find-more-information-about-cobol-standards|1.19   Q. Where can I find more information about COBOL standards?] ** [#q-do-you-know-any-good-jokes|1.20   Q. Do you know any good jokes?] * [#history|2   History] ** [#q-what-is-the-history-of-cobol|2.1   Q. What is the history of COBOL?] ** [#q-what-is-the-development-history-of-opencobol|2.2   Q. What is the development history of OpenCOBOL?] ** [#q-what-is-the-current-version-of-opencobol|2.3   Q. What is the current version of OpenCOBOL?] * [#using-opencobol|3   Using OpenCOBOL] ** [#q-how-do-i-install-opencobol|3.1   Q. How do I install OpenCOBOL?] ** [#q-what-are-the-configure-options-available-for-building-opencobol|3.2   Q. What are the configure options available for building OpenCOBOL?] ** [#q-does-opencobol-have-any-other-dependencies|3.3   Q. Does OpenCOBOL have any other dependencies?] ** [#q-how-does-the-opencobol-compiler-work|3.4   Q. How does the OpenCOBOL compiler work?] ** [#q-what-is-cobc|3.5   Q. What is cobc?] ** [#q-what-is-cobcrun|3.6   Q. What is cobcrun?] ** [#q-what-is-cob-config|3.7   Q. What is cob-config?] ** [#q-what-compiler-options-are-supported|3.8   Q. What compiler options are supported?] ** [#q-what-dialects-are-supported-by-opencobol|3.9   Q. What dialects are supported by OpenCOBOL?] ** [#q-what-are-the-opencobol-compile-time-configuration-files|3.10   Q. What are the OpenCOBOL compile time configuration files?] ** [#q-do-you-have-a-reasonable-source-code-skeleton-for-opencobol|3.11   Q. Do you have a reasonable source code skeleton for OpenCOBOL?] ** [#q-what-is-ocdoc|3.12   Q. What is ocdoc?] ** [#q-does-opencobol-support-any-sql-databases|3.13   Q. Does OpenCOBOL support any SQL databases?] ** [#q-what-are-the-opencobol-reserved-words|3.14   Q. What are the OpenCOBOL RESERVED WORDS?] ** [#q-does-opencobol-support-modules|3.15   Q. Does OpenCOBOL support modules?] ** [#q-what-is-the-opencobol-linkage-section-for|3.16   Q. What is the OpenCOBOL LINKAGE SECTION for?] ** [#q-what-does-the-fstatic-linkage-opencobol-compiler-option-do|3.17   Q. What does the -fstatic-linkage OpenCOBOL compiler option do?] ** [#q-can-opencobol-interface-with-ada|3.18   Q. Can OpenCOBOL interface with Ada?] ** [#q-does-opencobol-support-screen-section|3.19   Q. Does OpenCOBOL support SCREEN SECTION?] ** [#q-what-are-the-opencobol-screen-section-colour-values|3.20   Q. What are the OpenCOBOL SCREEN SECTION colour values?] ** [#q-does-opencobol-support-crt-status|3.21   Q. Does OpenCOBOL support CRT STATUS?] ** [#q-what-is-cobcurses|3.22   Q. What is CobCurses?] ** [#q-does-opencobol-implement-report-writer|3.23   Q. Does OpenCOBOL implement Report Writer?] ** [#q-does-opencobol-implement-linage|3.24   Q. Does OpenCOBOL implement LINAGE?] ** [#q-does-opencobol-implement-any-intrinsic-functions|3.25   Q. Does OpenCOBOL implement any Intrinsic FUNCTIONs?] ** [#q-can-you-clarify-the-use-of-function-in-opencobol|3.26   Q. Can you clarify the use of FUNCTION in OpenCOBOL?] ** [#q-what-is-the-difference-between-the-length-verb-and-function-length|3.27   Q. What is the difference between the LENGTH verb and FUNCTION LENGTH?] ** [#q-what-stock-call-library-does-opencobol-offer|3.28   Q. What STOCK CALL LIBRARY does OpenCOBOL offer?] ** [#q-what-are-the-xf4-xf5-and-x91-routines|3.29   Q. What are the XF4, XF5, and X91 routines?] ** [#q-what-is-cbl-oc-nanosleep-opencobol-library-routine|3.30   Q. What is CBL_OC_NANOSLEEP OpenCOBOL library routine?] ** [#q-can-i-use-ctags-with-opencobol|3.31   Q. Can I use ctags with OpenCOBOL?] ** [#q-what-about-debugging-opencobol-programs|3.32   Q. What about debugging OpenCOBOL programs?] ** [#q-is-there-a-c-interface-to-opencobol|3.33   Q. Is there a C interface to OpenCOBOL?] ** [#q-what-are-some-idioms-for-dealing-with-c-char-data-from-opencobol|3.34   Q. What are some idioms for dealing with C char * data from OpenCOBOL?] ** [#q-does-opencobol-support-copy-includes|3.35   Q. Does OpenCOBOL support COPY includes?] ** [#q-does-opencobol-support-when-compiled|3.36   Q. Does OpenCOBOL support WHEN-COMPILED?] ** [#q-what-is-pi-in-opencobol|3.37   Q. What is PI in OpenCOBOL?] ** [#q-does-opencobol-support-the-object-features-of-the-2002-standard|3.38   Q. Does OpenCOBOL support the Object features of the 2002 standard?] ** [#q-does-opencobol-implement-picture-78|3.39   Q. Does OpenCOBOL implement PICTURE 78?] ** [#q-does-opencobol-implement-constant|3.40   Q. Does OpenCOBOL implement CONSTANT?] ** [#q-what-source-formats-are-accepted-by-opencobol|3.41   Q. What source formats are accepted by OpenCOBOL?] ** [#q-does-opencobol-support-continuation-lines|3.42   Q. Does OpenCOBOL support continuation lines?] ** [#q-does-opencobol-support-string-concatenation|3.43   Q. Does OpenCOBOL support string concatenation?] ** [#q-does-opencobol-support-d-indicator-debug-lines|3.44   Q. Does OpenCOBOL support D indicator debug lines?] ** [#q-does-opencobol-support-mixed-case-source-code|3.45   Q. Does OpenCOBOL support mixed case source code?] ** [#q-what-is-the-shortest-opencobol-program|3.46   Q. What is the shortest OpenCOBOL program?] ** [#q-what-is-the-shortest-hello-world-program-in-opencobol|3.47   Q. What is the shortest Hello World program in OpenCOBOL?] ** [#q-how-do-i-get-those-nifty-sequential-sequence-numbers-in-a-source-file|3.48   Q. How do I get those nifty sequential sequence numbers in a source file?] ** [#q-is-there-a-way-to-count-trailing-spaces-in-data-fields-using-opencobol|3.49   Q. Is there a way to count trailing spaces in data fields using OpenCOBOL?] ** [#q-is-there-a-way-to-left-justify-an-edited-numeric-field|3.50   Q. Is there a way to left justify an edited numeric field?] * [#notes|4   Notes] ** [#big-endian|4.1   big-endian] ** [#little-endian|4.2   little-endian] ** [#ascii|4.3   ASCII] ** [#dso|4.4   DSO] ** [#gdb|4.5   gdb] ** [#gmp|4.6   GMP] * [#authors|5   Authors] * [#maintainers-and-contributors|6   Maintainers and Contributors] * [#changelog|7   Changelog] [#id20|1   OpenCOBOL][#id21|1.1   Q. What is OpenCOBOL?] [http://opencobol.org/|OpenCOBOL] is an open-source [http://en.wikipedia.org/wiki/COBOL|COBOL] compiler. OpenCOBOL implements a substantial part of the [http://www.cobolstandards.com/|COBOL 85] and [http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=28805|COBOL 2002] standards, 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, including Unix/Linux, Mac OS X, and Microsoft Windows. [#id22|1.2   Q. What is COBOL?] [http://en.wikipedia.org/wiki/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", but that emphasis is perhaps up to the readers point of view. [#id23|1.3   Q. How is OpenCOBOL licensed?] The compiler is licensed under [http://www.gnu.org/licenses/gpl.html|GNU General Public License]. The run-time library is licensed under [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, 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. [#id24|1.4   Q. What platforms are supported by OpenCOBOL?] [http://opencobol.org/modules/mydownloads/singlefile.php?cid=1&lid=3|OpenCOBOL 1.0] the current official release version, hosted on SourceForge.net, compiles on: * All 32-bit MS Windows (95/98/NT/2000/XP) * All POSIX (Linux/BSD/UNIX-like OSes) * OS/X [http://www.opencobol.org/modules/mydownloads/singlefile.php?cid=1&lid=2|OpenCOBOL 1.1] also hosted on SourceForge.net, has been tested on * MS Windows * POSIX Systems * OS/X [#id25|1.5   Q. Are there pre-built OpenCOBOL packages] Yes. Debian APT, and RPM packages exist. Packages for NetBSD. Many. Google ''opencobol packages'' for any late breaking news. A Debian apt binary package exists for OpenCOBOL 1.0 as __open-cobol__ and lists dependencies of * libc6 (>= 2.7-1), * libcob1, * libcob1-dev (= 1.0-1), * libdb4.5 (>= 4.5.20-3), * libdb4.5-dev, * libgmp3-dev, * libgmp3c2, * libltdl3-dev, * libncurses5 (>= 5.6+20071006-3) Thanks to the gracious efforts of Bart Martens, bartm on Debian's .org domain. Also check out [http://www.kiska.net/opencobol/] for binary builds on various platforms. Thanks to Sergey Kashyrin. [#id26|1.6   Q. What is the most recent version of OpenCOBOL?] See [#q-what-is-the-current-version-of-opencobol|Q. What is the current version of OpenCOBOL?] [#id27|1.7   Q. How complete is OpenCOBOL?] [http://opencobol.org/modules/mydownloads/singlefile.php?cid=1&lid=3|OpenCOBOL 1.0] implements a substantial portion of [http://www.cobolstandards.com/|COBOL 85], supports many of the advances and clarifications of [http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=28805|COBOL 2002], and includes many extensions in common use from Micro Focus COBOL, ACUCOBOL and other exsistent compilers. [http://www.opencobol.org/modules/mydownloads/singlefile.php?cid=1&lid=2|OpenCOBOL 1.1] implements a more substantial portion of the [http://www.cobolstandards.com/|COBOL 85] Dialect, [http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=28805|COBOL 2002] and a growing number of vendor extensions. Some proposed COBOL 2008 features have also been implemented. Compatibility support includes: * MF for Micro Focus * IBM for IBM compatibility * MVS * BS2000 OpenCOBOL also includes some advanced features allowing source code such as CALL "cfunction" USING BY REFERENCE ADDRESS OF VAR-IN-LINKAGE-SECTION. Passing the equivalent of char**, pointer to pointer to char. Just as a small example of the level of coverage provided by OpenCOBOL. [#id28|1.8   Q. Will I be amazed by OpenCOBOL?] This author believes so. For an open source implementation of COBOL, OpenCOBOL may surprise you in the depth and breadth of its COBOL standard feature support, usability and robustness. [#id29|1.9   Q. 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: 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. [#id30|1.10   Q. Does OpenCOBOL include a Test Suite?] Why yes it does. 74 syntax tests, 170 coverage tests, and 16 data representation tests at last count. From the development tarball, __$ make check__ will evaluate and report on the test suite. [#id31|1.11   Q. Does OpenCOBOL pass the NIST Test Suite?] Many. OpenCOBOL achieves a very high level of COBOL 85 conformance. The National Institute of Standards and Technology, NIST, maintains a COBOL 85 implementation verification suite of tests. An archive of the tests can be found at [http://www.itl.nist.gov/div897/ctg/cobol_form.htm] Instructions for use of the NIST suite is included in the build archive under: tests/cobol85/README Basically, it is a simple __uncompress__ and __make__ then sit back and relax. The scripts run OpenCOBOL over some 364 programs/modules and includes thousands of test passes. 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 The summary.log from a run in July 2008: Module programs executed error crash details ------ -------- -------- ----- ----- ------- NC 92 92 0 0 4363,0,6,11/4380 SM 15 13 0 0 289,2,3,1/295 IC 24 21 3 0 240,0,4,0/244 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 IF 42 42 0 0 732,0,0,0/732 ------ -------- -------- ----- ----- ------- Total 364 359 3 0 [#id32|1.12   Q. What about OpenCOBOL and benchmarks?] OpenCOBOL 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, by default, generates code optimized for [#big-endian|big-endian] hardware. Fairly dramatic speed improvements on Intel architecture can come from simple __USAGE IS COMPUTATIONAL-5__ clauses in the DATA DIVISION. Attention! Look into this [#id33|1.13   Q. Can OpenCOBOL be used for CGI?] Yes. Through standard IO redirection and the extended __ACCEPT ... FROM ENVIRONMENT ...__ feature, OpenCOBOL is more than capable of supporting advanced CGI programming. COBOL >>SOURCE FORMAT IS FIXED ****************************************************************** * Author: Brian Tiffin, 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 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 24. 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 '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_CONNECTION'. 03 filler pic x(20) value 'HTTP_HOST'. 03 filler pic x(20) value 'HTTP_USER_AGENT'. 03 filler pic x(20) value 'PATH'. 03 filler pic x(20) value 'QUERY_STRING'. 03 filler pic x(20) value 'REMOTE_ADDR'. 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. * Always send out the Content-type before any other IO display "Content-type: text/html" newline end-display. display "<html><body>" end-display. display "<h3>CGI environment with OpenCOBOL</h3>" end-display. display '<a href="/cgienvform.html">To cgienvform.html</a>' "<p><table>" end-display. * Accept and display some of the known CGI environment values perform varying name-index from 1 by 1 until name-index > name-count accept value-string from environment name-string(name-index) end-accept display "<tr><td>" name-string(name-index) ": </td><td>" function trim (value-string trailing) "</td></tr>" 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 '<tr><td align="right">' "First chunk of POST:</td><td>" postchunk(1:72) "</td></tr>" end-display end-if end-perform. display "</table></p></body></html>" end-display. COOL goback. cgienv.cgi form: <html><head><title>OpenCOBOL sample CGI form</title></head> <body> <h3>OpenCOBOL sample CGI form</h3> <form action="http://localhost/cgi-bin/cgienv.cgi" method="post"> <p> Text: <input type="text" name="text"><br> Password: <input type="password" name="password"><br> Checkbox: <input type="checkbox" name="checkbox"><br> <input type="radio" name="radio" value="ONE"> One<br> <input type="radio" name="radio" value="TWO"> Two<br> <input type="submit" value="Send"> <input type="reset"> </p> </form> </body> </html> [#id34|1.14   Q. Can OpenCOBOL by used for production applications?] Depends. OpenCOBOL is still in active development. Feature coverage is growing, and while the current implementation offers great coverage, applicability to any given situation would need to analyzed and risks evaluated before commitment to production use. The licensing allows for commercial use, but OpenCOBOL also ships with notice of indemnity, meaning that there are no guarantees when using OpenCOBOL, directly or indirectly. There may be a time when commercial support of OpenCOBOL is offered, but at the time of writing no known offering exists. ''Search google just in case!'' And yes, OpenCOBOL is used in production environments. From [#roger|[Roger]]: 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. Attention! Look into this - need more entries [#id35|1.15   Q. Where can I get more information about COBOL?] The [http://home.comcast.net/~wmklein/FAQ/COBOLFAQ.htm|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, opinions and technical information to satisfy the greatest of curiosities. The [http://www.cobug.com/|COBUG] site ''COBOL User Groups'' is also a wonderful resource for OpenCOBOL developers. [#id36|1.16   Q. Where can I get more information about OpenCOBOL?] The [http://opencobol.org/|opencobol.org] website is probably the best place to find out more about the OpenCOBOL system. [#id37|1.17   Q. Can I help out with the OpenCOBOL project?] Absolutely. Visit the [http://opencobol.org/|opencobol.org] website and either post a message asking what needs to be done, or perhaps join the development mailing list to find out the current state of development. See [#q-is-there-an-opencobol-mailing-list|Q. Is there an OpenCOBOL mailing list?] for some details. OpenCOBOL is a GPL licensed open source project and while [#roger|[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. [#id38|1.18   Q. Is there an OpenCOBOL mailing list?] Yes. Visit [http://opencobol.org/|opencobol.org] for details. The OpenCOBOL development mailing list is graciously hosted by SourceForge. The ML archive is available at [http://sourceforge.net/mailarchive/forum.php?forum_name=open-cobol-list] and once you have subscribed, the list will accept messages at the open-cobol-list email destination at lists.sourceforge.net. [#id39|1.19   Q. Where can I find more information about COBOL standards?] The [http://www.cobolstandards.com/|COBOL 85] standard is documented in * ANSI X3.23-1985 * ISO 1989-1985 * ANSI X3.23a-1989 * ANSI X3.23b-1993 Attention! Look into this [#id40|1.20   Q. Do you know any good jokes?] Maybe. * A computer without COBOL and Fortran is like a piece of chocolate cake without ketchup or mustard.''John Krueger'' * A determined coder can write COBOL programs in any language.''Author: unknown'' * Rumour has it that the object oriented specification for COBOL was code named''ADD 1 TO COBOL GIVING COBOL.''''Author: unknown''A less verbose, more concise version; ''very unCOBOL that''''ADD 1 TO COBOL.''''Thanks to aoirthoir''And, just because;''ADD 1 TO COBOL GIVING OpenCOBOL'' * A common dis of COBOL jokes that the acronym is:Completely Obsolete Business Oriented Language. ''Author unkown''We know better. The reality is:Can't Obsolesce Because Of Legacy. ''And why would you want to?''''Brian Tiffin'' * Ruby on Rails? Don't forget COBOL ON COGS.[http://www.coboloncogs.org/INDEX.HTM] * Eat COBOL, 200 billion lines can't be wrong.''Brian Tiffin'' * What did COBOL yell to the escaping thief?__STOP RUN RETURNING NOW.__''Brian Tiffin'' * What did COBOL reply to the executive? ''Why yes, I can''__PERFORM JUMPS THRU HOOPS.__''Brian Tiffin'' * What did OpenCOBOL reply to the executive? ''Sir, I can''__PERFORM JUMPS THRU FLAMING-HOOPS UNTIL HELL-FREEZES-OVER.__''And being COBOL, I have to show you how little code it takes:'' 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. ''Brian Tiffin'' [#id41|2   History][#id42|2.1   Q. What is the history of COBOL?] Starting in 1959, 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, and created the first standardized business computer programming language. The COmmon Business Oriented Language acronym was announced on September 18th, 1959. Late in 1960, ''essentially'' the same COBOL program ran on two different hardware platforms, and stakeholders espied the potential for fulfilling the objective of industry wide, compatible business systems. [http://en.wikipedia.org/wiki/Grace_Hopper|Admiral Grace Hopper] is affectionately referred to as the ''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: * COBOL-68 * COBOL-74 * COBOL-85 * COBOL-2002 * Draft work for COBOL-2008 is underway (August 2008) 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, but it is entirely reasonable to believe that of the some 300,000,000,000 (three hundred thousand million) lines of computer source code in production today, 200,000,000,000 (two hundred thousand million) lines are COBOL. A full 2/3rds of the world's source code. See the Wikipedia entry for [http://en.wikipedia.org/wiki/COBOL|COBOL] for a lot more details. [#id43|2.2   Q. What is the development history of OpenCOBOL?] OpenCOBOL was initially developed by Keisuke Nishida [#keisuke|[Keisuke]] from work on [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, 2002. Development continued apace, with version 0.30 released by Keisuke on August 8th, 2004. Roger While [#roger|[Roger]] then took up the role as lead developer on October 30th, 2004. ; Version 0.31 : was released February 1st, 2005. ; Version 0.32 : was released May 12th, 2005. ; Version 0.33 : started on May 13th, 2005. ; Version 1.0 : was released on December 27th, 2007. [#id44|2.3   Q. What is the current version of OpenCOBOL?] OpenCOBOL 1.0 was released December 27th, 2007 by Roger While [#roger|[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, 2007 and is currently ''(August 2008)'' in active development. The pre-release source tar can be found at [http://www.opencobol.org/modules/mydownloads/singlefile.php?cid=1&lid=2|OpenCOBOL 1.1] with installer instructions at [http://www.opencobol.org/modules/bwiki/index.php?InstallGuide|OpenCOBOL Install] and in the INSTALLING text file of the sources. If you build a pre-release OC1.1, you will be able to compile the __occurlrefresh.cbl__ (with __occurlsym.cpy__) application and an early __occurl.c__ libCURL wrapper that allows file transfers off the Internet. __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|[aoirthoir]] for hosting these; currently ''(August 2008)'' at [http://opencobol.add1tocobol.com/occurlrefresh.cbl|occurlrefresh.cbl] [http://opencobol.add1tocobol.com/occurlsym.cpy|occurlsym.cpy] [http://opencobol.add1tocobol.com/occurl.c|occurl.c] After a download: $ ./configure $ make $ make check $ sudo make install will place a new set of binaries rooted off __/usr/local__ [#id45|3   Using OpenCOBOL][#id46|3.1   Q. How do I install OpenCOBOL?] Installation instructions can be found at [http://www.opencobol.org/modules/bwiki/index.php?InstallGuide|OpenCOBOL Install]. ; Debian : The Debian binary package makes installing OpenCOBOL 1.0 a snap. From __root__ or using sudo: $ apt-get open-cobol ; Windows : Build from sources under Cygwin or MinGW. Follow the instructions from the site listed above. Also see [#q-what-is-the-current-version-of-opencobol|Q. What is the current version of OpenCOBOL?] [#id47|3.2   Q. What are the configure options available for building OpenCOBOL?] ''configure'' is a defacto standard development tool for POSIX compliant operating systems, 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, the ''configure'' script accepts __--help__ as a command line option to display all of the available configuration choices. `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 -q, --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=<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-varseq (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<lib dir> if you have libraries in a nonstandard directory <lib dir> CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> 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 <open-cobol-list@lists.sourceforge.net>. [#id48|3.3   Q. 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 ''(August 2008)'' in use. OpenCOBOL requires the following external libraries to be installed: ; 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. ; GNU Libtool (libltdl) : libltdl is used to implement dynamic CALL statements. GNU Libtool is licensed under GNU Lesser General Public License. NOTE - Libtool is not required for Linux and Windows (including MinGW and Cygwin) The following libraries are optional: ; 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, as of 2.x, if you linked your software with Berkeley DB, you must distribute the source code of your software along with your software, 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 ; Ncurses (libncurses) 5.2 or later : libncurses can be used to implement SCREEN SECTION. Ncurses is licensed under a BSD-style license. [#id49|3.4   Q. 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. # 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, __gcc__ being a standard. The main tool, __cobc__, by default, produces modules, linkable shared object files. Example $ cat hello.cob Original source code; 000100* HELLO.COB OpenCOBOL FAQ example 000200 IDENTIFICATION DIVISION. 000300 PROGRAM-ID. hello. 000400 PROCEDURE DIVISION. 000500 DISPLAY "Hello World!". 000600 STOP RUN. OpenCOBOL stages. Preprocess: $ cobc -E hello.cob Preprocess only; For one thing, FIXED format becomes FREE format. For another COPY is processed. Displays # 1 "hello.cob" IDENTIFICATION DIVISION. PROGRAM-ID. hello. PROCEDURE DIVISION. DISPLAY "Hello World!". STOP RUN. to standard out. Translate: $ cobc -C hello.cob 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 __hello.c.h__ and __hello.c__. hello.c.h: /* Generated by cobc 1.1.0 */ /* Generated from hello.cob */ /* Generated at Oct 04 2008 00:19:36 EDT */ /* OpenCOBOL build date Oct 01 2008 22:15:19 */ /* OpenCOBOL package date Oct 01 2008 16:31:26 CEST */ /* Compile command cobc -C hello.cob */ /* PROGRAM-ID : hello */ static unsigned char b_5[4] __attribute__((aligned)); /* COB-CRT-STATUS */ static unsigned char b_1[4] __attribute__((aligned)); /* RETURN-CODE */ static unsigned char b_2[4] __attribute__((aligned)); /* SORT-RETURN */ static unsigned char b_3[4] __attribute__((aligned)); /* NUMBER-OF-CALL-PARAMETERS */ /* attributes */ static cob_field_attr a_1 = {16, 4, 0, 0, NULL}; static cob_field_attr a_2 = {33, 0, 0, 0, NULL}; /* fields */ static cob_field f_5 = {4, b_5, &a_1}; /* COB-CRT-STATUS */ /* constants */ static cob_field c_1 = {12, (unsigned char *)"Hello World!", &a_2}; /* ---------------------------------------------- */ hello.c: /* Generated by cobc 1.1.0 */ /* Generated from hello.cob */ /* Generated at Oct 04 2008 00:19:36 EDT */ /* OpenCOBOL build date Oct 01 2008 22:15:19 */ /* OpenCOBOL package date Oct 01 2008 16:31:26 CEST */ /* Compile command cobc -C hello.cob */ #define __USE_STRING_INLINES 1 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <libcob.h> #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 */ static int initialized = 0; static cob_field *cob_user_parameters[COB_MAX_FIELD_PARAMS]; static cob_module module = { NULL, NULL, &f_5, NULL, cob_user_parameters, 0, '.', '$', ',', 1, 1, 1, 0}; /* perform frame stack */ int frame_index; struct frame { int perform_through; void *return_address; } frame_stack[255]; /* Start of function code */ if (unlikely(entry < 0)) { if (!initialized) { return 0; } initialized = 0; return 0; } module.next = cob_current_module; cob_current_module = &module; if (unlikely(initialized == 0)) { if (!cob_initialized) { cob_fatal_error (COB_FERROR_INITIALIZED); } cob_check_version (COB_SOURCE_FILE, COB_PACKAGE_VERSION, COB_PATCH_LEVEL); if (module.next) cob_set_cancel ((const char *)"hello", (void *)hello, (void *)hello_); (*(int *) (b_1)) = 0; (*(int *) (b_2)) = 0; (*(int *) (b_3)) = 0; memset (b_5, 48, 4); initialized = 1; } /* initialize frame stack */ frame_index = 0; frame_stack[0].perform_through = -1; /* initialize number of call params */ (*(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 */ { cob_new_display (0, 1, 1, &c_1); } /* hello.cob:6: STOP */ { cob_stop_run ((*(int *) (b_1))); } cob_current_module = cob_current_module->next; return (*(int *) (b_1)); } /* end function stuff */ Generate assembler: $ cobc -S hello.cob hello.s: .file "cob9141_0.c" .text .globl hello .type hello, @function hello: pushl %ebp movl %esp, %ebp subl $8, %esp movl $0, (%esp) call hello_ leave ret .size hello, .-hello .data .align 4 .type module.5786, @object .size module.5786, 28 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,256,32 .local initialized.5784 .comm initialized.5784,4,4 .section .rodata .LC0: .string "Hello World!" .data .align 4 .type c_1.5783, @object .size c_1.5783, 12 c_1.5783: .long 12 .long .LC0 .long a_2.5781 .align 4 .type f_5.5782, @object .size f_5.5782, 12 f_5.5782: .long 4 .long b_5.5776 .long a_1.5780 .align 4 .type a_2.5781, @object .size a_2.5781, 8 a_2.5781: .byte 33 .byte 0 .byte 0 .byte 0 .long 0 .align 4 .type a_1.5780, @object .size a_1.5780, 8 a_1.5780: .byte 16 .byte 4 .byte 0 .byte 0 .long 0 .local b_3.5779 .comm b_3.5779,4,16 .local b_2.5778 .comm b_2.5778,4,16 .local b_1.5777 .comm b_1.5777,4,16 .local b_5.5776 .comm b_5.5776,4,16 .section .rodata .LC1: .string "1.1" .LC2: .string "hello.cob" .LC3: .string "hello" .text .type hello_, @function hello_: pushl %ebp movl %esp, %ebp subl $2072, %esp movl 8(%ebp), %eax shrl $31, %eax testl %eax, %eax je .L4 movl initialized.5784, %eax testl %eax, %eax jne .L5 movl $0, -2052(%ebp) jmp .L6 .L5: movl $0, initialized.5784 movl $0, -2052(%ebp) jmp .L6 .L4: movl cob_current_module, %eax movl %eax, module.5786 movl $module.5786, cob_current_module movl initialized.5784, %eax testl %eax, %eax sete %al movzbl %al, %eax testl %eax, %eax je .L7 movl cob_initialized, %eax testl %eax, %eax jne .L8 movl $0, (%esp) call cob_fatal_error .L8: movl $0, 8(%esp) movl $.LC1, 4(%esp) movl $.LC2, (%esp) call cob_check_version movl module.5786, %eax testl %eax, %eax je .L9 movl $hello_, 8(%esp) movl $hello, 4(%esp) movl $.LC3, (%esp) call cob_set_cancel .L9: movl $b_1.5777, %eax movl $0, (%eax) movl $b_2.5778, %eax movl $0, (%eax) movl $b_3.5779, %eax movl $0, (%eax) movl $4, 8(%esp) movl $48, 4(%esp) movl $b_5.5776, (%esp) call memset movl $1, initialized.5784 .L7: movl $0, -4(%ebp) movl $-1, -2044(%ebp) movl $b_3.5779, %edx movl cob_call_params, %eax movl %eax, (%edx) movl cob_call_params, %eax movl %eax, cob_save_call_params .L10: movl $c_1.5783, 12(%esp) movl $1, 8(%esp) movl $1, 4(%esp) movl $0, (%esp) call cob_new_display movl $b_1.5777, %eax movl (%eax), %eax movl %eax, (%esp) call cob_stop_run .L6: movl -2052(%ebp), %eax leave ret .size hello_, .-hello_ .ident "GCC: (Debian 4.3.1-9) 4.3.1" .section .note.GNU-stack,"",@progbits Compile only; outputs assembly file. Produces __hello.s__. Produce object code: $ cobc -c hello.cob Compile and assemble, do not link. Produces __hello.o__. Build modules: $ cobc -m hello.cob Build dynamically loadable module. The is the ''default behaviour''. This example produces __hello.so__ or __hello.dll__. Module run: $ cobcrun hello Will scan the [#dso|DSO] hello.so, and then link, load, and execute hello. Attention! Need a little OS/X info here $ cobc -x hello.cob Build an executable program. This examples produces __hello__ or __hello.exe__. __This is important__. ''cobc'' produces a ''Dynamic Shared Object'' by default. ''To create executables'', you need to use __-x__. $ ./hello Hello World! OpenCOBOL also supports features for multiple source, multiple language programming, detailed in the FAQ at [#q-does-opencobol-support-modules|Q. Does OpenCOBOL support modules?]. [#id50|3.5   Q. What is cobc?] __cobc__ is the OpenCOBOL compiler. See [#q-what-compiler-options-are-supported|Q. What compiler options are supported?] for more information. [#id51|3.6   Q. What is cobcrun?] __cobcrun__ is the OpenCOBOL driver program that allows the execution of programs stored in OpenCOBOL modules. The __cobc__ compiler, by default, produces modules (the ''-m'' option). These modules are linkable dynamic shared objects (DSO). Using GNU/Linux for example: $ cobc -x hello.cob $ ./hello Hello World! $ cobc hello.cob $ cobcrun hello Hello World! The __cobc -x hello.cob__ built an executable binary called hello. The __cobc hello.cob__ produced a [#dso|DSO] hello.so, and cobcrun resolves the entry point and executes the code, right from the [#dso|DSO]. __cobcrun__ ''is the compiler author's preferred way to manage OpenCOBOL development.'' It alleviates knowing which source file needs ''-x'' while encouraging proper modular programming, a mainstay of OpenCOBOL. [#id52|3.7   Q. What is cob-config?] __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: $ 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 You may need to use these features during mixed source language development, usually by back-ticking the command output inline with other __gcc__ commands. [#id53|3.8   Q. What compiler options are supported?] The OpenCOBOL system strives to be standards compliant, 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 [#q-what-are-the-opencobol-compile-time-configuration-files|Q. What are the OpenCOBOL compile time configuration files?] for more details on this finely tuned control. $ 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=<dialect> 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 <file> Place the output into <file> -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 <file> Generate and place a program listing into <file> -I <directory> Add <directory> to copy/include search path -L <directory> Add <directory> to library search path -l <lib> Link the library <lib> -D <define> Pass <define> to the C compiler -conf=<file> User defined dialect configuration - See -std= --list-reserved Display all reserved words -save-temps Do not delete intermediate files -MT <target> Set target file used in dependency list -MF <file> Place dependency list into <file> -ext <extension> Add default file extension -Wall Enable all warnings -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) -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 -fstatic-linkage Statically allocate non-USING LINKAGE parameters -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 PIC (ala MF) -fmfcomment Treat lines with '*' or '/' in column 1 as comments (FIXED only) -fnull-param Pass extra NULL terminating pointers on CALL statements [#id54|3.9   Q. What dialects are supported by OpenCOBOL?] Using the __std=<dialect>__ compiler option, OpenCOBOL can be configured to compile using specific historical COBOL compiler features and quirks. Supported dialects include: * default * cobol85 * cobol2002 * ibm * mvs * mf * bs2000 For details on what options and switches are used to support these dialect compiles, see the __config/__ directory of your OpenCOBOL installation. For Debian GNU/Linux, that will be __/usr/share/open-cobol/config/__ if you used APT to install an OpenCOBOL package or __/usr/local/share/open-cobol/config/__ after a build from the source archive. For example: the ''bs2000.conf'' file restricts data representations to 2, 4 or 8 byte binary while ''mf.conf'' allows data representations from 1 thru 8 bytes. ''cobol85.conf'' allows debugging lines, ''cobol2002.conf'' configures the compiler to warn that this feature is obsolete. [#id55|3.10   Q. What are the OpenCOBOL compile time configuration files?] To assist in the support of the various existent COBOL compilers, OpenCOBOL reads configuration files controlling various aspects of a compile pass. Each supported dialect will have also have a ''.conf'' file in the __config/__ sub-directory of its installation. For Debian GNU/Linux, these will be in __/usr/share/open-cobol/config/__ or __/usr/local/share/open-cobol/config__ under default package and default ''make'' conditions. For example, the default configuration, ''default.conf'' is: # 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 [#id56|3.11   Q. 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 __ocdoc__ lines. *>>SOURCE FORMAT IS FIXED *> *************************************************************** *><* =========== *><* *><* =========== *><* :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. *> ************************************************************** procedure division. goback. end program . *><* *><* Last Update: dd-Mmm-yyyy Fill in the ''program-id'' and ''end program'' to compile. Fill in the ocdoc title for generating documentation. [#id57|3.12   Q. What is ocdoc?] __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: *>>SOURCE FORMAT IS FIXED *> *************************************************************** *><* ===================== *><* ocdoc.cob usage guide *><* ===================== *><* .. sidebar:: Table of Contents *><* *><* .. contents:: :local: *><* *><* :Author: Brian Tiffin *><* :Date: 30-Sep-2008 *><* :Rights: Copyright (c) 2008, Brian Tiffin. *><* GNU FDL License. *><* :Purpose: Extract usage document lines from COBOL sources. *><* Using OpenCOBOL 1.1pr. OpenCOBOL is tasty. *><* :Tectonics: cobc -x ocdoc.cob *><* :Docgen: $ ./ocdoc ocdoc.cob ocdoc.rst ocdoc.html skin.css *> *************************************************************** *><* *><* ------------ *><* Command line *><* ------------ *><* *ocdoc* runs in two forms. *><* *><* Without arguments, *ocdoc* will act as a pipe filter. *><* Reading from standard in and writing the extract to standard *><+ out. *><* *><* The *ocdoc* command also takes an input file, an extract *><+ filename, an optional result file (with optional *><+ stylesheet) and a verbosity option *-v* or a *><+ special *-fixed* flag (to force skipping sequence numbers). *><* If a result file is given, ocdoc will automatically *><* run an *rst2html* command using the SYSTEM service. *><* *><* Due to an overly simplistic argument handler, you can only *><+ turn on verbosity or -fixed when using all four filenames. *><* *><* Examples:: *><* *><* $ cat ocdoc.cob | ocdoc >ocdoc.rst *><* $ ./ocdoc ocdoc.cob ocdoc.rst *><* $ ./ocdoc ocdoc.cob ocdoc.rst *><+ ocdoc.html skin.css -fixed *><* ... *><* Input : ocdoc.cob *><* Output : ocdoc.rst *><* Command: rst2html --stylesheet=skin.css *><+ ocdoc.rst ocdoc.html *><* *><* ----------------- *><* What is extracted *><* ----------------- *><* - Lines that begin with \*><\* *ignoring spaces*, are *><+ extracted. *><* *><* - Lines that begin with \*><+ are appended to the *><+ previous output line. As lines are trimmed of trailing *><+ spaces, and *ocdoc* removes the space following the *><+ extract triggers, you may need two spaces after an *><+ ocdoc append. *><* *><* - Lines that begin with \*><[ begin a here document *><+ with lines that follow extracted as is. *><* *><* - Lines that begin with \*><] close a here document. *><+ Here document start and end lines are excluded from the *><+ extract. *><* *><* ----------- *><* Source code *><* ----------- *><* `Download ocdoc.cob *><+ <http://opencobol.add1tocobol.com/ocdoc.cob>`_ *><* `See ocdocseq.cob *><+ <http://opencobol.add1tocobol.com/ocdocseq.html>`_ *><* *><! This is not extracted. Reminder of how to include source *><! .. include:: ocdoc.cob *><! :literal: *><* *><* ----------------------- *><* identification division *><* ----------------------- *><* *><* :: *><* *><[ identification division. program-id. OCDOC. environment division. input-output section. file-control. select standard-input assign to KEYBOARD. select standard-output assign to DISPLAY. select source-input assign to source-name organization is line sequential . select doc-output assign to doc-name organization is line sequential . *><] *><* *><* ------------- *><* data division *><* ------------- *><* *><* :: *><* *><[ data division. file section. fd standard-input. 01 stdin-record pic x(256). fd standard-output. 01 stdout-record pic x(256). fd source-input. 01 source-record pic x(256). fd doc-output. 01 doc-record pic x(256). 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. *><] *><* *><* Note the conditional test for end of here doc *><* *><* :: *><* *><[ 01 trimmed pic x(256). 88 herestart value "*><[". 88 hereend value "*><]". 01 hereflag pic x value low-value. 88 heredoc value high-value. 88 herenone value low-value. *><] *><* *><* Note the here-record adds an ocdoc extract to lines that *><+ follow. *><* *><* :: *><* *><[ 01 here-record. 02 filler pic x(5) value "*><* ". 02 here-data pic x(251). 01 seq-record. 02 filler pic x(7) value " ". 02 seq-data pic x(249). 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. 01 first-part pic x(8). 88 special values "*><*" "*><+". 88 autodoc value "*><*". 88 autoappend value "*><+". 01 rst-command pic x(256). 01 result usage binary-long. *><] *><* *><* ------------------ *><* procedure division *><* ------------------ *><* *><* :: *><* *><[ *> *************************************************************** procedure division. *><] *><* *><* Accept command line arguments. See if help requested. *><* *><* :: *><* *><[ accept arguments from command-line end-accept 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 *><] *><* *><* Either run as filter or open given files. Two filenames *><+ will generate an extract. Three will run the extract *><+ through *rst2html* using an optional fourth filename *><+ as a stylesheet. *><* *><* :: *><* *><[ *> 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 open input source-input open output doc-output else set filtering to true open input standard-input open output standard-output end-if *><] *><* *><* Initialize the output buffer, and line count. *><* *><* :: *><* *><[ set buffer-empty to true move 1 to buffer-offset move spaces to doc-record move 0 to line-count *><] *><* *><* The read is either from file or stdin. Start with the *><+ first record. *><* *><* :: *><* *><[ *> 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 *><] *><* *><* The main loop starts here, having done a pre-read to start *><+ things off. *><* *><* :: *><* *><[ perform until source-record = high-values add 1 to line-count *><] *><* *><* Small wrinkle if processing fixed form with sequence numbers, *><+ as the heredoc end marker needs to be recognized *><+ but we still want the sequence numbers in the heredoc. *><* *><* So files processed --fixed play some data shuffling games. *><* *><* :: *><* *><[ 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 *><] *><* *><* First to check for here doc start and end, setting flag *><+ if trimmed conditional the heredoc start or heredoc end *><+ strings. *><* *><* :: *><* *><[ if herestart set heredoc to true end-if if hereend set herenone to true end-if *><] *><* *><* Inside the loop, we skip over heredoc entries. *><+ If it is normal, than check for heredoc and include *><+ source lines that follow, by prepending the extract tag *><* *><* :: *><* *><[ if (not herestart) and (not hereend) if heredoc move source-record to here-data move here-record to trimmed end-if *><] *><* *><* Unstring the line, looking for special tags in the first *><+ part. *><* *><* :: *><* *><[ unstring trimmed delimited by all spaces into first-part count in counter end-unstring *><] *><* *><* If special, we either buffer or append to buffer *><* *><* :: *><* *><[ evaluate true when special if autoappend and buffer-empty move spaces to doc-record move 1 to buffer-offset end-if if autodoc and buffered-output 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 set buffer-empty to true move 1 to buffer-offset end-if *><] *><* *><* Skip over where the tag was found plus an extra space. *><* Adding 2 skips over the assumed space after a special tag *><* *><* :: *><* *><[ add 2 to counter compute len-of-comment = function length(trimmed) - counter end-compute if len-of-comment > 0 move trimmed(counter : len-of-comment) to doc-buffer else move spaces to doc-buffer end-if *><] *><* *><* Buffer the line, either to position 1 or appending to last. *><* *><* :: *><* *><[ 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 "*** truncation *** reading line " line-display end-display end-string set buffered-output to true end-evaluate end-if *><] *><* *><* Again, we either read the next record from file or stdin. *><* *><* :: *><* *><[ 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 *><] *><* *><* We may or may not end up with buffered data *><* *><* :: *><* *><[ 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 *><] *><* *><* Close the OpenCOBOL files *><* *><* :: *><* *><[ if filtering close standard-output close standard-input else close doc-output close source-input end-if if verbose display "Input : " function trim(source-name) end-display display "Output : " function trim(doc-name) end-display end-if *><] *><* *><* If we have a result file, use the SYSTEM service to *><+ generate an HTML file, possibly with stylesheet. *><* *><* :: *><* *><[ *> pass the extract through a markover, 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 if verbose display "Command: " function trim(rst-command trailing) end-display end-if call "SYSTEM" using rst-command returning result end-call if result not equal zero display "HTML generate failed: " result end-display end-if end-if *><] *><* *><* And before you know it, we are done. *><* *><* :: *><* *><[ goback. end program OCDOC. *><] *><* *><* Don't forget to visit http://opencobol.org *><* *><* Cheers *><* *><* *Last edit:* 03-Oct-2008 See [http://opencobol.add1tocobol.com/ocdoc.html|ocdoc.html] for the output from processing ''ocdoc.cob'' with __ocdoc__. [#id58|3.13   Q. Does OpenCOBOL support any SQL databases?] Yes and no. There is no embedded SQL in OpenCOBOL. There are early prototypes for SQLite at [http://opencobol.add1tocobol.com/ocshell.c|ocshell.c] with a sample usage program at [http://opencobol.add1tocobol.com/sqlscreen.cob|sqlscreen.cob] and supporting documentation at [http://opencobol.add1tocobol.com/sqlscreen.html|sqlscreen.html] There are currently ''(August 2008)'' quite a few active developments for external SQL engine access. Rumours of Postgres and libdbi wrappers abound. [#id59|3.14   Q. What are the OpenCOBOL RESERVED WORDS?] [http://en.wikipedia.org/wiki/COBOL|COBOL] is a reserved word rich language. The OpenCOBOL compiler recognizes: Reserved Words * [#accept|ACCEPT] * ENTRY * POINTER * [#access|ACCESS] # ENTRY-CONVENTION * POSITION # [#active-class|ACTIVE-CLASS] * ENVIRONMENT * POSITIVE * [#add|ADD] * ENVIRONMENT-NAME # PRESENT * [#address|ADDRESS] * ENVIRONMENT-VALUE * PREVIOUS * [#advancing|ADVANCING] # EO * PRINTER * [#after|AFTER] * EOL # PRINTING # ALIGNED * EOP * PROCEDURE * [#all|ALL] * EOS * PROCEDURE-POINTER * [#allocate|ALLOCATE] * EQUAL * PROCEDURES * [#alphabet|ALPHABET] * EQUALS * PROCEED * ALPHABETIC * ERASE * PROGRAM * ALPHABETIC-LOWER * ERROR * PROGRAM-ID * ALPHABETIC-UPPER * ESCAPE * PROGRAM-POINTER * ALPHANUMERIC # ESI * PROMPT * ALPHANUMERIC-EDITED * EVALUATE # PROPERTY * ALSO * EXCEPTION # PROTOTYPE * ALTER # EXCEPTION-OBJECT # PURGE * ALTERNATE * EXCLUSIVE # QUEUE * AND * EXIT * QUOTE * ANY # EXPANDS * QUOTES # ANYCASE * EXTEND # RAISE * ARE * EXTERNAL # RAISING * AREA # FACTORY * RANDOM * AREAS * FALSE # RD * ARGUMENT-NUMBER * FD * READ * ARGUMENT-VALUE * FILE # RECEIVE # ARITHMETIC * FILE-CONTROL * RECORD * AS * FILE-ID * RECORDING * ASCENDING * FILLER * RECORDS * ASSIGN # FINAL * RECURSIVE * AT * FIRST * REDEFINES # ATTRIBUTE # FLOAT-EXTENDED * REEL * AUTO * FLOAT-LONG * REFERENCE * AUTO-SKIP * FLOAT-SHORT # RELATION * AUTOMATIC * FOOTING * RELATIVE * AUTOTERMINATE * FOR * RELEASE # B-AND * FOREGROUND-COLOR * REMAINDER # B-NOT # FOREVER * REMOVAL # B-OR # FORMAT * RENAMES # B-XOR * FREE # REPLACE * BACKGROUND-COLOR * FROM * REPLACING * [#based|BASED] * FULL # REPORT * [#beep|BEEP] * [#function|FUNCTION] # REPORTING * BEFORE # FUNCTION-ID # REPORTS * [#bell|BELL] # GENERATE # REPOSITORY * BINARY # GET * REQUIRED * BINARY-C-LONG * [#giving|GIVING] * RESERVE * BINARY-CHAR * GLOBAL # RESET * BINARY-DOUBLE * GO # RESUME * BINARY-LONG * [#goback|GOBACK] # RETRY * BINARY-SHORT * GREATER * RETURN # BIT # GROUP * RETURNING * [#blank|BLANK] # GROUP-USAGE * REVERSE-VIDEO * BLINK # HEADING * REWIND * BLOCK * HIGH-VALUE * REWRITE # BOOLEAN * HIGH-VALUES # RF * BOTTOM * HIGHLIGHT # RH * BY * I-O * RIGHT # BYTE-LENGTH * I-O-CONTROL * ROLLBACK * [#call|CALL] * ID * ROUNDED * CANCEL * IDENTIFICATION * RUN # CD * IF * SAME # CENTER * IGNORING * SCREEN # CF # IMPLEMENTS * SD # CH * IN * SEARCH # CHAIN * INDEX # SECONDS * CHAINING * INDEXED * SECTION * CHARACTER # INDICATE * SECURE * CHARACTERS # INHERITS # SEGMENT * CLASS * INITIAL * SELECT # CLASS-ID * INITIALIZE # SELF # CLASSIFICATION * INITIALIZED # SEND * CLOSE # INITIATE * SENTENCE # CODE * INPUT * SEPARATE * CODE-SET * INPUT-OUTPUT * SEQUENCE * COL * INSPECT * SEQUENTIAL * COLLATING # INTERFACE * SET * COLS # INTERFACE-ID * SHARING * COLUMN * INTO * SIGN * COLUMNS # INTRINSIC * SIGNED * COMMA * INVALID * SIGNED-INT * COMMAND-LINE # INVOKE * SIGNED-LONG * COMMIT * IS * SIGNED-SHORT * COMMON * JUST * SIZE # COMMUNICATION * JUSTIFIED * [#sort|SORT] * COMP * KEY * SORT-MERGE * COMP-1 * LABEL * SOURCE * COMP-2 # LAST * SOURCE-COMPUTER * COMP-3 # LC_ALL # SOURCES * COMP-4 # LC_COLLATE * SPACE * COMP-5 # LC_CTYPE * SPACES * COMP-X # LC_MESSAGES * [#special-names|SPECIAL-NAMES] * COMPUTATIONAL # LC_MONETARY * STANDARD * COMPUTATIONAL-1 # LC_NUMERIC * STANDARD-1 * COMPUTATIONAL-2 # LC_TIME * STANDARD-2 * COMPUTATIONAL-3 * LEADING * START * COMPUTATIONAL-4 * LEFT # STATEMENT * COMPUTATIONAL-5 * LENGTH * STATUS * COMPUTATIONAL-X * LESS # STEP * COMPUTE # LIMIT * STOP # CONDITION # LIMITS * STRING * CONFIGURATION * LINAGE # STRONG * CONSTANT * [#linage-counter|LINAGE-COUNTER] # SUB-QUEUE-1 * CONTAINS * LINE # SUB-QUEUE-2 * CONTENT # LINE-COUNTER # SUB-QUEUE-3 * CONTINUE * LINES * SUBTRACT # CONTROL * LINKAGE # SUM # CONTROLS * LOCAL-STORAGE # SUPER * CONVERTING * LOCALE # SUPPRESS * COPY * LOCK # SYMBOL * CORR * LOW-VALUE * SYMBOLIC * CORRESPONDING * LOW-VALUES * SYNC * COUNT * LOWLIGHT * SYNCHRONIZED * CRT * MANUAL # SYSTEM-DEFAULT * CURRENCY * MEMORY # TABLE * CURSOR * MERGE * TALLYING * CYCLE # MESSAGE * TAPE * DATA # METHOD # TERMINAL # DATA-POINTER # METHOD-ID # TERMINATE * DATE * MINUS * TEST * DAY * MODE # TEXT * DAY-OF-WEEK * MOVE * THAN # DE * MULTIPLE * THEN * DEBUGGING * MULTIPLY * THROUGH * DECIMAL-POINT * NATIONAL * THRU * DECLARATIVES * NATIONAL-EDITED * TIME * DEFAULT * NATIVE * TIMES * DELETE * NEGATIVE * TO * DELIMITED # NESTED * TOP * DELIMITER * NEXT * TRAILING * DEPENDING * NO * TRUE * DESCENDING # NONE # TYPE # DESTINATION # NORMAL # TYPEDEF # DETAIL * NOT # UCS-4 # DISABLE * NULL * UNDERLINE * DISK * NULLS * UNIT * DISPLAY * NUMBER # UNIVERSAL * DIVIDE * NUMBERS * UNLOCK * DIVISION * NUMERIC * UNSIGNED * DOWN * NUMERIC-EDITED * UNSIGNED-INT * DUPLICATES # OBJECT * UNSIGNED-LONG * DYNAMIC * OBJECT-COMPUTER * UNSIGNED-SHORT * [#ebcdic|EBCDIC] # OBJECT-REFERENCE * UNSTRING # EC * OCCURS * UNTIL # EGI * OF * UP * ELSE * OFF * UPDATE # EMI * OMITTED * UPON # ENABLE * ON * [#usage|USAGE] * END * ONLY * USE * END-ACCEPT * OPEN # USER-DEFAULT * END-ADD * OPTIONAL * USING * END-CALL # OPTIONS # UTF-16 * END-COMPUTE * OR # UTF-8 * END-DELETE * ORDER # VAL-STATUS * END-DISPLAY * ORGANIZATION # VALID * END-DIVIDE * OTHER # VALIDATE * END-EVALUATE * OUTPUT # VALIDATE-STATUS * END-IF * OVERFLOW * VALUE * END-MULTIPLY * OVERLINE * VALUES * END-OF-PAGE # OVERRIDE * VARYING * END-PERFORM * PACKED-DECIMAL * WHEN * END-READ * PADDING * WITH # END-RECEIVE * PAGE * WORKING-STORAGE * END-RETURN # PAGE-COUNTER * WRITE * END-REWRITE * PARAGRAPH * YYYYDDD * END-SEARCH * PERFORM * YYYYMMDD * END-START # PF * ZERO * END-STRING # PH * ZEROES * END-SUBTRACT * PIC * ZEROS * END-UNSTRING * [#picture|PICTURE] * END-WRITE * PLUS 514 words in OC 1.1, 136 of which are marked not yet implemented. 378 functional reserved words, as of August 2008. 3.14.1   ACCEPT ACCEPT variable FROM CONSOLE. ACCEPT variable FROM ENVIRONMENT "path". ACCEPT variable FROM COMMAND LINE. ACCEPT screen-variable. 3.14.2   ACCESS SELECT filename ASSIGN TO "filename.dat" ACCESS MODE IS RANDOM RELATIVE KEY IS keyfield. 3.14.3   ACTIVE-CLASS Not yet implemented. Object COBOL feature. 3.14.4   ADD ADD 1 TO cobol GIVING OpenCOBOL END-ADD. 3.14.5   ADDRESS SET pointer-variable TO ADDRESS OF linkage-store. 3.14.6   ADVANCING DISPLAY "Legend: " WITH NO ADVANCING END-DISPLAY. WRITE printrecord AFTER ADVANCING PAGE END-WRITE. 3.14.7   AFTER PERFORM WITH TEST AFTER VARYING variable FROM 1 BY 1 UNTIL variable > 10 DISPLAY variable END-DISPLAY END-PERFORM. 3.14.8   ALIGNED3.14.9   ALL INSPECT variable REPLACING ALL "123" WITH "456". 3.14.10   ALLOCATE ALLOCATE based-var INITIALIZED RETURNING pointer-var. 3.14.11   ALPHABET * Set up for a mixed case SORT COLLATING SEQUENCE IS CONFIGURATION SECTION. SPECIAL-NAMES. ALPHABET name IS "AaBbCcDdEe..". 3.14.12   ALPHABETIC IF variable IS ALPHABETIC DISPLAY "alphabetic" END-DISPLAY END-IF 3.14.13   ALPHABETIC-LOWER IF variable IS ALPHABETIC-LOWER DISPLAY "alphabetic-lower" END-DISPLAY END-IF 3.14.14   ALPHABETIC-UPPER DISPLAY variable "alphabetic-upper " WITH NO ADVANCING IF variable IS ALPHABETIC-UPPER DISPLAY "true" END-DISPLAY ELSE DISPLAY "false" END-DISPLAY END-IF 3.14.15   ALPHANUMERIC3.14.16   ALPHANUMERIC-EDITED3.14.17   ALSO3.14.18   ALTER3.14.19   ALTERNATE3.14.20   AND3.14.21   ANY3.14.22   ANYCASE3.14.23   ARE3.14.24   AREA3.14.25   AREAS3.14.26   ARGUMENT-NUMBER3.14.27   ARGUMENT-VALUE3.14.28   ARITHMETIC3.14.29   ASx3.14.30   ASCENDING3.14.31   ASSIGN3.14.32   ATx3.14.33   ATTRIBUTE3.14.34   AUTO3.14.35   AUTO-SKIP3.14.36   AUTOMATIC3.14.37   AUTOTERMINATE3.14.38   B-AND3.14.39   B-NOT3.14.40   B-OR3.14.41   B-XOR3.14.42   BACKGROUND-COLOR 05 BLANK SCREEN BACKGROUND-COLOR 7 FOREGROUND-COLOR 0. 3.14.43   BASED 01 based-var PIC X(80) BASED. A sample posted by [#human|[human]]: *----------------------------------------------------------------- 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. * 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). *----------------------------------------------------------------- LINKAGE SECTION. *----------------------------------------------------------------- PROCEDURE DIVISION. declaratives. end declaratives. *----------------------------------------------------------------- main section. 00. FREE ADDRESS OF REC-TEST display 'MEMALL loaded and REC-TEST FREEd before ALLOCATE' accept mychar * IF ADDRESS OF REC-TEST = NULL display 'REC-TEST was not allocated before' ELSE display 'REC-TEST was allocated before' END-IF accept mychar * ALLOCATE REC-TEST move all '9' to REC-TEST display 'REC-TEST allocated and filled with ' REC-TEST (1:9) end-display accept mychar * IF ADDRESS OF REC-TEST = NULL display 'REC-TEST was not allocated before' ALLOCATE REC-TEST display 'REC-TEST allocated again, filled with ' REC-TEST (1:9) end-display ELSE display 'REC-TEST was allocated before' END-IF accept mychar * * FREE ADDRESS OF REC-TEST display 'REC-TEST FREEd' accept mychar * stop run * continue. ex. exit program. *----------------------------------------------------------------- *--- End of program MEMALL --------------------------------------- 3.14.44   BEEP DISPLAY "Beeeeep" LINE 3 COLUMN 1 WITH BEEP END-DISPLAY. 3.14.45   BEFORE3.14.46   BELL DISPLAY "Beeeeep" LINE 3 COLUMN 1 WITH BELL END-DISPLAY. 3.14.47   BINARY3.14.48   BINARY-C-LONG3.14.49   BINARY-CHAR3.14.50   BINARY-DOUBLE3.14.51   BINARY-LONG3.14.52   BINARY-SHORT3.14.53   BIT3.14.54   BLANK 05 BLANK SCREEN BACKGROUND-COLOR 7 FOREGROUND-COLOR 0. 3.14.55   BLINK3.14.56   BLOCK3.14.57   BOOLEAN3.14.58   BOTTOM3.14.59   BYx3.14.60   BYTE-LENGTH3.14.61   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|PICTURE] and [#usage|USAGE] clauses. Return values are captured with RETURNING identifier. See [#q-what-stock-call-library-does-opencobol-offer|Q. What STOCK CALL LIBRARY does OpenCOBOL offer?]. For more information see [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] 3.14.62   CANCEL3.14.63   CDx3.14.64   CENTER3.14.65   CFx3.14.66   CHx3.14.67   CHAIN3.14.68   CHAINING3.14.69   CHARACTER3.14.70   CHARACTERS3.14.71   CLASS3.14.72   CLASS-ID3.14.73   CLASSIFICATION3.14.74   CLOSE3.14.75   CODE3.14.76   CODE-SET3.14.77   COL3.14.78   COLLATING3.14.79   COLS3.14.80   COLUMN3.14.81   COLUMNS3.14.82   COMMA3.14.83   COMMAND-LINE3.14.84   COMMIT3.14.85   COMMON3.14.86   COMMUNICATION3.14.87   COMP3.14.88   COMP-13.14.89   COMP-23.14.90   COMP-33.14.91   COMP-43.14.92   COMP-53.14.93   COMP-X3.14.94   COMPUTATIONAL3.14.95   COMPUTATIONAL-13.14.96   COMPUTATIONAL-23.14.97   COMPUTATIONAL-33.14.98   COMPUTATIONAL-43.14.99   COMPUTATIONAL-53.14.100   COMPUTATIONAL-X3.14.101   COMPUTE3.14.102   CONDITION3.14.103   CONFIGURATION3.14.104   CONSTANT3.14.105   CONTAINS3.14.106   CONTENT3.14.107   CONTINUE3.14.108   CONTROL3.14.109   CONTROLS3.14.110   CONVERTING3.14.111   COPY3.14.112   CORR3.14.113   CORRESPONDING3.14.114   COUNT3.14.115   CRT3.14.116   CURRENCY3.14.117   CURSOR3.14.118   CYCLE3.14.119   DATA3.14.120   DATA-POINTER3.14.121   DATE3.14.122   DAY3.14.123   DAY-OF-WEEK3.14.124   DEx3.14.125   DEBUGGING3.14.126   DECIMAL-POINT3.14.127   DECLARATIVES3.14.128   DEFAULT3.14.129   DELETE3.14.130   DELIMITED3.14.131   DELIMITER3.14.132   DEPENDING3.14.133   DESCENDING3.14.134   DESTINATION3.14.135   DETAIL3.14.136   DISABLE3.14.137   DISK3.14.138   DISPLAY3.14.139   DIVIDE3.14.140   DIVISION3.14.141   DOWN3.14.142   DUPLICATES3.14.143   DYNAMIC3.14.144   EBCDIC Extended Binary Coded Decimal Interchange Code. A character encoding common to mainframe systems, therefore COBOL, therefore OpenCOBOL. Different than [#ascii|ASCII] and OpenCOBOL supports both through efficient mappings. See [http://en.wikipedia.org/wiki/EBCDIC] for more info. ASCII to EBCDIC conversion the OpenCOBOL way: SPECIAL-NAMES. ALPHABET ALPHA IS NATIVE. ALPHABET BETA IS EBCDIC. PROCEDURE DIVISION. INSPECT variable CONVERTING ALPHA TO BETA 3.14.145   ECx3.14.146   EGI3.14.147   ELSE3.14.148   EMI3.14.149   ENABLE3.14.150   END3.14.151   END-ACCEPT3.14.152   END-ADD3.14.153   END-CALL3.14.154   END-COMPUTE3.14.155   END-DELETE3.14.156   END-DISPLAY3.14.157   END-DIVIDE3.14.158   END-EVALUATE3.14.159   END-IF3.14.160   END-MULTIPLY3.14.161   END-OF-PAGE3.14.162   END-PERFORM3.14.163   END-READ3.14.164   END-RECEIVE3.14.165   END-RETURN3.14.166   END-REWRITE3.14.167   END-SEARCH3.14.168   END-START3.14.169   END-STRING3.14.170   END-SUBTRACT3.14.171   END-UNSTRING3.14.172   END-WRITE3.14.173   ENTRY3.14.174   ENTRY-CONVENTION3.14.175   ENVIRONMENT3.14.176   ENVIRONMENT-NAME3.14.177   ENVIRONMENT-VALUE3.14.178   EOx3.14.179   EOL3.14.180   EOP3.14.181   EOS3.14.182   EQUAL3.14.183   EQUALS3.14.184   ERASE3.14.185   ERROR3.14.186   ESCAPE3.14.187   ESI3.14.188   EVALUATE3.14.189   EXCEPTION3.14.190   EXCEPTION-OBJECT3.14.191   EXCLUSIVE3.14.192   EXIT3.14.193   EXPANDS3.14.194   EXTEND3.14.195   EXTERNAL3.14.196   FACTORY3.14.197   FALSE3.14.198   FDx3.14.199   FILE3.14.200   FILE-CONTROL3.14.201   FILE-ID3.14.202   FILLER3.14.203   FINAL3.14.204   FIRST3.14.205   FLOAT-EXTENDED3.14.206   FLOAT-LONG3.14.207   FLOAT-SHORT3.14.208   FOOTING3.14.209   FOR3.14.210   FOREGROUND-COLOR3.14.211   FOREVER3.14.212   FORMAT3.14.213   FREE3.14.214   FROM3.14.215   FULL3.14.216   FUNCTION DISPLAY FUNCTION TRIM(" trim off leading spaces" LEADING) END-DISPLAY. 3.14.217   FUNCTION-ID3.14.218   GENERATE3.14.219   GET3.14.220   GIVING ADD 1 TO cobol GIVING OpenCOBOL. 3.14.221   GLOBAL3.14.222   GOx3.14.223   GOBACK GOBACK. 3.14.224   GREATER3.14.225   GROUP3.14.226   GROUP-USAGE3.14.227   HEADING3.14.228   HIGH-VALUE3.14.229   HIGH-VALUES3.14.230   HIGHLIGHT3.14.231   I-O3.14.232   I-O-CONTROL3.14.233   IDx3.14.234   IDENTIFICATION3.14.235   IFx3.14.236   IGNORING3.14.237   IMPLEMENTS3.14.238   INx3.14.239   INDEX3.14.240   INDEXED3.14.241   INDICATE3.14.242   INHERITS3.14.243   INITIAL3.14.244   INITIALIZE A sample of the INITIALIZE verb posted [http://opencobol.org/|opencobol.org] by [#human|human] *----------------------------------------------------------------- IDENTIFICATION DIVISION. PROGRAM-ID. 'INITTEST'. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. DECIMAL-POINT IS COMMA. INPUT-OUTPUT SECTION. DATA DIVISION. * WORKING-STORAGE SECTION. * 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 '.'. *----------------------------------------------------------------- LINKAGE SECTION. *----------------------------------------------------------------- PROCEDURE DIVISION. *----------------------------------------------------------------- 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. *----------------------------------------------------------------- *--- End of program INITTEST ------------------------------------- 3.14.245   INITIALIZED3.14.246   INITIATE3.14.247   INPUT3.14.248   INPUT-OUTPUT3.14.249   INSPECT3.14.250   INTERFACE3.14.251   INTERFACE-ID3.14.252   INTO3.14.253   INTRINSIC3.14.254   INVALID3.14.255   INVOKE3.14.256   ISx3.14.257   JUST3.14.258   JUSTIFIED3.14.259   KEY3.14.260   KEYBOARD A special value for Standard Input: file-control. select cgi-in assign to keyboard. 3.14.261   LABEL3.14.262   LAST3.14.263   LC_ALL3.14.264   LC_COLLATE3.14.265   LC_CTYPE3.14.266   LC_MESSAGES3.14.267   LC_MONETARY3.14.268   LC_NUMERIC3.14.269   LC_TIME3.14.270   LEADING3.14.271   LEFT3.14.272   LENGTH3.14.273   LESS3.14.274   LIMIT3.14.275   LIMITS3.14.276   LINAGE3.14.277   LINAGE-COUNTER An internal OpenCOBOL noun, or ''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. 3.14.278   LINE3.14.279   LINE-COUNTER3.14.280   LINES3.14.281   LINKAGE3.14.282   LOCAL-STORAGE3.14.283   LOCALE3.14.284   LOCK3.14.285   LOW-VALUE3.14.286   LOW-VALUES3.14.287   LOWLIGHT3.14.288   MANUAL3.14.289   MEMORY3.14.290   MERGE3.14.291   MESSAGE3.14.292   METHOD3.14.293   METHOD-ID3.14.294   MINUS3.14.295   MODE3.14.296   MOVE3.14.297   MULTIPLE3.14.298   MULTIPLY3.14.299   NATIONAL3.14.300   NATIONAL-EDITED3.14.301   NATIVE3.14.302   NEGATIVE3.14.303   NESTED3.14.304   NEXT3.14.305   NOx3.14.306   NONE3.14.307   NORMAL3.14.308   NOT3.14.309   NULL3.14.310   NULLS3.14.311   NUMBER3.14.312   NUMBERS3.14.313   NUMERIC3.14.314   NUMERIC-EDITED3.14.315   OBJECT3.14.316   OBJECT-COMPUTER3.14.317   OBJECT-REFERENCE3.14.318   OCCURS3.14.319   OFx3.14.320   OFF3.14.321   OMITTED3.14.322   ONx3.14.323   ONLY3.14.324   OPEN3.14.325   OPTIONAL3.14.326   OPTIONS3.14.327   ORx3.14.328   ORDER3.14.329   ORGANIZATION3.14.330   OTHER3.14.331   OUTPUT3.14.332   OVERFLOW3.14.333   OVERLINE3.14.334   OVERRIDE3.14.335   PACKED-DECIMAL3.14.336   PADDING3.14.337   PAGE3.14.338   PAGE-COUNTER3.14.339   PARAGRAPH3.14.340   PERFORM3.14.341   PFx3.14.342   PHx3.14.343   PIC3.14.344   PICTURE Full standards support of all alpha, alphanumeric and numeric storage specifiers as well as full support for edit and numeric-edit clauses. An example of some of the PICTURE options: *>>source format is free *>********************************************************************* *> Author: jrls (John Ellis) *> Date: Oct-2008 *> Purpose: formated output examples using pic strings. *>********************************************************************* identification division. program-id. picstring. data division. working-storage section. *> 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". *> 01 headerLines pic x(90) value all "-". *> 01 displayformats. 05 linenum pic 99 value 1. 05 disp1 pic zzz,zz9.99 value zero. 05 filler pic x value spaces. 05 disp2 pic $zz,zz9.99 value zero. 05 filler pic x value spaces. 05 disp3 pic ---,--9.99 value zero. 05 filler pic x value spaces. 05 disp4 pic $-z,zz9.99 value zero. 05 filler pic x value spaces. 05 disp5 pic -zz,zz9.zz- blank zero value zero. 05 filler pic x value spaces. *><*an1 is actually a string field because of the embedded blanks, 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. *> display headerLines. display header. display headerLines. *><**************************************************** move 220.22 to disp1, disp2. move -220.22 to disp3, disp4, disp5. inspect disp5 replacing first "-" by "(", first "-" by ")". move 10122008 to dispdate. *><**************************************************** *><*Please note the results of moving 'abcd' to an1. *><*an1 will show up as 00 00 00 because alpha data was *><*moved into instead of numeric data. *><* *><*The phone field will display " abc def ghij" because *><*'b' in the pic string. *><**************************************************** move "abcd" to an1. move "abcdefghij" to phone. display displayformats. add 1 to linenum. move zero to disp4, disp5. *><**************************************************** *><*Here after moving data to an1 and phone, I use the *><*inspect statement to replace the blanks. *><**************************************************** move "123456" to an1. move "5555551234" to phone. inspect an1 replacing all " " by "-". inspect phone replacing first " " by "(", first " " by ")", first " " by "-". display displayformats. inspect phone converting "23456789" to "adgjmptw". display phone. perform 0010-endProgram. *> 0010-endProgram. stop run. *> Outputs: ------------------------------------------------------------------------------------------ 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 3.14.345   PLUS3.14.346   POINTER 01 C-HANDLE USAGE IS POINTER. CALL "open-lib" USING C-HANDLE 3.14.347   POSITION3.14.348   POSITIVE3.14.349   PRESENT3.14.350   PREVIOUS3.14.351   PRINTER3.14.352   PRINTING3.14.353   PROCEDURE3.14.354   PROCEDURE-POINTER3.14.355   PROCEDURES3.14.356   PROCEED3.14.357   PROGRAM3.14.358   PROGRAM-ID3.14.359   PROGRAM-POINTER3.14.360   PROMPT3.14.361   PROPERTY3.14.362   PROTOTYPE3.14.363   PURGE3.14.364   QUEUE3.14.365   QUOTE3.14.366   QUOTES3.14.367   RAISE3.14.368   RAISING3.14.369   RANDOM3.14.370   RDx3.14.371   READ3.14.372   RECEIVE3.14.373   RECORD3.14.374   RECORDING3.14.375   RECORDS3.14.376   RECURSIVE3.14.377   REDEFINES3.14.378   REEL3.14.379   REFERENCE3.14.380   RELATION3.14.381   RELATIVE3.14.382   RELEASE3.14.383   REMAINDER3.14.384   REMOVAL3.14.385   RENAMES3.14.386   REPLACE3.14.387   REPLACING3.14.388   REPORT3.14.389   REPORTING3.14.390   REPORTS3.14.391   REPOSITORY3.14.392   REQUIRED3.14.393   RESERVE3.14.394   RESET3.14.395   RESUME3.14.396   RETRY3.14.397   RETURN3.14.398   RETURNING3.14.399   REVERSE-VIDEO3.14.400   REWIND3.14.401   REWRITE3.14.402   RFx3.14.403   RHx3.14.404   RIGHT3.14.405   ROLLBACK3.14.406   ROUNDED3.14.407   RUN3.14.408   SAME3.14.409   SCREEN3.14.410   SDx3.14.411   SEARCH3.14.412   SECONDS3.14.413   SECTION3.14.414   SECURE3.14.415   SEGMENT3.14.416   SELECT3.14.417   SELF3.14.418   SEND3.14.419   SENTENCE3.14.420   SEPARATE3.14.421   SEQUENCE3.14.422   SEQUENTIAL3.14.423   SET3.14.424   SHARING3.14.425   SIGN3.14.426   SIGNED3.14.427   SIGNED-INT3.14.428   SIGNED-LONG3.14.429   SIGNED-SHORT3.14.430   SIZE3.14.431   SORT * 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. Here is a snippet describing TABLE sorts by [#jrls-swla|[jrls_swla]] table define 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, 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. 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. table load perform varying rows from 1 by 1 until rows > dbNumRows call "dbNextRow" using by value dbResult, by reference ColumnBuff, 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-perform. table sort sort tables-columns ascending key tcTable, tcColumn. display table 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-perform. 3.14.432   SORT-MERGE3.14.433   SORT-RETURN A ''SPECIAL-REGISTER'' used by the OpenCOBOL SORT routines. * +000000000 for success * +000000016 for failure A programmer may set SORT-RETURN in an INPUT PROCEDURE. 3.14.434   SOURCE3.14.435   SOURCE-COMPUTER3.14.436   SOURCES3.14.437   SPACE3.14.438   SPACES3.14.439   SPECIAL-NAMES OpenCOBOL supports a fair complete set of the SPECIAL-NAMES in common use. 3.14.440   STANDARD3.14.441   STANDARD-13.14.442   STANDARD-23.14.443   START3.14.444   STATEMENT3.14.445   STATUS3.14.446   STEP3.14.447   STOP3.14.448   STRING3.14.449   STRONG3.14.450   SUB-QUEUE-13.14.451   SUB-QUEUE-23.14.452   SUB-QUEUE-33.14.453   SUBTRACT3.14.454   SUM3.14.455   SUPER3.14.456   SUPPRESS3.14.457   SYMBOL3.14.458   SYMBOLIC3.14.459   SYNC3.14.460   SYNCHRONIZED3.14.461   SYSTEM-DEFAULT3.14.462   TABLE3.14.463   TALLYING3.14.464   TAPE3.14.465   TERMINAL3.14.466   TERMINATE3.14.467   TEST3.14.468   TEXT3.14.469   THAN3.14.470   THEN3.14.471   THROUGH3.14.472   THRU3.14.473   TIME3.14.474   TIMES3.14.475   TOx3.14.476   TOPx3.14.477   TRAILING3.14.478   TRUE3.14.479   TYPE3.14.480   TYPEDEF3.14.481   UCS-43.14.482   UNDERLINE3.14.483   UNIT3.14.484   UNIVERSAL3.14.485   UNLOCK3.14.486   UNSIGNED3.14.487   UNSIGNED-INT3.14.488   UNSIGNED-LONG3.14.489   UNSIGNED-SHORT3.14.490   UNSTRING3.14.491   UNTIL3.14.492   UPx3.14.493   UPDATE3.14.494   UPON3.14.495   USAGE OpenCOBOL uses standard [#big-endian|big-endian] internal storage by default. USAGE clauses influence the data representation. The INTEL architecture uses [#little-endian|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, 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 [http://en.wikipedia.org/wiki/COBOL|COBOL] [#picture|PICTURE] clauses both storage and display, OpenCOBOL supports USAGE clauses of: * BINARY * COMPUTATIONAL, COMP * COMP-1 * COMP-2 * COMP-3 * COMP-4 * COMP-5 * COMP-X * DISPLAY * INDEX * PACKED-DECIMAL * POINTER * PROGRAM-POINTER * SIGNED-SHORT * SIGNED-INT * SIGNED-LONG * UNSIGNED-SHORT * UNSIGNED-INT * UNSIGNED-LONG * BINARY-CHAR SIGNED * BINARY-CHAR UNSIGNED * BINARY-CHAR * BINARY-SHORT SIGNED * BINARY-SHORT UNSIGNED * BINARY-SHORT * BINARY-LONG SIGNED * BINARY-LONG UNSIGNED * BINARY-LONG * BINARY-DOUBLE SIGNED * BINARY-DOUBLE UNSIGNED * BINARY-DOUBLE * BINARY-C-LONG SIGNED * BINARY-C-LONG UNSIGNED * BINARY-C-LONG 3.14.496   USE3.14.497   USER-DEFAULT3.14.498   USING3.14.499   UTF-163.14.500   UTF-83.14.501   VAL-STATUS3.14.502   VALID3.14.503   VALIDATE3.14.504   VALIDATE-STATUS3.14.505   VALUE3.14.506   VALUES3.14.507   VARYING3.14.508   WHEN3.14.509   WITH3.14.510   WORKING-STORAGE3.14.511   WRITE3.14.512   YYYYDDD3.14.513   YYYYMMDD3.14.514   ZERO3.14.515   ZEROES3.14.516   ZEROS[#id60|3.15   Q. Does OpenCOBOL support modules?] Yes. Quite nicely in fact. Dynamically! [http://en.wikipedia.org/wiki/COBOL|COBOL] modules, and object files of many other languages are linkable. As OpenCOBOL uses intermediate C, linkage to other languages is well supported across many platforms. The OpenCOBOL [#call|CALL] instruction maps COBOL [#usage|USAGE] to many common C stack frame data representations. Multipart, complex system development is well integrated in the OpenCOBOL model. $ cobc -b hello.cob goodbye.cob Combines both source files into a single dynamically loadable module. Example produces __hello.so__. Using the __-l__ link library option, OpenCOBOL has access to most shared libraries supported on it's platforms. $ cobc -x -lcurl showcurl.cob Will link the /usr/lib/libcurl.so (''from the cURL project'') to showcurl. The OpenCOBOL [#call|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. [#id61|3.16   Q. What is the OpenCOBOL LINKAGE SECTION for?] Argument passing in COBOL is normally accomplished through the __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|CALL] for more details. [#id62|3.17   Q. What does the -fstatic-linkage OpenCOBOL compiler option do?] Under normal conditions, the ''LINKAGE SECTION'' is unallocated and uninitialized. When a LINKAGE SECTION variable, that is not part of the ''USING'' phrase (not a named calling argument), any memory that has been addressed becomes unaddressable across calls. ''-fstatic-linkage'' creates static addressing to the LINKAGE SECTION. From [#roger|[Roger]]: 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. With some rumours that this may become the default in future releases of OpenCOBOL, and the ''-fstatic-linkage'' option may be deprecated. [#id63|3.18   Q. Can OpenCOBOL interface with Ada?] Yes. The freely available __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 ''hello'' and ''ingress'' PROCEDURE and a ''echo'' FUNCTION. These will be called from an OpenCOBOL __adacaller.cob__ program. The gnat specification file: 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; The gnat implementation body: 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; The adacaller.cob source file: ******************* adacaller.cob ******************************** >>SOURCE FORMAT IS FIXED ****************************************************************** * 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 ****************************************************************** 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. ***************************************************************** procedure division. begin. call "adainit" end-call call "hello" end-call call "ingress" using by value 42 end-call call "echo" using by reference ada-message returning result end-call display "Ada return: " result end-display call "adafinal" end-call goback . end program caller. And the tectonics; Debian GNU/Linux ''build.sh'': gnatgcc -c helloada.adb gnatbind -n helloada gnatgcc -c b~helloada.adb cobc -x -lgnat adacaller.cob helloada.o b~helloada.o An important step is the creation of the object file from the ''gnatbind'' output ''with -n'' that is used in the final OpenCOBOL executable. Sample run using ./adacaller: Hello from Ada and OpenCOBOL Passing integer to Ada from OpenCOBOL OpenCOBOL passed: 42 Ada echo Ada return: +000000009 [#id64|3.19   Q. 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, 2008. The compiler recognizes most (if not all) of the ''Screen description entry'' of the COBOL 2008 Draft standard. External variables that influence screen handling include ; COB_SCREEN_EXCEPTIONS=Y : To enable exceptions during ACCEPT. ; COB_SCREEN_ESCAPE=Y : To enable handling of the escape key. See [#q-does-opencobol-support-crt-status|Q. 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, but is not necessary. [#id65|3.20   Q. What are the OpenCOBOL SCREEN SECTION colour values?] The FOREGROUND-COLOR and BACKGROUND-COLOR clauses will accept 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. The display of these colours are also influenced by HIGHLIGHT, LOWLIGHT and REVERSE-VIDEO options. For instance, brown will display as yellow when HIGHLIGHT is used. [#id66|3.21   Q. Does OpenCOBOL support CRT STATUS?] Yes. 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 ... There is also a special OpenCOBOL variable, __COB-CRT-STATUS__ which can be used instead of the CRT STATUS special name. There is also a COPY text that ships with OpenCOBOL, copy/screenio.cpy that can be included in the DATA DIVISION and provides 78 level constants for supported key status codes. Some values include: * COB-SCR-F1 thru * COB-SCR-F64 * COB-SCR-ESC examine the file to see the other values. [#id67|3.22   Q. What is CobCurses?] CobCurses is an optional package designed to work with OpenCOBOL 1.0, before OpenCOBOL 1.1 SCREEN SECTION support was initiated. It has many features beyond simple SCREEN SECTION handling. See [http://sourceforge.net/projects/cobcurses] for full details. This is a major piece of work by Warren Gay, ve3wwg. From an [http://opencobol.org/|opencobol.org] posting by Warren announcing release 0.95: 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 [#id68|3.23   Q. Does OpenCOBOL implement Report Writer?] Not at this time. ''July, 2008'' But it does support LINAGE. See [#q-does-opencobol-implement-linage|Q. Does OpenCOBOL implement LINAGE?] [#id69|3.24   Q. Does OpenCOBOL implement LINAGE?] Yes. LINAGE sets up logical pages inside file descriptors enhancing the WRITE operations and enabling the END-OF-PAGE clause. FILE SECTION. FD A-REPORT LINAGE IS 13 LINES TOP 2 FOOTING 2 BOTTOM 3. LINAGE clauses can set: TOP LINES FOOTING BOTTOM The [#linage-counter|LINAGE-COUNTER] noun is maintained during writes to LINAGE output files. [#id70|3.25   Q. Does OpenCOBOL implement any Intrinsic FUNCTIONs?] Yes, many. As of the July 2008 1.1 pre-release ABS, ACOS, ANNUITY, ASIN, ATAN, BYTE-LENGTH, CHAR, 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, SUM, TAN, TEST-DATE-YYYYMMDD, TEST-DAY-YYYYMMDD, TRIM, UPPER-CASE, VARIANCE, WHEN-COMPILED, YEAR-TO-YYYY 3.25.1   ABS Absolute value of numeric argument. DISPLAY FUNCTION ABS(DIFFERENCE). 3.25.2   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 π. DISPLAY FUNCTION ACOS(-1). 3.25.3   ANNUITY Compute the ratio of an annuity paid based on arguments of interest and number of periods. 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. Outputs: Monthly rate: +0.0067 Periods: 36 Annuity ratio: +0.0314 3.25.4   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 -π/2 thru π/2. DISPLAY FUNCTION ASIN(-1). 3.25.5   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 -π/2 thru π/2. DISPLAY FUNCTION ATAN(1). 3.25.6   FUNCTION BYTE-LENGTH The BYTE-LENGTH function returns an integer that is the internal storage length of the given argument. >>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 "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-display goback. exit program. Outputs: 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 3.25.7   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|ASCII] or [#ebcdic|EBCDIC] and details of the [#alphabet|ALPHABET] clause. DISPLAY FUNCTION CHAR(66). Would output __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. ''And to add a little confusion, most personal computers use an extended character set, usually erroneously called ASCII with a range of 0 to 255. A more appropriate name may be ISO-8859-1 Latin 1.'' See [#ascii|ASCII] for more accurate details. This author is often guilty of this misnomer of the use of the term ASCII. 3.25.8   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, with a nominal domain of 0 thru π with a zero returned at π/2. The cosine function returns a range of -1 thru +1. DISPLAY FUNCTION COS(1.5707963267949). 3.25.9   CURRENT-DATE Returns an alphanumeric field of length 21 with the current date, time and timezone information in the form YYYYMMDDhhmmsscc±tznn. DISPLAY FUNCTION CURRENT-DATE. Example Output: 2008080921243796-0400 3.25.10   DATE-OF-INTEGER Converts an integer date, days on the Gregorian since December 31 1600 to YYYYMMDD form. DISPLAY DATE-OF-INTEGER(1) DISPLAY DATE-OF-INTEGER(50000) Outputs: 16010101 17371123 50,000 days after December 31, 1600 being November 23rd, 1737. 3.25.11   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, 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,999. There is no validation of the input date. Because of the sliding window, this function is dependent on the date of evaluation 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, 50, 1900) DISPLAY FUNCTION DATE-TO-YYYYMMDD(990101, -10, 1900) DISPLAY FUNCTION DATE-TO-YYYYMMDD(990101, 50, 2000) DISPLAY FUNCTION DATE-TO-YYYYMMDD(990101, 50, 2100) When run in August, 2008 produces: 20000101 20500101 19610101 19990101 18990101 17990101 19990101 20990101 3.25.12   DAY-OF-INTEGER Converts a Gregorian integer date form to Julian date form (YYYDDD) based on days since December 31, 1600. Errors return 0. DISPLAY FUNCTION DAY-OF-INTEGER(97336). 1867182 97,336 days after 16001231 being the 182nd day of the year 1867. Canada's date of Confederation and recognized birthday. 3.25.13   DAY-TO-YYYYDDD Converts a Julian 2 digit year and three digit dat integer to a four digit year form. See [#date-to-yyyymmdd|DATE-TO-YYYYMMDD] for some of the details of the calculations involved.3.25.14   E3.25.15   EXCEPTION-FILE This special-register holds the error number and name of the source file that caused an input output exception. See [#exception-status|EXCEPTION-STATUS] for an example.3.25.16   EXCEPTION-LOCATION This special-register can be queried for the location of the last exception. See FUNCTION [#exception-status|EXCEPTION-STATUS] for example source code. Note: This feature requires compilation with ''-fsource-location'' compiler switch. This option is also turned on with ''-g'' debugging info compiles. Information includes PROGRAM-ID, section and source line.3.25.17   EXCEPTION-STATEMENT This special-register holds the statement that was executing when the latest exception was raised. See FUNCTION [#exception-status|EXCEPTION-STATUS] for an example. Note: This feature requires compilation with ''-fsource-location'' compiler switch. This option is also turned on with ''-g'' debugging info compiles.3.25.18   EXCEPTION-STATUS This FUNCTION returns the current exception status. The example below is courtesy of Roger While, from a post he made announcing the ''FUNCTION EXCEPTION-'' features. Source format is free, compile with ''cobc -x -g -free except.cob'': 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. Example output: 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 Tip See the source file libcob/exception.def for a list of the plethora of run-time exceptions supported by OpenCOBOL. 3.25.19   EXP3.25.20   EXP103.25.21   FACTORIAL3.25.22   FRACTION-PART3.25.23   INTEGER3.25.24   INTEGER-OF-DATE3.25.25   INTEGER-OF-DAY3.25.26   INTEGER-PART3.25.27   FUNCTION LENGTH3.25.28   FUNCTION LOCALE-DATE3.25.29   LOCALE-TIME3.25.30   LOG3.25.31   LOG103.25.32   LOWER-CASE3.25.33   MAX3.25.34   MEAN3.25.35   MEDIAN3.25.36   MIDRANGE3.25.37   MIN3.25.38   MOD3.25.39   NUMVAL3.25.40   NUMVAL-C3.25.41   ORD3.25.42   ORD-MAX3.25.43   ORD-MIN3.25.44   PIx3.25.45   PRESENT-VALUE3.25.46   FUNCTION RANDOM3.25.47   FUNCTION RANGE3.25.48   REM3.25.49   REVERSE3.25.50   SECONDS-FROM-FORMATTED-TIME3.25.51   SECONDS-PAST-MIDNIGHT3.25.52   FUNCTION SIGN3.25.53   SIN3.25.54   SQRT3.25.55   STANDARD-DEVIATION3.25.56   STORED-CHAR-LENGTH3.25.57   FUNCTION SUM3.25.58   TAN3.25.59   TEST-DATE-YYYYMMDD3.25.60   TEST-DAY-YYYYMMDD3.25.61   TRIM3.25.62   UPPER-CASE Returns a copy of the alphanumeric argument with any lower case letters replaced by upper case letters.3.25.63   VARIANCE Returns the variance of a series of numbers. The variance is defined as the square of the [#standard-deviation|STANDARD-DEVIATION]. DISPLAY FUNCTION VARIANCE(1 2 3 4 5 6 7 8 9 100) END-DISPLAY. +818.250000000000000 3.25.64   WHEN-COMPILED Returns a 21 character alphanumeric field of the form YYYYMMDDhhmmsscc±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: 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. $ cobc -c whenpart1.cob && sleep 15 && cobc -c whenpart2.cob && > sleep 15 && cobc -x whenshow.cob whenpart1.o whenpart2.o $ ./whenshow First part :2008082721391500-0400 Second part:2008082721393000-0400 Main part :2008082721394500-0400 3.25.65   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.[#id71|3.26   Q. Can you clarify the use of FUNCTION in OpenCOBOL?] Yes. This information is from [#roger|[Roger]], posted to the [http://opencobol.org/|opencobol] forums. 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)). One clarification to the above quote was pointed out by Roger. The line: be used anywhere where a source item is valid. should be: be used anywhere where a sending field is valid. [#id72|3.27   Q. What is the difference between the LENGTH verb and FUNCTION LENGTH?] From [#roger|[Roger]]: The standard only defines FUNCTION LENGTH. The LENGTH OF phrase is an extension (from MF) [#id73|3.28   Q. What STOCK CALL LIBRARY does OpenCOBOL offer?] OpenCOBOL 1.0 ships with quite a few callable features. See [#call|CALL]. Looking through the source code, you'll find the current list of service calls in: libcob/system.def With the 1.1 pre-release of July 2008, that list included: /* COB_SYSTEM_GEN (external name, number of parameters, internal name) */ COB_SYSTEM_GEN ("SYSTEM", 1, SYSTEM) COB_SYSTEM_GEN ("CBL_ERROR_PROC", 2, CBL_ERROR_PROC) COB_SYSTEM_GEN ("CBL_EXIT_PROC", 2, CBL_EXIT_PROC) COB_SYSTEM_GEN ("CBL_OPEN_FILE", 5, CBL_OPEN_FILE) COB_SYSTEM_GEN ("CBL_CREATE_FILE", 5, CBL_CREATE_FILE) COB_SYSTEM_GEN ("CBL_READ_FILE", 5, CBL_READ_FILE) COB_SYSTEM_GEN ("CBL_WRITE_FILE", 5, CBL_WRITE_FILE) COB_SYSTEM_GEN ("CBL_CLOSE_FILE", 1, CBL_CLOSE_FILE) COB_SYSTEM_GEN ("CBL_FLUSH_FILE", 1, CBL_FLUSH_FILE) COB_SYSTEM_GEN ("CBL_DELETE_FILE", 1, CBL_DELETE_FILE) COB_SYSTEM_GEN ("CBL_COPY_FILE", 2, CBL_COPY_FILE) COB_SYSTEM_GEN ("CBL_CHECK_FILE_EXIST", 2, CBL_CHECK_FILE_EXIST) COB_SYSTEM_GEN ("CBL_RENAME_FILE", 2, CBL_RENAME_FILE) COB_SYSTEM_GEN ("CBL_GET_CURRENT_DIR", 3, CBL_GET_CURRENT_DIR) COB_SYSTEM_GEN ("CBL_CHANGE_DIR", 1, CBL_CHANGE_DIR) COB_SYSTEM_GEN ("CBL_CREATE_DIR", 1, CBL_CREATE_DIR) COB_SYSTEM_GEN ("CBL_DELETE_DIR", 1, CBL_DELETE_DIR) COB_SYSTEM_GEN ("CBL_AND", 3, CBL_AND) COB_SYSTEM_GEN ("CBL_OR", 3, CBL_OR) COB_SYSTEM_GEN ("CBL_NOR", 3, CBL_NOR) COB_SYSTEM_GEN ("CBL_XOR", 3, CBL_XOR) COB_SYSTEM_GEN ("CBL_IMP", 3, CBL_IMP) COB_SYSTEM_GEN ("CBL_NIMP", 3, CBL_NIMP) COB_SYSTEM_GEN ("CBL_EQ", 3, CBL_EQ) COB_SYSTEM_GEN ("CBL_NOT", 2, CBL_NOT) COB_SYSTEM_GEN ("CBL_TOUPPER", 2, CBL_TOUPPER) COB_SYSTEM_GEN ("CBL_TOLOWER", 2, CBL_TOLOWER) 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) COB_SYSTEM_GEN ("C$TOLOWER", 2, CBL_TOLOWER) COB_SYSTEM_GEN ("C$JUSTIFY", 1, cob_acuw_justify) COB_SYSTEM_GEN ("CBL_OC_NANOSLEEP", 1, cob_oc_nanosleep) 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, diligent delevopers will need to pay heed to cross platform issues when calling the operating system. [#id74|3.29   Q. What are the XF4, XF5, and X91 routines?] From [http://opencobol.org/|opencobol.org] 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 Use CALL X"F4" USING BYTE-VAR ARRAY-VAR RETURNING STATUS-VAR 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. CALL X"91" USING RESULT-VAR FUNCTION-NUM PARAMETER-VAR RETURNING STATUS-VAR As mentioned by Roger, OpenCOBOL supports FUNCTION-NUM of 11, 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|SPECIAL-NAMES] paragraph. [#id75|3.30   Q. 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. CALL "CBL_OC_NANOSLEEP" USING 500000000 RETURNING STATUS END-CALL Would wait one-half second. ''It may be easier to grok if the source code uses string catenation; "500" & "000000" for example.'' [#id76|3.31   Q. Can I use ctags with OpenCOBOL?] Yes. Use the Exuberant version of ctags. Exuberant ctags recognizes COBOL, producing a TAGS or tags file suitable for __emacs__, __vi__, __nedit__ and other editors that support the ctags format. ''ctags, by default, only supports the competition, C and Fortran.'' After running ctags program.cob: $ vi -t WORKING-STORAGE will open program.cob and start at the line defining the working-storage section. Note: tags are case-sensitive and for larger projects, the above vi command would start an edit of the ''first'' file with an occurrence of WORKING-STORAGE found in the tags. [#id77|3.32   Q. What about debugging OpenCOBOL programs?] OpenCOBOL internal runtime checks are enabled with __-debug__. Support for tracing is enabled with __-ftrace__ and __-ftraceall__. Source line location is enabled with __-fsource-location__. Activation of FIXED format __D__ indicator debug lines is enabled with __-fdebugging-line__. __-fstack-check__ will perform stack checking when __-debug__ or __-g__ is used. __-fsyntax-only__ will ask the compiler to only check for syntax errors, and not emit any output. Support for [#gdb|gdb] is enabled with __-g__. $ gdb hello GNU gdb 6.7.1-debian Copyright (C) 2007 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 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) Setting a break at line 106 and 109 was found by a quick look through the C code from __$ 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. [#id78|3.33   Q. Is there a C interface to OpenCOBOL?] Most definitely. See [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. [#id79|3.34   Q. What are some idioms for dealing with C char * data from OpenCOBOL?] ''Thanks to Frank Swarbrick for pointing these idioms out'' To add or remove a null terminator, use the STRING verb. For example: * Add a null for calling C STRING current-url DELIMITED BY SPACE X"00" DELIMITED BY SIZE INTO display-url MOVE display-url TO current-url * Remove a null for display STRING current-url DELIMITED BY LOW-VALUE INTO display-url. Or to make changes in place: * Change nulls to spaces INSPECT current-url REPLACING ALL X"00" WITH SPACE. Or there is also modified references in OpenCOBOL: * Assume IND is the first trailing space (or picture limit). * Note: OpenCOBOL auto initializes working-storage to SPACES or ZEROES * depending on numeric or non-numeric pictures. * Remove null MOVE SPACE TO current-url(IND:1). * Add a zero terminator MOVE X"00" TO current-url(IND:1). [#roger|[Roger]] While points out: ''X"00" is almost always interchangeable with LOW-VALUE''. In all of the above snippets, the source code X"00" can be replaced by the COBOL noun __LOW-VALUE__ or ''LOW-VALUES''. ''Except when a program collating sequence is active and where the first character is not X"00"''. With the CALL verb, use ADDRESS OF and/or BY REFERENCE: CALL "CFUNCTION" USING BY REFERENCE ADDRESS OF current-url. The above being equivalent to char** in C. COBOL, by it's nature, passes all arguments by reference. That can be overridden with the __BY VALUE__ clause and the __BY CONTENT__ clause. [#id80|3.35   Q. Does OpenCOBOL support COPY includes?] Yes. COPY is fully supported, all variations from the standards up to and including the proposed 2008 standards. The __-I__ compiler option influences the copybook search path and __-E__ can be used to examine the ''after'' COPY preprocessor output. There is also __-ffold-copy-upper__ and __-ffold-copy-lower__ compiler controls. [#id81|3.36   Q. Does OpenCOBOL support WHEN-COMPILED?] Both as a noun and as an intrinsic function. DISPLAY WHEN-COMPILED. DISPLAY FUNCTION WHEN-COMPILED. 07/05/0805.15.20 2008070505152000-0400 Note: The noun WHEN-COMPILED is non-standard and was deemed obsolete in the pre 85 standard. [#id82|3.37   Q. What is PI in OpenCOBOL?] With OpenCOBOL 1.1: DISPLAY FUNCTION PI. 3.1415926535897932384626433832795029 DISPLAY FUNCTION E. 2.7182818284590452353602874713526625 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, and to read up on [#gmp|GMP]. [#id83|3.38   Q. Does OpenCOBOL support the Object features of the 2002 standard?] Not yet. ''July 2008'' [#id84|3.39   Q. Does OpenCOBOL implement PICTURE 78?] Yes. PICTURE 78 clauses can be used for constants, translated at compile time. This common non-standard extension is supported in OpenCOBOL. [#id85|3.40   Q. Does OpenCOBOL implement CONSTANT?] Current OC 1.1 has preliminary support for a subset of the standard conforming "CONSTANT" phrase. eg: 01  MYCONST CONSTANT AS 1. Note: there is a syntax difference between 78 and CONSTANT. [#id86|3.41   Q. What source formats are accepted by OpenCOBOL?] Both FIXED and FREE COBOL source formats are supported. FIXED format follows the 1-6, 7, 8-72 special columns of the COBOL standards. The compiler directives: Column 12345678901234567890 >>SOURCE FORMAT IS FREE >>SOURCE FORMAT IS FIXED 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 __&__ operator. The special *> ''till end of line'' comment is supported in both FREE and FIXED forms, but by necessity will need to be placed at column 7 or greater in FIXED format sources. The __-free__ and __-fixed__ options to __cobc__ also influence the expected source formats, with the default being mandated by the standards as FIXED. [#id87|3.42   Q. Does OpenCOBOL support continuation lines?] Yes. A dash __-__ in column 7 can be used for continuation lines. But, 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 ''column 7'' in FREE form source. Note that in this example there is no terminating quote on the string continuations, but there is an extra starting quote following the dash: 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 -"t source code". 01 otherstr pic X(148) value "this -"string will have spaces between the words THIS and STRING, as -"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. $ cobc longcont.cob $ cobcrun longcont 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 ''Note: The DISPLAY of'' __otherstr__ ''was split to avoid any wide browser scrolling, not for any COBOL reasons.'' ''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.'' [#id88|3.43   Q. Does OpenCOBOL support string concatenation?] Absolutely. Sources that need long strings, or those wishing to enhance source code readability, can use the __&__ operator: 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. Run this with: $ 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 [#id89|3.44   Q. Does OpenCOBOL support D indicator debug lines?] Yes, but only for FIXED FORMAT sources. As for continuation lines, column 7 has no meaning for SOURCE FORMAT IS FREE source code. Use __D__ lines as a conditional include of a source code line. These debug lines will only be compiled if the ''-fdebugging-line'' compiler switch is used. From human on [http://opencobol.org/|opencobol.org] 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). [#id90|3.45   Q. Does OpenCOBOL support mixed case source code?] Absolutely, kind of. Mixed case and mixed format, [#ascii|ASCII] and [#ebcdic|EBCDIC]. Most COBOL compilers have not required uppercase only source code for quite a few years now. Still, most COBOL compilers including OpenCOBOL folds parts of the source to uppercase ''with certain rules'' before translating. The compiler is case insensitive to names: 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. $ cobc -x mixcase.cob 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 Note; that although the folded declarations conflict, the DISPLAY quoted strings will NOT be folded, and would display as expected. ''Case sensitivity is also at the mercy of operating system conventions''. Under GNU/Linux, OpenCOBOL's dynamic link loader is case sensitive. CALL "C$JUSTIFY" USING center-string "C" END-CALL. is not the same as: CALL "c$justify" USING center-string "C" END-CALL. In support of case folding and COPY libraries, OpenCOBOL supports ''-ffold-copy-lower'' and ''-ffold-copy-upper''. For mixing and matching legacy sources. ; Trivia : The expressions ''uppercase'' and ''lowercase'' date back to early moveable type. Typographers would keep two cases of metal casted letters, Capitalized and normal. Usually set on stacked shelves over the workbench. The small letters, being used more frequently, ended up on the lower shelf; the lower case letters. [#id91|3.46   Q. What is the shortest OpenCOBOL program?] All that is needed is a program-id. Doesn't do much. program-id. a. [#id92|3.47   Q. What is the shortest Hello World program in OpenCOBOL?] A short version of OpenCOBOL hello world, compiled -free: program-id.hello.procedure division.display "Hello World!". Thanks to human and the [http://opencobol.org/|opencobol.org] forums. ''Please note:'' This is not __good__ COBOL form, and is only shown as an example of the possibilities. [#id93|3.48   Q. 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 __sequence__ field. This field is stripped as part of the preprocessing and is not validated. Historically, 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 __vi__ trick to renumber the sequence field by 100s. Given 000005* HELLO.COB OpenCOBOL FAQ example 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. hello. 000030 PROCEDURE DIVISION. 000040 DISPLAY "Hello World!". 000100 STOP RUN. Running the following __ex__ filter :%!perl -ne 'printf("\%06d\%s\n", $. * 100, substr($_, 6, -1));' produces a nicely resequenced source file. 000100* HELLO.COB OpenCOBOL FAQ example 000200 IDENTIFICATION DIVISION. 000300 PROGRAM-ID. hello. 000400 PROCEDURE DIVISION. 000500 DISPLAY "Hello World!". 000600 STOP RUN. * Note: Only use this on already FIXED form source. If used on any FREE format COBOL, the first 6 columns will be damaged. This has no effect on the compilation process, it only effects the appearance of the sources. * Vim: For users of the Vim editor, the command :set number will display the number of each source line. Many editors support the display of line numbers. Even: $ less -N can be used to display line numbers of its input. [#id94|3.49   Q. 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: 01 B-COUNT PIC 999 VALUE 0. 01 TEST-CASE PIC X(80) VALUE "This is my string.". ONE-WAY. INSPECT FUNCTION REVERSE(TEST-CASE) TALLYING B-COUNT FOR LEADING ' '. DISPLAY B-COUNT. TWO-WAY. INSPECT TEST-CASE TALLYING B-COUNT FOR TRAILING SPACE. DISPLAY B-COUNT. THREE-WAY. IF TEST-CASE EQUAL SPACES COMPUTE B-COUNT = LENGTH OF TEST-CASE ELSE COMPUTE B-COUNT = LENGTH TEST-CASE - FUNCTION LENGTH(FUNCTION TRIM(TEST-CASE TRAILING)) END-COMPUTE END-IF DISPLAY B-COUNT. produces: 062 124 062 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 [http://opencobol.org/|opencobol.org] forum post. [#id95|3.50   Q. Is there a way to left justify an edited numeric field?] Yes, a couple of ways. Assuming a working storage of: 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 00000123 123 With OpenCOBOL, the intrinsic: FUNCTION TRIM(myedit LEADING) 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: CALL "C$JUSTIFY" USING mychars "L" END-CALL to left justify an alphanumeric field. "R" for right, or "C" for centre. But a generic idiom that should work across all capable COBOL systems: 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 123 123 MOVE 0 TO spcount INSPECT mynumber TALLYING spcount FOR LEADING ZERO DISPLAY mynumber DISPLAY mynumber(spcount + 1:) Uses the INSPECT verb to count leading spaces, then reference modification to move the characters one past the spaces till the end of the edit field to an alpha field. [#id96|4   Notes][#id97|4.1   big-endian] Binary values stored with the most significant byte at the lowest memory address. __Big End First__. See [http://en.wikipedia.org/wiki/Endianness] for more details. The OpenCOBOL compiler ''default'' storage format for [#usage|USAGE] BINARY and COMP. [#id98|4.2   little-endian] Binary values stored with the most significant byte at the highest memory address. __Little End First__. [http://en.wikipedia.org/wiki/Endianness] for more details. This is the common Intel architecture form, and [#usage|USAGE] clauses of COMPUTATIONAL-5, BINARY-CHAR, BINARY-SHORT, BINARY-LONG, BINARY-DOUBLE are a true performance boost on this hardware. See [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. [#id99|4.3   ASCII] American Symbolic Code for Information Interchange. The character encoding common to personal computers and the Internet Age, therefore OpenCOBOL. OpenCOBOL also supports the [#ebcdic|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 [http://en.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange] for more info. Attention! Unicode? [#id100|4.4   DSO] Dynamic Shared Objects. Similar to but subtlely different from ''share libraries''. [#id101|4.5   gdb] The GNU symbolic debugger. Big, deep, wide. $ info gdb for the details. or visit [http://www.gnu.org/software/gdb/documentation/] [#id102|4.6   GMP] GNU MP libgmp. GNU Library for decimal arithmetic. See [http://gmplib.org/] for complete details on the library advertised as ''Arithmetic without limitations''. ''Arithmetic without limitations''. [#id103|5   Authors][Keisuke]''([#id6|1], [#id9|2])'' Keisuke Nishida Initial developer and creator of OpenCOBOL. From the 1990s through 2004 was the primary developer and OpenCOBOL project lead. His efforts are greatly appreciated by the userbase of OpenCOBOL. [Roger]''([#id5|1], [#id7|2], [#id8|3], [#id10|4], [#id11|5], [#id15|6], [#id16|7], [#id17|8], [#id18|9])'' Roger While OpenCOBOL 1.1 is currently ''(August 2008)'' in development, and Roger is the lead programmer. From early 2004 up till today, and tomorrow, Roger has been very active on the [http://opencobol.org/|opencobol.org] website, and is open to feature requests and clarifications to the implementation. Roger has, since January 2008, actively monitored an OpenCOBOL 1.1 wishlist on the [http://opencobol.org/|opencobol.org] OpenCOBOL forum. [#id104|6   Maintainers and Contributors][#id1|[btiffin]] Brian Tiffin Initial FAQ, sample programs for OpenCOBOL 1.1. [aoirthoir]''([#id4|1], [#id12|2])'' Joseph James Frantz Hosting, support. [jrls_swla]''([#id2|1], [#id14|2])'' John Ellis Samples and how-to's and ... [human]''([#id3|1], [#id13|2])'' human Samples and style [#id105|7   Changelog] ; 02-July-2008 : Experimental version for commnent ; 06-July-2008 : First 0.0 pre-alpha release ; 07-July-2008 : Second 0.0 pre-alpha. ; 11-July-2008 : Last 0.0 pre-alpha. Checked in for diffs. ; 13-July-2008 : Last-last 0.0 pre-alpha. Verify DIFF functionality. ; 17-July-2008 : Last-last-last 0.0 pre-alpha. Second DIFF. ; 20-July-2008 : Corrections pass. ; 24-July-2008 : Expanded the SCREEN SECTION questions. ; 28-July-2008 : Another correction pass, with clarifications from Roger While ; 10-Aug-2008 : Started in on the intrinsic functions. Dropped the pre from the alpha designation. Still some Look into this entries. ; 21-Aug-2008 : Move to add1tocobol.com ; 28-Aug-2008 : Publish link to 1.0rc ; 29-Aug-2008 : Skeleton of the reserved words list ; 30-Aug-2008 : Let the tweaking begin ; 23-Sep-2008 : Adds and a trial skin ; 13-Oct-2008, 15-Oct-2008 : Added a few samples. ; 19-Oct-2008 : Added TABLE SORT sample. ; 22-Oct-2008 : Added configure script information. ; 29-Oct-2008 : Added dialect configuration information.