You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document describes the syntax, semantics and use of the COBOL programming language as implemented by GnuCOBOL, formerly known as OpenCOBOL.
6
6
7
7
The original principal developers of GnuCOBOL were Keisuke Nishida and Roger While. Since then, many members of the community have been involved in its development.
@@ -17,18 +17,14 @@ Other documents that should be read is the @file{gnucobol.pdf} found in the @fil
17
17
Yet another document which delves deeper in to the compiler that is a @i{must} read, is the FAQ available via the GnuCOBOL
18
18
@url{https://gnucobol.sourceforge.io/#faq, ManualsandGuides}, although it could do with a wee clean up to ease reading and finding required information.
For those wishing to learn COBOL for the first time, Gary can strongly recommend the following resources.
33
29
34
30
If you like to hold a book in your hands, I strongly recommend @i{Murach's Structured COBOL}, by Mike Murach, Anne Prince and Raul Menendez (2000) - ISBN 9781890774059. Mike Murach and his various writing partners have been writing outstanding COBOL textbooks for decades. It's an excellent book for those familiar with the concepts of programming in other languages, but unfamiliar with COBOL.
@@ -46,20 +42,20 @@ Along with every release of the compiler sources is the file @file{NEWS}. It co
If you already know a programming language other than COBOL, chances are that language is Java, C or C++. You will find COBOL much different from those; sometimes the differences are a good thing and sometimes they aren't. The thing to remember about COBOL is this: @i{it was designed to solve business problems}.
51
47
52
48
COBOL, first introduced to the programming public in 1959, was the very first programming language to become standardized (in 1960). This meant that a standard-compliant COBOL program written on computer ``A'' made by company ``B'' would be able to be compiled and executed on computer ``X'' made by company ``Y'' with very few, if any, changes. This may not seem like such a big deal today, but it was a radical departure from all programming languages that came before it and even many that came after it.
53
49
54
50
The name @acronym{COBOL} actually says it all --- COBOL is an acronym that stands for ``(@b{CO})mmon (@b{B})usiness (@b{O})riented (@b{L})anguage''. Note the fact that the word ``common'' comes before all others. The word ``business'' is a close second. Therein lies the key to COBOL's success.
Despite statements from industry ``insiders'', the COBOL programming language is not dead, even though newer and so-called ``modern'' languages like Java, C#, .NET, Ruby on Rails and so on appear to have become the languages of choice in the Information Technology world. These languages have become popular because they address the following desired requirements for ``modern'' programming:
64
60
@enumerate
65
61
@item
@@ -114,7 +110,7 @@ The whole reason you're reading this is that you've discovered GnuCOBOL --- anot
Throughout the history of computer programming, the search for new ways to improve of the productivity of programmers has been a major consideration. Other than hobbyists, programming is an activity performed for money, and businesses abhor spending anything more than is absolutely necessary; even government agencies try to spend as little money on projects as is absolutely necessary.
119
115
120
116
The amount of programming necessary to accomplish a given task --- including rework needed by any errors found during testing (testing is sometimes jokingly defined as: @i{that time during which an application is actually in production, allowing users to discover the problems}) is the measure of programmer productivity. Anything that reduces that effort will therefore reduce the time spent in such activities therefore reducing the expense of same. When the expense of programming is reduced, programmer productivity is increased.
@@ -138,7 +134,7 @@ The reality is, however, that good programmers have been practising code re-usab
GnuCOBOL is a free and open sourced COBOL compiler and runtime environment, written using the C programming language which itself is free to use and can be used in all forms including for commercial purposes - there is no restrictions. GnuCOBOL is typically distributed in source-code form, and must then be built for your computer's operating system using the system's C compiler and loader. While originally developed for the UNIX and Linux operating systems, GnuCOBOL has also been successfully built for computers running OSX (a OpenBSD implementation) and Windows utilizing the UNIX-emulation features of such tools as Cygwin and MinGW. Also see the @url{https://savannah.gnu.org/projects/gnucobol, GNUwebsite} for more information.
143
139
Pre built Implemeations for Windows can also be found at @url{https://www.arnoldtrembley.com/GnuCOBOL.htm}.
The GnuCOBOL compiler is named @command{cobc} (@command{cobc.exe} on a Windows system).
31
31
32
32
The following describes the syntax and option switches of the cobc command. This information may be displayed by entering the command @command{cobc--help} or @command{cobc-h}.
@@ -576,7 +576,7 @@ Later, when you wish to compile a calling program and combine any needed assembl
The GnuCOBOL compiler will attempt to locate copybooks by searching for them in the following folders. The search will occur in the sequence shown below, and will terminate once a copybook is found.
900
900
@enumerate
901
901
@item
@@ -959,7 +959,7 @@ Case-folding may also be turned on and off within the program source code using
GnuCOBOL uses compiler configuration files to define various options that will control the compilation process. These configuration files are specified using the
964
964
@switchidx{-conf} compilation switch and are found in the folder defined by the @envvarcompile{COB_CONFIG_DIR}.
Once GnuCOBOL programs have been compiled into either directly-executable programs (created via the @switch{-x}) or dynamically-loadable libraries (created via the @switch{-m}), those programs may be executed from any shell environment. The exact manner in which the two are executed will differ, as described in the upcoming sections.
@switchidx{-x} will be generated as directly-executable programs. For example, a native Windows or Windows/MinGW build of GnuCOBOL will generate an @file{.exe} file when the @switch{-x} switch is specified to the compiler.
As discussed previously, dynamically-loadable libraries are created via the compiler's @switch{-m}. Once so created, the program(s) in these libraries are executed from the command line (via the GnuCOBOL @code{cobcrun} utility), or as dynamically-loadable subprograms.
Dynamically-loaded subprograms are executed (from a COBOL syntax point of view) just like any other subprograms. What makes them unique, however, is that they are loaded into memory only when they are actually used the first time during the execution of a program.
1369
1369
1370
1370
When a dynamically-loadable module needs to be loaded (because it is not already in memory from a previous subprogram execution), the dynamically-loadable library will be sought by libcob in each directory named in the library specified by the
@@ -1381,7 +1381,7 @@ It is possible, however, to automatically cause all library names to 'fold' to u
Regardless of the manner in which a main program is executed (i.e. directly or via @code{cobcrun}), any arguments specified to the program may be retrieved via any of the following:
2099
2099
@itemize@bullet
2100
2100
@item
@@ -2105,7 +2105,7 @@ Regardless of the manner in which a main program is executed (i.e. directly or v
By default, the GnuCOBOL compiler will truncate binary data items to the precision indicated by their @syntaxref{PICTURE} clause, if they have one. This applies to COMP, BINARY and COMP-4 items Only.
2110
2110
@* The fact is, however, that binary truncation has a significant effect on the performance of GnuCOBOL programs. When binary truncation is in effect, arithmetic operations performed against all types of numeric data items (even @code{USAGEDISPLAY}) are slowed down.
0 commit comments