"~end-display.~\\
COOL~~~goback.
}\end{quote}
Once compiled and placed in an appropriate cgi-bin directory of
your web server, a simple form can be used to try the example.
\textbf{cgienv.cgi form}
\begin{quote}{\ttfamily \raggedright \noindent
OpenCOBOL~sample~CGI~form~\\
~\\
OpenCOBOL~sample~CGI~form
~\\
~\\
~\\
}\end{quote}
%___________________________________________________________________________
\hypertarget{what-is-ocdoc}{}
\pdfbookmark[1]{5.2~~~What is ocdoc?}{what-is-ocdoc}
\subsection*{5.2~~~What is ocdoc?}
\label{what-is-ocdoc}
\textbf{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
\begin{quote}{\ttfamily \raggedright \noindent
*>~**~*>{}>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~{\textbackslash}*><{\textbackslash}*~*ignoring~spaces*,~are~\\
~~~~~~*><+~~extracted.~\\
~~~~~~*><*~\\
~~~~~~*><*~-~Lines~that~begin~with~{\textbackslash}*><+~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~{\textbackslash}*><{[}~begin~a~here~document~\\
~~~~~~*><+~~with~lines~that~follow~extracted~as~is.~\\
~~~~~~*><*~\\
~~~~~~*><*~-~Lines~that~begin~with~{\textbackslash}*><{]}~close~a~here~document.~\\
~~~~~~*><+~~Here~document~start~and~end~lines~are~excluded~from~the~\\
~~~~~~*><+~~extract.~\\
~~~~~~*><*~\\
~~~~~~*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~~~~~~*><*~Source~code~\\
~~~~~~*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~~~~~~*><*~`Download~ocdoc.cob~\\
~~~~~~*><+~~`{\_}~\\
~~~~~~*><*~`See~ocdocseq.cob~\\
~~~~~~*><+~~`{\_}~\\
~~~~~~*><*~\\
~~~~~~*><*~\\
~~~~~~*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~~~~~~*><*~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
}\end{quote}
See \href{http://opencobol.add1tocobol.com/ocdoc.html}{ocdoc.html} for the output
from processing \emph{ocdoc.cob} with \textbf{ocdoc}.
%___________________________________________________________________________
\hypertarget{what-is-cbl-oc-dump}{}
\pdfbookmark[1]{5.3~~~What is CBL{\_}OC{\_}DUMP?}{what-is-cbl-oc-dump}
\subsection*{5.3~~~What is CBL{\_}OC{\_}DUMP?}
\label{what-is-cbl-oc-dump}
CBL{\_}OC{\_}DUMP is somewhat of a community challenge application to allow for
runtime data dumps. Multiple postings to \href{http://opencobol.org/}{opencobol.org} has refined the
hex display callable to:
\begin{quote}{\ttfamily \raggedright \noindent
*>{}>SOURCE~FORMAT~IS~FIXED~\\
*-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*>~Author:~~~~Brian~Tiffin~\\
*>~~~~~~~~~~~~Changed~by~Asger~Kjelstrup~and~human~\\
*>~Date:~~~~~~18-Feb-2009~\\
*>~Purpose:~~~Hex~Dump~display~\\
*>~Tectonics:~cobc~-c~CBL{\_}OC{\_}DUMP.cob~\\
*>~~~~~Usage:~cobc~-x~program.cob~-o~CBL{\_}OC{\_}DUMP~\\
*>~~~~~~~~~~~~export~OC{\_}DUMP{\_}EXT=Y~for~explanatory~text~on~dumps~\\
*-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~identification~division.~\\
~program-id.~CBL{\_}OC{\_}DUMP.~\\
*~\\
~ENVIRONMENT~~~~~~DIVISION.~\\
~CONFIGURATION~~~~SECTION.~\\
~SPECIAL-NAMES.~\\
*~\\
~data~division.~\\
~working-storage~section.~\\
~77~addr~~~~~~~~~~~~~~~~~~~~~~~~~~~~usage~pointer.~\\
~77~addr2addr~~~~~~~~~~~~~~~~~~~~~~~usage~pointer.~\\
~77~addr3~~~~~~~~~~~~~~~~~~~~~~~~~~~usage~pointer.~\\
~77~counter~~~~~~~~~~~~~~~~~~~~~~~~~usage~binary-long.~\\
~77~byline~~~~~~~~~~~~~~~pic~999~~~~usage~comp-5.~\\
~77~offset~~~~~~~~~~~~~~~pic~9999~~~usage~comp-5.~\\
~77~byte~~~~~~~~~~~~~~~~~pic~x~~~~~~based.~\\
~77~some~~~~~~~~~~~~~~~~~pic~999~~~~usage~comp-5.~\\
~77~high-var~~~~~~~~~~~~~pic~99~~~~~usage~comp-5.~\\
~77~low-var~~~~~~~~~~~~~~pic~99~~~~~usage~comp-5.~\\
*~\\
~01~char-set~~~~~~~~~~~~~pic~x(6).~\\
~~~~88~is-ascii~~~value~"ASCII".~\\
~~~~88~is-ebdic~~~value~"EBCDIC".~\\
~~~~88~is-unknown~value~"?".~\\
~01~architecture~~~~~~~~~pic~x(6).~\\
~~~~88~is-32-bit~~value~"32-bit".~\\
~~~~88~is-64-bit~~value~"64-bit".~\\
~01~endian-order~~~~~~~~~pic~x(10).~\\
~~~~88~is-big-endian-no~~value~"Little-Big".~\\
~~~~88~is-big-endian-yes~value~"Big-Little".~\\
*~\\
~01~show-hex-group.~\\
~~~~02~hex-line.~\\
~~~~~~~05~show-hexes~~~~~~~~pic~x(48).~\\
~~~~02~filler~redefines~hex-line.~\\
~~~~~~~05~filler~occurs~~16.~\\
~~~~~~~~~07~filler~occurs~~3.~\\
~~~~~~~~~~~10~show-hex~~~~pic~x.~\\
*~\\
~77~dots~~~~~~~~~~~~~~~~~pic~x(16)~~value~'................'.~\\
~77~show~~~~~~~~~~~~~~~~~pic~x(16).~\\
*~\\
~77~hex-digit~~~~~~~~~~~~pic~x(16)~~value~'0123456789abcdef'.~\\
~01~show-extended-infos~~pic~x.~\\
~~~~88~show-extended-infos-yes~values~'Y',~'y'.~\\
*~\\
~linkage~section.~\\
~01~buffer~~~~~~~~~~~~~~~pic~x~~~~~~any~length.~\\
~77~len~~~~~~~~~~~~~~~~~~~~~~~~~~~~~usage~binary-long.~\\
*-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~procedure~division~using~buffer~len.~\\
*~\\
~MAIN~SECTION.~\\
~00.~\\
~~~~~perform~starting-address~\\
*~\\
~~~~~set~address~~of~byte~to~address~of~buffer~\\
*~\\
~~~~~perform~varying~counter~from~0~by~16~\\
~~~~~~~~~~~~~until~~~counter~~>=~~~len~\\
~~~~~~~~move~counter~to~offset~\\
~~~~~~~~move~spaces~~to~show-hexes~\\
~~~~~~~~move~dots~~~~to~show~\\
~~~~~~~~perform~varying~byline~from~1~by~1~\\
~~~~~~~~~~~~~~~~until~~~byline~~>~~16~\\
~~~~~~~~~~~if~(counter~+~byline)~>~len~\\
~~~~~~~~~~~~~~move~spaces~to~show-hexes(3*(byline~-~1):3)~\\
*~~~~~~~~~~~~~move~space~~to~show~(byline:1)~\\
~~~~~~~~~~~else~\\
~~~~~~~~~~~~~~perform~calc-hex-value~\\
~~~~~~~~~~~~~~if~some~>~31~and~some~<=~128~\\
~~~~~~~~~~~~~~~~~move~byte~to~show(byline:1)~\\
~~~~~~~~~~~~~~end-if~\\
~~~~~~~~~~~~~~set~addr3~to~address~of~byte~\\
~~~~~~~~~~~~~~set~addr3~up~by~1~\\
~~~~~~~~~~~~~~set~address~of~byte~to~addr3~\\
~~~~~~~~~~~end-if~\\
~~~~~~~~end-perform~\\
~~~~~~~~display~offset~"~~"~show-hexes~show~\\
~~~~~~~~end-display~\\
~~~~~end-perform~\\
~~~~~display~"~"~\\
~~~~~end-display~\\
*~\\
~~~~~continue.~\\
~ex.~exit~program.~\\
*-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~CALC-HEX-VALUE~SECTION.~\\
~00.~\\
~~~~~subtract~1~from~function~ord(byte)~giving~some~\\
~~~~~end-subtract~\\
~~~~~divide~~~some~by~16~giving~high-var~remainder~low-var~\\
~~~~~end-divide~\\
~~~~~move~hex-digit(high-var~+~1:1)~to~show-hex(byline~1)~\\
~~~~~move~hex-digit(low-var~~+~1:1)~to~show-hex(byline~2)~\\
*~\\
~~~~~continue.~\\
~ex.~exit.~\\
*-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~STARTING-ADDRESS~SECTION.~\\
~00.~\\
~~~~~perform~TEST-ASCII~\\
~~~~~perform~TEST-64bit~\\
~~~~~perform~TEST-ENDIAN~\\
~~~~~set~addr~~~~~~to~address~of~buffer~\\
~~~~~set~addr2addr~to~address~of~addr~\\
*~\\
*~To~show~hex-address,~reverse~if~Big-Little~Endian~\\
~~~~~if~is-big-endian-yes~\\
~~~~~~~~set~addr2addr~up~~~by~LENGTH~OF~addr~\\
~~~~~~~~set~addr2addr~down~by~1~\\
~~~~~end-if~\\
~~~~~perform~varying~byline~from~1~by~1~\\
~~~~~~~~~~~~~until~byline~>~LENGTH~OF~addr~\\
~~~~~~~~set~address~of~byte~to~addr2addr~\\
~~~~~~~~perform~calc-hex-value~\\
~~~~~~~~if~is-big-endian-yes~\\
~~~~~~~~~~~set~addr2addr~down~by~1~\\
~~~~~~~~else~\\
~~~~~~~~~~~set~addr2addr~up~~~by~1~\\
~~~~~~~~end-if~\\
~~~~~end-perform~\\
*~\\
*~Display~characteristics~and~headline~\\
~~~~~accept~show-extended-infos~from~environment~"OC{\_}DUMP{\_}EXT"~\\
~~~~~end-accept~\\
~~~~~subtract~1~from~byline~\\
~~~~~end-subtract~\\
~~~~~if~show-extended-infos-yes~\\
~~~~~~~~display~"~"~\\
~~~~~~~~end-display~\\
~~~~~~~~display~"Dump~of~memory~beginning~at~Hex-address:~"~\\
~~~~~~~~~~~~~~~~~show-hexes(~1~:~3*byline)~\\
~~~~~~~~end-display~\\
~~~~~~~~display~"Program~runs~in~"~architecture~"~architecture.~"~\\
~~~~~~~~~~~~~~~~"Char-set~is~"~char-set~"."~\\
~~~~~~~~end-display~\\
~~~~~~~~display~~"Byte~order~is~"~endian-order~"~endian."~\\
~~~~~~~~end-display~\\
~~~~~end-if~\\
~~~~~display~"~"~\\
~~~~~end-display~\\
~~~~~display~"Offs~~"~\\
~~~~~~~~~~~~~"HEX-{}-~-{}-~-{}-~5-~-{}-~-{}-~-{}-~-{}-~10~-{}-~-{}-~-{}-~-{}-~15~-{}-~"~\\
~~~~~~~~~~~~~"CHARS-{}-{}-{}-1-{}-{}-{}-5-"~\\
~~~~~end-display~\\
*~\\
~~~~~continue.~\\
~ex.~exit.~\\
*-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~TEST-ASCII~SECTION.~\\
*Function:~Discover~if~running~Ascii~or~Ebcdic~\\
~00.~\\
~~~~~evaluate~"~"~\\
~~~~~~~~when~X"20"~\\
~~~~~~~~~~~set~~is-ascii~~~to~true~\\
~~~~~~~~when~X"40"~\\
~~~~~~~~~~~set~~is-ebdic~~~to~true~\\
~~~~~~~~when~other~\\
~~~~~~~~~~~set~~is-unknown~to~true~\\
~~~~~end-evaluate~\\
*~\\
~~~~~continue.~\\
~ex.~exit.~\\
*-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~TEST-64BIT~SECTION.~\\
*Function:~Discover~if~running~32/64~bit~\\
~00.~\\
*~~~~Longer~pointers~in~64-bit~architecture~\\
~~~~~if~function~length(addr)~<=~4~\\
~~~~~~~~set~~is-32-bit~to~true~\\
~~~~~else~\\
~~~~~~~~set~~is-64-bit~to~true~\\
~~~~~end-if~\\
*~\\
~~~~~continue.~\\
~ex.~exit.~\\
*-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~TEST-ENDIAN~SECTION.~\\
~00.~\\
*~~~~Number-bytes~are~shuffled~in~Big-Little~endian~\\
~~~~~move~128~to~byline~\\
~~~~~set~address~of~byte~to~address~of~byline~\\
~~~~~if~function~ord(byte)~>~0~\\
~~~~~~~~set~~is-big-endian-yes~to~true~\\
~~~~~else~\\
~~~~~~~~set~~is-big-endian-no~~to~true~\\
~~~~~end-if~\\
*~\\
~~~~~continue.~\\
~ex.~exit.~\\
*-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~end~program~CBL{\_}OC{\_}DUMP.~\\
*><*
}\end{quote}
Example displays:
\begin{quote}{\ttfamily \raggedright \noindent
Alpha~literal~Dump~\\
~\\
Offs~~HEX-{}-~-{}-~-{}-~5-~-{}-~-{}-~-{}-~-{}-~10~-{}-~-{}-~-{}-~-{}-~15~-{}-~CHARS-{}-{}-{}-1-{}-{}-{}-5-~\\
0000~~61~62~63~64~65~66~67~68~69~6a~6b~6c~6d~6f~70~71~abcdefghijklmopq~\\
0016~~72~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~r...............~\\
~\\
Integer~Dump:~+0000000123~\\
~\\
Offs~~HEX-{}-~-{}-~-{}-~5-~-{}-~-{}-~-{}-~-{}-~10~-{}-~-{}-~-{}-~-{}-~15~-{}-~CHARS-{}-{}-{}-1-{}-{}-{}-5-~\\
0000~~7b~00~00~00~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{\{}...............
}\end{quote}
Or with OC{\_}DUMP{\_}EXT enviroment variable set to Y:
\begin{quote}{\ttfamily \raggedright \noindent
Numeric~Literal~Dump:~0~\\
~\\
Dump~of~memory~beginning~at~Hex-address:~bf~80~fc~e4~\\
Program~runs~in~32-bit~architecture.~Char-set~is~ASCII~.~\\
Byte~order~is~Big-Little~endian.~\\
~\\
Offs~~HEX-{}-~-{}-~-{}-~5-~-{}-~-{}-~-{}-~-{}-~10~-{}-~-{}-~-{}-~-{}-~15~-{}-~CHARS-{}-{}-{}-1-{}-{}-{}-5-~\\
0000~~00~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~................
}\end{quote}
%___________________________________________________________________________
\hypertarget{does-opencobol-support-any-sql-databases}{}
\pdfbookmark[1]{5.4~~~Does OpenCOBOL support any SQL databases?}{does-opencobol-support-any-sql-databases}
\subsection*{5.4~~~Does OpenCOBOL support any SQL databases?}
\label{does-opencobol-support-any-sql-databases}
Yes and no. There is no embedded SQL in OpenCOBOL in terms of EXEC but there
are at least two usable CALL extensions. There are currently \emph{(February 2009)} quite a few
active developments for external SQL engine access.
\begin{itemize}
\item {}
There are early prototypes for SQLite at
\href{http://opencobol.add1tocobol.com/ocshell.c}{ocshell.c}
\item {}
with a sample usage program at
\href{http://opencobol.add1tocobol.com/sqlscreen.cob}{sqlscreen.cob}
\item {}
and supporting documentation at
\href{http://opencobol.add1tocobol.com/sqlscreen.html}{sqlscreen.html}
\item {}
The SQLite extension comes in two flavours; a shell mode discussed above and
a direct API interface housed at
\href{http://add1tocobol.com/tiki-list_file_gallery.php?galleryId=12}{ocsqlite.c}
\item {}
A libdbi (generic database access) extension is also available. See
\href{http://add1tocobol.com/tiki-read_article.php?articleId=1}{cobdbi} for
full details.
\item {}
Efforts toward providing a preprocessor for EXEC are underway.
\item {}
Rumours of a potential Postgres layer have also been heard.
\item {}
\textbf{AND} as a \emph{thing to watch for}, one of the good people of the
OpenCOBOL communinity has written a layer that converts READ and WRITE
verbage to SQL calls \emph{at run time}. More on this as it progresses.
\end{itemize}
%___________________________________________________________________________
\hypertarget{does-opencobol-support-isam}{}
\pdfbookmark[1]{5.5~~~Does OpenCOBOL support ISAM?}{does-opencobol-support-isam}
\subsection*{5.5~~~Does OpenCOBOL support ISAM?}
\label{does-opencobol-support-isam}
Yes. The official release used Berkeley DB, but there are also
experimental configurations of the compiler that use VBISAM,
CISAM, DISAM or other external handlers. See
\href{\#what-are-the-configure-options-available-for-building-opencobol}{What are the configure options available for building OpenCOBOL?}
for more details about these options. The rest of this entry assumes
the default Berkeley database.
\href{\#isam}{ISAM} is an acronymn for Indexed Sequential Access Method.
OpenCOBOL has fairly full support of all standard specified ISAM
compile and runtime semantics.
For example
\begin{quote}{\ttfamily \raggedright \noindent
*>{}>SOURCE~FORMAT~IS~FIXED~\\
*>~***************************************************************~\\
*><*~================~\\
*><*~indexing~example~\\
*><*~================~\\
*><*~:Author:~~~~Brian~Tiffin~\\
*><*~:Date:~~~~~~17-Feb-2009~\\
*><*~:Purpose:~~~Fun~with~Indexed~IO~routines~\\
*><*~:Tectonics:~cobc~-x~indexing.cob~\\
*>~***************************************************************~\\
~identification~division.~\\
~program-id.~indexing.~\\
~\\
~environment~division.~\\
~configuration~section.~\\
~\\
~input-output~section.~\\
~file-control.~\\
~~~~select~optional~indexing~\\
~~~~assign~to~"indexing.dat"~\\
~~~~organization~is~indexed~\\
~~~~access~mode~is~dynamic~\\
~~~~record~key~is~keyfield~of~indexing-record~\\
~~~~alternate~record~key~is~splitkey~of~indexing-record~\\
~~~~~~~~with~duplicates~\\
~~~~.~\\
~\\
*>~**~OpenCOBOL~does~not~yet~support~split~keys~**~\\
*>~~alternate~record~key~is~newkey~\\
*>~~~~~~source~is~first-part~of~indexing-record~\\
*>~~~~~~~~~~~~~~~~last-part~of~indexing-record~\\
*>~~~~~~with~duplicates~\\
~\\
~data~division.~\\
~file~section.~\\
~fd~indexing.~\\
~01~indexing-record.~\\
~~~~03~keyfield~~~~~~~~~~pic~x(8).~\\
~~~~03~splitkey.~\\
~~~~~~~05~first-part~~~~~pic~99.~\\
~~~~~~~05~middle-part~~~~pic~x.~\\
~~~~~~~05~last-part~~~~~~pic~99.~\\
~~~~03~data-part~~~~~~~~~pic~x(54).~\\
~\\
~working-storage~section.~\\
~01~display-record.~\\
~~~~03~filler~~~~~~~~~~~~pic~x(4)~~value~spaces.~\\
~~~~03~keyfield~~~~~~~~~~pic~x(8).~\\
~~~~03~filler~~~~~~~~~~~~pic~xx~~~~value~spaces.~\\
~~~~03~splitkey.~\\
~~~~~~~05~first-part~~~~~pic~z9.~\\
~~~~~~~05~filler~~~~~~~~~pic~x~~~~~value~space.~\\
~~~~~~~05~middle-part~~~~pic~x.~\\
~~~~~~~05~filler~~~~~~~~~pic~xx~~~~value~all~"+".~\\
~~~~~~~05~last-part~~~~~~pic~z9.~\\
~~~~03~filler~~~~~~~~~~~~pic~x(4)~~value~all~"-".~\\
~~~~03~data-part~~~~~~~~~pic~x(54).~\\
~\\
*>~control~break~\\
~01~oldkey~~~~~~~~~~~~~~~pic~99x99.~\\
~\\
*>~In~a~real~app~this~should~well~be~two~separate~flags~\\
~01~control-flag~~~~~~~~~pic~x.~\\
~~~~88~no-more-duplicates~~~~~~~~~~value~high-value~\\
~~~~~~~when~set~to~false~is~~~~~~~~~~~~~~low-value.~\\
~~~~88~no-more-records~~~~~~~~~~~~~value~high-value~\\
~~~~~~~when~set~to~false~is~~~~~~~~~~~~~~low-value.~\\
~\\
*>~***************************************************************~\\
~procedure~division.~\\
~\\
*>~Open~optional~index~file~for~read~write~\\
~open~i-o~indexing~\\
~\\
*>~populate~a~sample~database~\\
~move~"1234567800a01some~12345678~data~here"~to~indexing-record~\\
~perform~write-indexing-record~\\
~move~"8765432100a01some~87654321~data~here"~to~indexing-record~\\
~perform~write-indexing-record~\\
~move~"1234876500a01some~12348765~data~here"~to~indexing-record~\\
~perform~write-indexing-record~\\
~move~"8765123400a01some~87651234~data~here"~to~indexing-record~\\
~perform~write-indexing-record~\\
~\\
~move~"1234567900b02some~12345679~data~here"~to~indexing-record~\\
~perform~write-indexing-record~\\
~move~"9765432100b02some~97654321~data~here"~to~indexing-record~\\
~perform~write-indexing-record~\\
~move~"1234976500b02some~12349765~data~here"~to~indexing-record~\\
~perform~write-indexing-record~\\
~move~"9765123400b02some~97651234~data~here"~to~indexing-record~\\
~perform~write-indexing-record~\\
~\\
~move~"1234568900c13some~12345689~data~here"~to~indexing-record~\\
~perform~write-indexing-record~\\
~move~"9865432100c13some~98654321~data~here"~to~indexing-record~\\
~perform~write-indexing-record~\\
~move~"1234986500c13some~12349865~data~here"~to~indexing-record~\\
~perform~write-indexing-record~\\
~move~"9865123400c13some~98651234~data~here"~to~indexing-record~\\
~perform~write-indexing-record~\\
~\\
*>~close~it~...~not~necessary,~but~for~the~example~\\
~close~indexing~\\
~\\
*>~clear~the~record~space~for~this~example~\\
~move~spaces~to~indexing-record~\\
~\\
*>~open~the~data~file~again~\\
~open~i-o~indexing~\\
~\\
*>~read~all~the~duplicate~00b02~keys~\\
~move~00~to~first-part~of~indexing-record~\\
~move~"b"~to~middle-part~of~indexing-record~\\
~move~02~to~last-part~of~indexing-record~\\
~\\
*>~using~read~key~and~then~next~key~/~last~key~compare~\\
~set~no-more-duplicates~to~false~\\
~perform~read-indexing-record~\\
~perform~read-next-record~\\
~~~~~until~no-more-duplicates~\\
~\\
*>~read~by~key~of~reference~...~the~cool~stuff~\\
~move~00~to~first-part~of~indexing-record~\\
~move~"a"~to~middle-part~of~indexing-record~\\
~move~02~to~last-part~of~indexing-record~\\
~\\
*>~using~start~and~read~next~\\
~set~no-more-records~to~false~\\
~perform~start-at-key~\\
~perform~read-next-by-key~\\
~~~~~until~no-more-records~\\
~\\
*>~read~by~primary~key~of~reference~\\
~move~"87654321"~to~keyfield~of~indexing-record~\\
~\\
*>~\\
~set~no-more-records~to~false~\\
~perform~start-prime-key~\\
~perform~read-previous-by-key~\\
~~~~~until~no-more-records~\\
~\\
*>~and~with~that~we~are~done~with~indexing~sample~\\
~close~indexing~\\
~\\
~goback.~\\
*>~***************************************************************~\\
~\\
*><*~Write~paragraph~\\
~write-indexing-record.~\\
~~~~~write~indexing-record~\\
~~~~~~~~~invalid~key~\\
~~~~~~~~~~~~~display~\\
~~~~~~~~~~~~~~~~~"rewrite~key:~"~keyfield~of~indexing-record~\\
~~~~~~~~~~~~~end-display~\\
~~~~~~~~~~~~~rewrite~indexing-record~\\
~~~~~~~~~~~~~~~~~invalid~key~\\
~~~~~~~~~~~~~~~~~~~~~display~\\
~~~~~~~~~~~~~~~~~~~~~~~~~"really~bad~key:~"~\\
~~~~~~~~~~~~~~~~~~~~~~~~~keyfield~of~indexing-record~\\
~~~~~~~~~~~~~~~~~~~~~end-display~\\
~~~~~~~~~~~~~end-rewrite~\\
~~~~~end-write~\\
~.~\\
~\\
*><*~read~by~alternate~key~paragraph~\\
~read-indexing-record.~\\
~~~~~display~"Reading:~"~splitkey~of~indexing-record~end-display~\\
~~~~~read~indexing~key~is~splitkey~of~indexing-record~\\
~~~~~invalid~key~\\
~~~~~~~~~display~\\
~~~~~~~~~~~~"bad~read~key:~"~splitkey~of~indexing-record~\\
~~~~~~~~~end-display~\\
~~~~~~~~~set~no-more-duplicates~to~true~\\
~~~~~end-read~\\
~.~\\
~\\
*><*~read~next~sequential~paragraph~\\
~read-next-record.~\\
~~~~~move~corresponding~indexing-record~to~display-record~\\
~~~~~display~display-record~end-display~\\
~~~~~move~splitkey~of~indexing-record~to~oldkey~\\
~\\
~~~~~read~indexing~next~record~\\
~~~~~~~~~at~end~set~no-more-duplicates~to~true~\\
~~~~~~~~~not~at~end~\\
~~~~~~~~~~~~~if~oldkey~not~equal~splitkey~of~indexing-record~\\
~~~~~~~~~~~~~~~~~set~no-more-duplicates~to~true~\\
~~~~~~~~~~~~~end-if~\\
~~~~~end-read~\\
~.~\\
~\\
*><*~start~primary~key~of~reference~paragraph~\\
~start-prime-key.~\\
~~~~~display~"Prime~<~"~keyfield~of~indexing-record~end-display~\\
~~~~~start~indexing~\\
~~~~~~~~key~is~less~than~\\
~~~~~~~~~~~~keyfield~of~indexing-record~\\
~~~~~~~~invalid~key~\\
~~~~~~~~~~~~display~\\
~~~~~~~~~~~~~~~~"bad~start:~"~keyfield~of~indexing-record~\\
~~~~~~~~~~~~end-display~\\
~~~~~~~~~~~~set~no-more-records~to~true~\\
~~~~~~~~not~invalid~key~\\
~~~~~~~~~~~~read~indexing~previous~record~\\
~~~~~~~~~~~~~~~~at~end~set~no-more-records~to~true~\\
~~~~~~~~~~~~end-read~\\
~~~~~end-start~\\
~.~\\
~\\
*><*~read~previous~by~key~or~reference~paragraph~\\
~read-previous-by-key.~\\
~~~~~move~corresponding~indexing-record~to~display-record~\\
~~~~~display~display-record~end-display~\\
~\\
~~~~~read~indexing~previous~record~\\
~~~~~~~~~at~end~set~no-more-records~to~true~\\
~~~~~end-read~\\
~.~\\
*><*~start~alternate~key~of~reference~paragraph~\\
~start-at-key.~\\
~~~~~display~"Seeking~>=~"~splitkey~of~indexing-record~end-display~\\
~~~~~start~indexing~\\
~~~~~~~~key~is~greater~than~or~equal~to~\\
~~~~~~~~~~~~splitkey~of~indexing-record~\\
~~~~~~~~invalid~key~\\
~~~~~~~~~~~~display~\\
~~~~~~~~~~~~~~~~"bad~start:~"~splitkey~of~indexing-record~\\
~~~~~~~~~~~~end-display~\\
~~~~~~~~~~~~set~no-more-records~to~true~\\
~~~~~~~~not~invalid~key~\\
~~~~~~~~~~~~read~indexing~next~record~\\
~~~~~~~~~~~~~~~~at~end~set~no-more-records~to~true~\\
~~~~~~~~~~~~end-read~\\
~~~~~end-start~\\
~.~\\
~\\
*><*~read~next~by~key~or~reference~paragraph~\\
~read-next-by-key.~\\
~~~~~move~corresponding~indexing-record~to~display-record~\\
~~~~~display~display-record~end-display~\\
~\\
~~~~~read~indexing~next~record~\\
~~~~~~~~~at~end~set~no-more-records~to~true~\\
~~~~~end-read~\\
~.~\\
~end~program~indexing.~\\
*><*~\\
*><*~Last~Update:~20090220
}\end{quote}
which outputs:
\begin{quote}{\ttfamily \raggedright \noindent
Reading:~00b02~\\
~~~~12345679~~~0~b++~2-{}-{}-{}-some~12345679~data~here~\\
~~~~97654321~~~0~b++~2-{}-{}-{}-some~97654321~data~here~\\
~~~~12349765~~~0~b++~2-{}-{}-{}-some~12349765~data~here~\\
~~~~97651234~~~0~b++~2-{}-{}-{}-some~97651234~data~here~\\
~~~~12345679~~~0~b++~2-{}-{}-{}-some~12345679~data~here~\\
~~~~97654321~~~0~b++~2-{}-{}-{}-some~97654321~data~here~\\
~~~~12349765~~~0~b++~2-{}-{}-{}-some~12349765~data~here~\\
~~~~97651234~~~0~b++~2-{}-{}-{}-some~97651234~data~here~\\
~~~~12345679~~~0~b++~2-{}-{}-{}-some~12345679~data~here~\\
~~~~97654321~~~0~b++~2-{}-{}-{}-some~97654321~data~here~\\
~~~~12349765~~~0~b++~2-{}-{}-{}-some~12349765~data~here~\\
~~~~97651234~~~0~b++~2-{}-{}-{}-some~97651234~data~here~\\
Seeking~>=~00a02~\\
~~~~12345679~~~0~b++~2-{}-{}-{}-some~12345679~data~here~\\
~~~~97654321~~~0~b++~2-{}-{}-{}-some~97654321~data~here~\\
~~~~12349765~~~0~b++~2-{}-{}-{}-some~12349765~data~here~\\
~~~~97651234~~~0~b++~2-{}-{}-{}-some~97651234~data~here~\\
~~~~12345679~~~0~b++~2-{}-{}-{}-some~12345679~data~here~\\
~~~~97654321~~~0~b++~2-{}-{}-{}-some~97654321~data~here~\\
~~~~12349765~~~0~b++~2-{}-{}-{}-some~12349765~data~here~\\
~~~~97651234~~~0~b++~2-{}-{}-{}-some~97651234~data~here~\\
~~~~12345679~~~0~b++~2-{}-{}-{}-some~12345679~data~here~\\
~~~~97654321~~~0~b++~2-{}-{}-{}-some~97654321~data~here~\\
~~~~12349765~~~0~b++~2-{}-{}-{}-some~12349765~data~here~\\
~~~~97651234~~~0~b++~2-{}-{}-{}-some~97651234~data~here~\\
~~~~12345689~~~0~c++13-{}-{}-{}-some~12345689~data~here~\\
~~~~98654321~~~0~c++13-{}-{}-{}-some~98654321~data~here~\\
~~~~12349865~~~0~c++13-{}-{}-{}-some~12349865~data~here~\\
~~~~98651234~~~0~c++13-{}-{}-{}-some~98651234~data~here~\\
~~~~12345689~~~0~c++13-{}-{}-{}-some~12345689~data~here~\\
~~~~98654321~~~0~c++13-{}-{}-{}-some~98654321~data~here~\\
~~~~12349865~~~0~c++13-{}-{}-{}-some~12349865~data~here~\\
~~~~98651234~~~0~c++13-{}-{}-{}-some~98651234~data~here~\\
~~~~12345689~~~0~c++13-{}-{}-{}-some~12345689~data~here~\\
~~~~98654321~~~0~c++13-{}-{}-{}-some~98654321~data~here~\\
~~~~12349865~~~0~c++13-{}-{}-{}-some~12349865~data~here~\\
~~~~98651234~~~0~c++13-{}-{}-{}-some~98651234~data~here~\\
Prime~<~87654321~\\
~~~~87651234~~~0~a++~1-{}-{}-{}-some~87651234~data~here~\\
~~~~12349865~~~0~c++13-{}-{}-{}-some~12349865~data~here~\\
~~~~12349765~~~0~b++~2-{}-{}-{}-some~12349765~data~here~\\
~~~~12348765~~~0~a++~1-{}-{}-{}-some~12348765~data~here~\\
~~~~12345689~~~0~c++13-{}-{}-{}-some~12345689~data~here~\\
~~~~12345679~~~0~b++~2-{}-{}-{}-some~12345679~data~here~\\
~~~~12345678~~~0~a++~1-{}-{}-{}-some~12345678~data~here
}\end{quote}
on any first runs, where \textbf{indexing.dat} does not exist.
Subsequent runs have the same output with:
\begin{quote}{\ttfamily \raggedright \noindent
rewrite~key:~12345678~\\
rewrite~key:~87654321~\\
rewrite~key:~12348765~\\
rewrite~key:~87651234~\\
rewrite~key:~12345679~\\
rewrite~key:~97654321~\\
rewrite~key:~12349765~\\
rewrite~key:~97651234~\\
rewrite~key:~12345689~\\
rewrite~key:~98654321~\\
rewrite~key:~12349865~\\
rewrite~key:~98651234
}\end{quote}
prepended, as the WRITE INVALID KEY clause triggers a REWRITE to allow
overwriting key and data.
%___________________________________________________________________________
\hypertarget{does-opencobol-support-modules}{}
\pdfbookmark[1]{5.6~~~Does OpenCOBOL support modules?}{does-opencobol-support-modules}
\subsection*{5.6~~~Does OpenCOBOL support modules?}
\label{does-opencobol-support-modules}
Yes. Quite nicely in fact. Dynamically! \href{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 \href{\#call}{CALL} instruction maps COBOL \href{\#usage}{USAGE} to many common
C stack frame data representations.
Multipart, complex system development is well integrated in the OpenCOBOL
model.
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~cobc~-b~hello.cob~goodbye.cob
}\end{quote}
Combines both source files into a single dynamically loadable module.
Example produces \textbf{hello.so}.
Using the \textbf{-l} link library option, OpenCOBOL has access to most
shared libraries supported on it's platforms.
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~cobc~-x~-lcurl~showcurl.cob
}\end{quote}
Will link the /usr/lib/libcurl.so (\emph{from the cURL project}) to showcurl.
The OpenCOBOL \href{\#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.
For more information, see \href{\#what-is-cob-pre-load}{What is COB{\_}PRE{\_}LOAD?}.
%___________________________________________________________________________
\hypertarget{what-is-cob-pre-load}{}
\pdfbookmark[1]{5.7~~~What is COB{\_}PRE{\_}LOAD?}{what-is-cob-pre-load}
\subsection*{5.7~~~What is COB{\_}PRE{\_}LOAD?}
\label{what-is-cob-pre-load}
COB{\_}PRE{\_}LOAD is an environment variable that controls what dynamic link
modules are included in a run.
For example:
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~cobc~occurl.c~\\
{\$}~cobc~occgi.c~\\
{\$}~cobc~-x~myprog.cob~\\
{\$}~export~COB{\_}PRE{\_}LOAD=occurl:occgi~\\
{\$}~./myprog
}\end{quote}
That will allow the OpenCOBOL runtime link resolver to find
the entry point for CALL ``CBL{\_}OC{\_}CURL{\_}INIT'' in the occurl.so
module. \emph{Note:} the modules listed in the COB{\_}PRE{\_}LOAD environment
variable DO NOT have extensions. OpenCOBOL will do the right thing
on the various platforms.
If the \href{\#dso}{DSO} files are not in the current working directory along with
the executable, the COB{\_}LIBRARY{\_}PATH can be set to find them.
%___________________________________________________________________________
\hypertarget{what-is-the-opencobol-linkage-section-for}{}
\pdfbookmark[1]{5.8~~~What is the OpenCOBOL LINKAGE SECTION for?}{what-is-the-opencobol-linkage-section-for}
\subsection*{5.8~~~What is the OpenCOBOL LINKAGE SECTION for?}
\label{what-is-the-opencobol-linkage-section-for}
Argument passing in COBOL is normally accomplished through the
\textbf{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 \href{\#call}{CALL} for more details.
%___________________________________________________________________________
\hypertarget{what-does-the-fstatic-linkage-opencobol-compiler-option-do}{}
\pdfbookmark[1]{5.9~~~What does the -fstatic-linkage OpenCOBOL compiler option do?}{what-does-the-fstatic-linkage-opencobol-compiler-option-do}
\subsection*{5.9~~~What does the -fstatic-linkage OpenCOBOL compiler option do?}
\label{what-does-the-fstatic-linkage-opencobol-compiler-option-do}
Under normal conditions, the \emph{LINKAGE SECTION} is unallocated
and uninitialized. When a LINKAGE SECTION variable, that is not
part of the \emph{USING} phrase (not a named calling argument), any
memory that has been addressed becomes unaddressable across calls.
\emph{-fstatic-linkage} creates static addressing to the LINKAGE SECTION.
From [\hyperlink{roger}{Roger}]:
\begin{quote}{\ttfamily \raggedright \noindent
This~relates~to~LINKAGE~items~that~are~NOT~referred~\\
to~in~the~USING~phrase~of~the~PROCEDURE~DIVISION.~\\
It~also~only~has~relevance~when~the~program~is~CALL'ed~\\
from~another~prog.~\\
This~means~that~the~addressability~of~these~items~must~\\
be~programmed~(usually~with~SET~ADDRESS)~before~reference.~\\
~\\
Per~default,~the~item~loses~it's~addressability~on~exit~\\
from~the~program.~This~option~causes~the~module~to~retain~\\
the~item's~address~between~CALL~invocations~of~the~program.
}\end{quote}
With some rumours that this may become the default in future releases of
OpenCOBOL, and the \emph{-fstatic-linkage} option may be deprecated.
%___________________________________________________________________________
\hypertarget{does-opencobol-support-message-queues}{}
\pdfbookmark[1]{5.10~~~Does OpenCOBOL support Message Queues?}{does-opencobol-support-message-queues}
\subsection*{5.10~~~Does OpenCOBOL support Message Queues?}
\label{does-opencobol-support-message-queues}
Yes, but not out of the box. A linkable POSIX message queue layer
is available.
\begin{quote}{\ttfamily \raggedright \noindent
/*~OpenCOBOL~access~to~POSIX~Message~Queues~~~~~~~~~~~~~~~~~*/~\\
/*~Author:~Brian~Tiffin~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/~\\
/*~Date:~~~August,~2008~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/~\\
/*~Build:~~gcc~-c~ocmq.c~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/~\\
/*~Usage:~~cobc~-x~-lrt~program.cob~ocmq.o~~~~~~~~~~~~~~~~~~*/~\\
~\\
{\#}include~~~~~~~~~~~~/*~For~O{\_}*~constants~*/~\\
{\#}include~~~~~~~~~/*~For~mode~constants~*/~\\
{\#}include~~~~~~~~~~~~/*~Access~to~error~values~*/~\\
{\#}include~~~~~~~~~~~/*~The~message~queues~*/~\\
{\#}include~~~~~~~~~~~/*~for~notification~*/~\\
{\#}include~~~~~~~~~~~~~/*~for~the~timed~versions~*/~\\
{\#}include~~\\
{\#}include~~~~~~~~~~~/*~For~strerror~*/~\\
~\\
{\#}include~~~~~~~~~~~/*~for~cob{\_}resolve~*/~\\
~\\
/*~Forward~declarations~*/~\\
static~void~ocmq{\_}handler(int,~siginfo{\_}t~*,~void~*);~\\
static~void~(*MQHANDLER)(int~*mqid);~\\
~\\
/*~Return~C~runtime~global~errno~*/~\\
int~ERRORNUMBER()~{\{}~\\
~~~~return~errno;~\\
{\}}~\\
~\\
/*~Load~a~COBOL~field~with~an~error~string~*/~\\
int~ERRORSTRING(char~*errbuff,~int~buflen)~{\{}~\\
~~~~void~*temperr;~\\
~\\
~~~~temperr~=~strerror(errno);~\\
~~~~memcpy((void~*)errbuff,~temperr,~buflen);~\\
~~~~return~strlen(temperr);~\\
{\}}~\\
~\\
/*~\\
~\\
/*~Open~Message~Queue~*/~\\
int~MQOPEN(char~*mqname,~int~oflags)~{\{}~\\
~~~~mqd{\_}t~mqres;~\\
~\\
~~~~errno~=~0;~\\
~~~~mqres~=~mq{\_}open(mqname,~oflags);~\\
~~~~return~(int)mqres;~\\
{\}}~\\
~\\
/*~Creating~a~queue~requires~two~extra~arguments,~permissions~and~attributes~*/~\\
int~MQCREATE(char~*mqname,~int~oflags,~int~perms,~char~*mqattr)~{\{}~\\
~~~~mqd{\_}t~mqres;~\\
~\\
~~~~errno~=~0;~\\
~~~~mqres~=~mq{\_}open(mqname,~oflags,~(mode{\_}t)perms,~(struct~mq{\_}attr~*)mqattr);~\\
~~~~return~(int)mqres;~\\
{\}}~\\
~\\
/*~Get~current~queue~attributes~*/~\\
int~MQGETATTR(int~mqid,~char~*mqattr)~{\{}~\\
~~~~mqd{\_}t~mqres;~\\
~\\
~~~~errno~=~0;~\\
~~~~mqres~=~mq{\_}getattr((mqd{\_}t)mqid,~(struct~mq{\_}attr~*)mqattr);~\\
~~~~return~(int)mqres;~\\
{\}}~\\
~\\
/*~Set~current~queue~attributes~*/~\\
/*~~~only~accepts~mqflags~of~0~or~MQO-NONBLOCK~once~created~*/~\\
int~MQSETATTR(int~mqid,~char~*mqattr,~char~*oldattr)~{\{}~\\
~~~~mqd{\_}t~mqres;~\\
~\\
~~~~errno~=~0;~\\
~~~~mqres~=~mq{\_}setattr((mqd{\_}t)mqid,~(struct~mq{\_}attr~*)mqattr,~(struct~mq{\_}attr~*)oldattr);~\\
~~~~return~(int)mqres;~\\
{\}}~\\
~\\
/*~Send~a~message~to~the~queue~*/~\\
int~MQSEND(int~mqid,~char~*message,~int~length,~unsigned~int~mqprio)~{\{}~\\
~~~~mqd{\_}t~mqres;~\\
~\\
~~~~errno~=~0;~\\
~~~~mqres~=~mq{\_}send((mqd{\_}t)mqid,~message,~(size{\_}t)length,~mqprio);~\\
~~~~return~(int)mqres;~\\
{\}}~\\
~\\
/*~Read~the~highest~priority~message~*/~\\
int~MQRECEIVE(int~mqid,~char~*msgbuf,~int~buflen,~int~*retprio)~{\{}~\\
~~~~ssize{\_}t~retlen;~\\
~\\
~~~~errno~=~0;~\\
~~~~retlen~=~mq{\_}receive((mqd{\_}t)mqid,~msgbuf,~buflen,~retprio);~\\
~~~~return~(int)retlen;~\\
{\}}~\\
~\\
/*~Timeout~send~*/~\\
int~MQTIMEDSEND(int~mqid,~char~*message,~int~length,~unsigned~int~mqprio,~int~secs,~long~nanos)~{\{}~\\
~\\
~~~~mqd{\_}t~mqres;~\\
~~~~struct~timespec~mqtimer;~\\
~~~~struct~timeval~curtime;~\\
~\\
~~~~/*~Expect~seconds~and~nanos~to~wait,~not~absolute.~~Add~the~OpenCOBOL~values~*/~\\
~~~~gettimeofday({\&}curtime,~NULL);~\\
~~~~mqtimer.tv{\_}sec~=~curtime.tv{\_}sec~+~(time{\_}t)secs;~\\
~~~~mqtimer.tv{\_}nsec~=~nanos;~\\
~\\
~~~~errno~=~0;~\\
~~~~mqres~=~mq{\_}timedsend((mqd{\_}t)mqid,~message,~(size{\_}t)length,~mqprio,~{\&}mqtimer);~\\
~~~~return~(int)mqres;~\\
{\}}~\\
~\\
/*~Read~the~highest~priority~message~*/~\\
int~MQTIMEDRECEIVE(int~mqid,~char~*msgbuf,~int~buflen,~int~*retprio,~int~secs,~long~nanos)~{\{}~\\
~~~~ssize{\_}t~retlen;~\\
~~~~struct~timespec~mqtimer;~\\
~\\
~~~~struct~timeval~curtime;~\\
~\\
~~~~/*~Expect~seconds~and~nanos~to~wait,~not~absolute.~~Add~the~OpenCOBOL~values~*/~\\
~~~~gettimeofday({\&}curtime,~NULL);~\\
~~~~mqtimer.tv{\_}sec~=~curtime.tv{\_}sec~+~(time{\_}t)secs;~\\
~~~~mqtimer.tv{\_}nsec~=~nanos;~\\
~\\
~~~~errno~=~0;~\\
~~~~retlen~=~mq{\_}timedreceive((mqd{\_}t)mqid,~msgbuf,~buflen,~retprio,~{\&}mqtimer);~\\
~~~~return~(int)retlen;~\\
{\}}~\\
~\\
~\\
/*~Notify~of~new~message~written~to~queue~*/~\\
int~MQNOTIFY(int~mqid,~char~*procedure)~{\{}~\\
~~~~struct~sigevent~ocsigevent;~\\
~~~~struct~sigaction~ocsigaction;~\\
~\\
~~~~/*~Install~signal~handler~for~the~notify~signal~-~fill~in~a~\\
~~~~~*~sigaction~structure~and~pass~it~to~sigaction().~Because~the~\\
~~~~~*~handler~needs~the~siginfo~structure~as~an~argument,~the~\\
~~~~~*~SA{\_}SIGINFO~flag~is~set~in~sa{\_}flags.~\\
~~~~~*/~\\
~~~~ocsigaction.sa{\_}sigaction~=~ocmq{\_}handler;~\\
~~~~ocsigaction.sa{\_}flags~=~SA{\_}SIGINFO;~\\
~~~~sigemptyset({\&}ocsigaction.sa{\_}mask);~\\
~\\
~~~~if~(sigaction(SIGUSR1,~{\&}ocsigaction,~NULL)~==~-1)~{\{}~\\
~~~~~~~~fprintf(stderr,~"{\%}s{\textbackslash}n",~"Error~posting~sigaction");~\\
~~~~~~~~return~-1;~\\
~~~~{\}}~\\
~\\
~~~~/*~Set~up~notification:~fill~in~a~sigevent~structure~and~pass~it~\\
~~~~~*~to~mq{\_}notify().~The~queue~ID~is~passed~as~an~argument~to~the~\\
~~~~~*~signal~handler.~\\
~~~~~*/~\\
~~~~ocsigevent.sigev{\_}signo~~~~~~=~SIGUSR1;~\\
~~~~ocsigevent.sigev{\_}notify~~~~~=~SIGEV{\_}SIGNAL;~\\
~~~~ocsigevent.sigev{\_}value.sival{\_}int~=~(int)mqid;~\\
~\\
~~~~if~(mq{\_}notify((mqd{\_}t)mqid,~{\&}ocsigevent)~==~-1)~{\{}~\\
~~~~~~~~fprintf(stderr,~"{\%}s{\textbackslash}n",~"Error~posting~notify");~\\
~~~~~~~~return~-1;~\\
~~~~{\}}~\\
~~~~return~0;~\\
{\}}~\\
~\\
/*~Close~a~queue~*/~\\
int~MQCLOSE(int~mqid)~{\{}~\\
~~~~mqd{\_}t~mqres;~\\
~\\
~~~~errno~=~0;~\\
~~~~mqres~=~mq{\_}close((mqd{\_}t)mqid);~\\
~~~~return~(int)mqres;~\\
{\}}~\\
~\\
/*~Unlink~a~queue~*/~\\
int~MQUNLINK(char~*mqname)~{\{}~\\
~~~~mqd{\_}t~mqres;~\\
~\\
~~~~errno~=~0;~\\
~~~~mqres~=~mq{\_}unlink(mqname);~\\
~~~~return~(int)mqres;~\\
{\}}~\\
~\\
/*~The~signal~handling~section~*/~\\
/*~signal~number~*/~\\
/*~signal~information~*/~\\
/*~context~unused~(required~by~posix)~*/~\\
static~void~ocmq{\_}handler(int~sig,~siginfo{\_}t~*pInfo,~void~*pSigContext)~{\{}~\\
~~~~struct~sigevent~ocnotify;~\\
~~~~mqd{\_}t~mqid;~\\
~\\
~~~~/*~Get~the~ID~of~the~message~queue~out~of~the~siginfo~structure.~~~~~*/~\\
~~~~mqid~=~(mqd{\_}t)~pInfo->si{\_}value.sival{\_}int;~\\
~\\
~~~~/*~The~MQPROCESSOR~is~a~hardcoded~OpenCOBOL~resolvable~module~name~*/~\\
~~~~/*~~~It~must~accept~an~mqd{\_}t~pointer~~*/~\\
~~~~cob{\_}init(0,~NULL);~\\
~~~~MQHANDLER~=~cob{\_}resolve("MQPROCESSOR");~\\
~~~~if~(MQHANDLER~==~NULL)~{\{}~\\
~~~~~~~~/*~What~to~do~here?~*/~\\
~~~~~~~~fprintf(stderr,~"{\%}s{\textbackslash}n",~"Error~resolving~MQPROCESSOR");~\\
~~~~~~~~return;~\\
~~~~{\}}~\\
~\\
~~~~/*~Request~notification~again;~it~resets~each~time~a~notification~\\
~~~~~*~signal~goes~out.~\\
~~~~~*/~\\
~~~~ocnotify.sigev{\_}signo~=~pInfo->si{\_}signo;~\\
~~~~ocnotify.sigev{\_}value~=~pInfo->si{\_}value;~\\
~~~~ocnotify.sigev{\_}notify~=~SIGEV{\_}SIGNAL;~\\
~\\
~~~~if~(mq{\_}notify(mqid,~{\&}ocnotify)~==~-1)~{\{}~\\
~~~~~~~~/*~What~to~do~here?~*/~\\
~~~~~~~~fprintf(stderr,~"{\%}s{\textbackslash}n",~"Error~posting~notify");~\\
~~~~~~~~return;~\\
~~~~{\}}~\\
~\\
~~~~/*~Call~the~cobol~module~with~the~message~queue~id~*/~\\
~~~~MQHANDLER({\&}mqid);~\\
~~~~return;~\\
{\}}~\\
/**/
}\end{quote}
With a sample of usage. Note the linkage of the rt.so realtime
library.
\begin{quote}{\ttfamily \raggedright \noindent
OCOBOL~>{}>SOURCE~FORMAT~IS~FIXED~\\
~~~~~~******************************************************************~\\
~~~~~~*~Author:~~~~Brian~Tiffin~\\
~~~~~~*~Date:~~~~~~August~2008~\\
~~~~~~*~Purpose:~~~Demonstration~of~OpenCOBOL~message~queues~\\
~~~~~~*~Tectonics:~gcc~-c~ocmq.c~\\
~~~~~~*~~~~~~~~~~~~cobc~-Wall~-x~-lrt~mqsample.cob~ocmq.o~\\
~~~~~~******************************************************************~\\
~~~~~~~identification~division.~\\
~~~~~~~program-id.~mqsample.~\\
~\\
~~~~~~~data~division.~\\
~~~~~~~working-storage~section.~\\
~~~~~~*~Constants~for~the~Open~Flags~\\
~~~~~~~01~MQO-RDONLY~~~~~~~~~~~constant~as~0.~\\
~~~~~~~01~MQO-WRONLY~~~~~~~~~~~constant~as~1.~\\
~~~~~~~01~MQO-RDWR~~~~~~~~~~~~~constant~as~2.~\\
~~~~~~~01~MQO-CREAT~~~~~~~~~~~~constant~as~64.~\\
~~~~~~~01~MQO-EXCL~~~~~~~~~~~~~constant~as~128.~\\
~~~~~~~01~MQO-NONBLOCK~~~~~~~~~constant~as~2048.~\\
~~~~~~*~Constants~for~the~protection/permission~bits~\\
~~~~~~~01~MQS-IREAD~~~~~~~~~~~~constant~as~256.~\\
~~~~~~~01~MQS-IWRITE~~~~~~~~~~~constant~as~128.~\\
~\\
~~~~~~*~Need~a~better~way~of~displaying~newlines~\\
~~~~~~~01~newline~~~~~~~~~~~~~~pic~x~value~x'0a'.~\\
~\\
~~~~~~*~Message~Queues~return~an~ID,~maps~to~int~\\
~~~~~~~01~mqid~~~~~~~~~~~~~~~~~usage~binary-long.~\\
~~~~~~~01~mqres~~~~~~~~~~~~~~~~usage~binary-long.~\\
~~~~~~*~Queue~names~end~up~in~an~mqueue~virtual~filesystem~on~GNU/Linux~\\
~~~~~~~01~mqname.~\\
~~~~~~~~~~02~name-display~~~~~~pic~x(5)~value~"/ocmq".~\\
~~~~~~~~~~02~filler~~~~~~~~~~~~pic~x~value~x'00'.~\\
~~~~~~~01~mqopenflags~~~~~~~~~~usage~binary-long.~\\
~~~~~~~01~mqpermissions~~~~~~~~usage~binary-long.~\\
~\\
~~~~~~~01~default-message~~~~~~pic~x(20)~value~'OpenCOBOL~is~awesome'.~\\
~~~~~~~01~user-message~~~~~~~~~pic~x(80).~\\
~~~~~~~01~send-length~~~~~~~~~~usage~binary-long.~\\
~\\
~~~~~~~01~urgent-message~~~~~~~pic~x(20)~value~'Urgent~OpenCOBOL~msg'.~\\
~\\
~~~~~~*~Data~members~for~access~to~C~global~errno~and~error~strings~\\
~~~~~~~01~errnumber~~~~~~~~~~~~usage~binary-long.~\\
~~~~~~~01~errstr~~~~~~~~~~~~~~~pic~x(256).~\\
~~~~~~*~legend~to~use~with~the~error~reporting~\\
~~~~~~~01~operation~~~~~~~~~~~~pic~x(7).~\\
~\\
~~~~~~~01~loopy~~~~~~~~~~~~~~~~pic~9.~\\
~\\
~~~~~~*~Debian~GNU/Linux~defaults~to~Message~Queue~entry~limit~of~8K~\\
~~~~~~~01~msgbuf~~~~~~~~~~~~~~~pic~x(8192).~\\
~~~~~~~01~msglen~~~~~~~~~~~~~~~usage~binary-long~value~8192.~\\
~~~~~~*~Priorities~range~from~0~to~31~on~many~systems,~can~be~more~\\
~~~~~~~01~msgprio~~~~~~~~~~~~~~usage~binary-long.~\\
~~~~~~*~MQ~attributes.~~See~/usr/include/bits/mqueue.h~\\
~~~~~~~01~mqattr.~\\
~~~~~~~~~~03~mqflags~~~~~~~~~~~usage~binary-long.~\\
~~~~~~~~~~03~mqmaxmsg~~~~~~~~~~usage~binary-long.~\\
~~~~~~~~~~03~mqmsgsize~~~~~~~~~usage~binary-long.~\\
~~~~~~~~~~03~mqcurmsqs~~~~~~~~~usage~binary-long.~\\
~~~~~~~~~~03~filler~~~~~~~~~~~~usage~binary-long~occurs~4~times.~\\
~~~~~~~01~oldattr.~\\
~~~~~~~~~~03~mqflags~~~~~~~~~~~usage~binary-long.~\\
~~~~~~~~~~03~mqmaxmsg~~~~~~~~~~usage~binary-long.~\\
~~~~~~~~~~03~mqmsgsize~~~~~~~~~usage~binary-long.~\\
~~~~~~~~~~03~mqcurmsqs~~~~~~~~~usage~binary-long.~\\
~~~~~~~~~~03~filler~~~~~~~~~~~~usage~binary-long~occurs~4~times.~\\
~\\
~~~~~~~procedure~division.~\\
~~~~~~*~The~ocmq~API~support~MQCREATE~and~MQOPEN.~\\
~~~~~~*~This~example~uses~non~blocking,~non~exclusive~create~\\
~~~~~~*~~~read/write~by~owner~and~default~attributes~\\
~~~~~~~compute~\\
~~~~~~~~~~~mqopenflags~=~MQO-RDWR~+~MQO-CREAT~+~MQO-NONBLOCK~\\
~~~~~~~end-compute.~\\
~~~~~~~compute~\\
~~~~~~~~~~~mqpermissions~=~MQS-IREAD~+~MQS-IWRITE~\\
~~~~~~~end-compute.~\\
~\\
~~~~~~*~Sample~shows~the~two~types~of~open,~but~only~evaluates~create~\\
~~~~~~~if~zero~=~zero~\\
~~~~~~~call~"MQCREATE"~using~mqname~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~mqopenflags~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~mqpermissions~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~0~\\
~~~~~~~~~~~~~~~~~~~~~~~returning~mqid~\\
~~~~~~~end-call~\\
~~~~~~~else~\\
~~~~~~~call~"MQOPEN"~using~mqname~\\
~~~~~~~~~~~~~~~~~~~~~~~~~by~value~mqopenflags~\\
~~~~~~~~~~~~~~~~~~~~~returning~mqid~\\
~~~~~~~end-call~\\
~~~~~~~end-if.~\\
~~~~~~~move~"create"~to~operation.~\\
~~~~~~~perform~show-error.~\\
~\\
~~~~~~*~Show~the~attributes~after~initial~create~\\
~~~~~~~perform~show-attributes.~\\
~\\
~~~~~~*~Register~notification~\\
~~~~~~~call~"MQNOTIFY"~using~by~value~mqid~\\
~~~~~~~~~~~~~~~~~~~~~~~mqname~\\
~~~~~~~~~~~~~~~~~~~~~~~returning~mqres~\\
~~~~~~~end-call.~\\
~~~~~~~move~"notify"~to~operation.~\\
~~~~~~~perform~show-error.~\\
~\\
~~~~~~*~Create~a~temporary~queue,~will~be~removed~on~close~\\
~~~~~~*~call~"MQUNLINK"~using~mqname~\\
~~~~~~*~~~~~~~~~~~~~~~~returning~mqres~\\
~~~~~~*~end-call.~\\
~~~~~~*~move~"unlink"~to~operation.~\\
~~~~~~*~perform~show-error.~\\
~\\
~~~~~~*~Use~the~command~line~arguments~or~a~default~message~\\
~~~~~~~accept~user-message~from~command-line~end-accept.~\\
~~~~~~~if~user-message~equal~spaces~\\
~~~~~~~~~~~move~default-message~to~user-message~\\
~~~~~~~end-if.~\\
~~~~~~~move~function~length~\\
~~~~~~~~~~~(function~trim(user-message~trailing))~\\
~~~~~~~~~~~to~send-length.~\\
~\\
~~~~~~*~Queue~up~an~urgent~message~(priority~31)~\\
~~~~~~~call~"MQSEND"~using~by~value~mqid~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~urgent-message~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~20~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~31~\\
~~~~~~~end-call.~\\
~~~~~~~move~"send-31"~to~operation.~\\
~~~~~~~perform~show-error.~\\
~\\
~~~~~~*~Queue~up~a~low~priority~message~(1)~\\
~~~~~~~call~"MQSEND"~using~by~value~mqid~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~user-message~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~send-length~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~1~\\
~~~~~~~~~~~~~~~~~~~~~returning~mqres~\\
~~~~~~~end-call.~\\
~~~~~~~move~"send-1"~to~operation.~\\
~~~~~~~perform~show-error.~\\
~\\
~~~~~~*~Queue~up~a~middle~priority~message~(16)~\\
~~~~~~~inspect~urgent-message~\\
~~~~~~~~~~~replacing~leading~"Urgent"~by~"Middle".~\\
~~~~~~~call~"MQSEND"~using~by~value~mqid~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~urgent-message~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~20~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~16~\\
~~~~~~~~~~~~~~~~~~~~~returning~mqres~\\
~~~~~~~end-call.~\\
~~~~~~~move~"send-16"~to~operation.~\\
~~~~~~~perform~show-error.~\\
~\\
~~~~~~*~Redisplay~the~queue~attributes~\\
~~~~~~~perform~show-attributes.~\\
~\\
~~~~~~*~Pull~highest~priority~message~off~queue~\\
~~~~~~~call~"MQRECEIVE"~using~by~value~mqid~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~msgbuf~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~msglen~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~msgprio~\\
~~~~~~~~~~~~~~~~~~~~~~~~returning~mqres~\\
~~~~~~~end-call.~\\
~~~~~~~display~\\
~~~~~~~~~~~newline~"recieve~len:~"~mqres~"~prio:~"~msgprio~\\
~~~~~~~end-display.~\\
~~~~~~~if~mqres~>~0~\\
~~~~~~~~~~~display~\\
~~~~~~~~~~~~~~~"priority~31~message:~"~msgbuf(1:mqres)~\\
~~~~~~~~~~~end-display~\\
~~~~~~~end-if.~\\
~~~~~~~move~"receive"~to~operation.~\\
~~~~~~~perform~show-error.~\\
~\\
~~~~~~*~Pull~the~middling~priority~message~off~queue~\\
~~~~~~~call~"MQRECEIVE"~using~by~value~mqid~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~msgbuf~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~msglen~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~msgprio~\\
~~~~~~~~~~~~~~~~~~~~~~~~returning~mqres~\\
~~~~~~~end-call.~\\
~~~~~~~display~\\
~~~~~~~~~~~newline~"recieve~len:~"~mqres~"~prio:~"~msgprio~\\
~~~~~~~end-display.~\\
~~~~~~~if~mqres~>~0~\\
~~~~~~~~~~~display~\\
~~~~~~~~~~~~~~~"priority~16~message:~"~msgbuf(1:mqres)~\\
~~~~~~~~~~~end-display~\\
~~~~~~~end-if.~\\
~~~~~~~move~"receive"~to~operation.~\\
~~~~~~~perform~show-error.~\\
~\\
~~~~~~*~**~INTENTIONAL~ERROR~msglen~param~too~small~**~\\
~~~~~~*~Pull~message~off~queue~\\
~~~~~~~call~"MQRECEIVE"~using~by~value~mqid~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~msgbuf~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~1024~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~msgprio~\\
~~~~~~~~~~~~~~~~~~~~~~~~returning~mqres~\\
~~~~~~~end-call.~\\
~~~~~~~display~\\
~~~~~~~~~~~newline~"recieve~len:~"~mqres~"~prio:~"~msgprio~\\
~~~~~~~end-display.~\\
~~~~~~~if~mqres~>~0~\\
~~~~~~~~~~~display~\\
~~~~~~~~~~~~~~~"no~message:~"~msgbuf(1:mqres)~\\
~~~~~~~~~~~end-display~\\
~~~~~~~end-if.~\\
~~~~~~~move~"receive"~to~operation.~\\
~~~~~~~perform~show-error.~\\
~\\
~~~~~~*~Pull~the~low~priority~message~off~queue,~in~blocking~mode~\\
~~~~~~~move~MQO-NONBLOCK~to~mqflags~of~mqattr.~\\
~~~~~~~call~"MQSETATTR"~using~by~value~mqid~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~mqattr~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~oldattr~\\
~~~~~~~~~~~~~~~~~~~~~~~~returning~mqres~\\
~~~~~~~end-call~\\
~~~~~~~move~"setattr"~to~operation.~\\
~~~~~~~perform~show-error.~\\
~~~~~~~perform~show-attributes.~\\
~\\
~~~~~~~call~"MQRECEIVE"~using~by~value~mqid~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~msgbuf~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~msglen~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~msgprio~\\
~~~~~~~~~~~~~~~~~~~~~~~~returning~mqres~\\
~~~~~~~end-call.~\\
~~~~~~~display~\\
~~~~~~~~~~~newline~"recieve~len:~"~mqres~"~prio:~"~msgprio~\\
~~~~~~~end-display.~\\
~~~~~~~if~mqres~>~0~\\
~~~~~~~~~~~display~\\
~~~~~~~~~~~~~~~"priority~1~message:~"~msgbuf(1:mqres)~\\
~~~~~~~~~~~end-display~\\
~~~~~~~end-if.~\\
~~~~~~~move~"receive"~to~operation.~\\
~~~~~~~perform~show-error.~\\
~\\
~~~~~~~perform~varying~loopy~from~1~by~1~\\
~~~~~~~~~~~until~loopy~>~5~\\
~~~~~~~~~~~~~~~display~"Sleeper~call~"~loopy~end-display~\\
~~~~~~~~~~~~~~~call~"CBL{\_}OC{\_}NANOSLEEP"~using~50000000000~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~returning~mqres~\\
~~~~~~~~~~~~~~~end-call~\\
~~~~~~~end-perform.~\\
~\\
~~~~~~*~Close~the~queue.~~As~it~is~set~unlinked,~it~will~be~removed~\\
~~~~~~~call~"MQCLOSE"~using~by~value~mqid~\\
~~~~~~~~~~~~~~~~~~~~~~returning~mqres~\\
~~~~~~~end-call.~\\
~~~~~~~move~"close"~to~operation.~\\
~~~~~~~perform~show-error.~\\
~\\
~~~~~~*~Create~a~temporary~queue,~will~be~removed~on~close~\\
~~~~~~~call~"MQUNLINK"~using~mqname~\\
~~~~~~~~~~~~~~~~~~~~~~~returning~mqres~\\
~~~~~~~end-call.~\\
~~~~~~~move~"unlink"~to~operation.~\\
~~~~~~~perform~show-error.~\\
~\\
~~~~~~~goback.~\\
~\\
~~~~~~******************************************************************~\\
~~~~~~*~Information~display~of~the~Message~Queue~attributes.~\\
~~~~~~~show-attributes.~\\
~~~~~~~call~"MQGETATTR"~using~by~value~mqid~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~mqattr~\\
~~~~~~~~~~~~~~~~~~~~~~~~returning~mqres~\\
~~~~~~~end-call~\\
~~~~~~~move~"getattr"~to~operation.~\\
~~~~~~~perform~show-error.~\\
~\\
~~~~~~*~Display~the~message~queue~attributes~\\
~~~~~~~display~\\
~~~~~~~~~~~name-display~"~attributes:"~~~~~~~newline~\\
~~~~~~~~~~~"flags:~~~~"~mqflags~~~of~mqattr~~newline~\\
~~~~~~~~~~~"max~msg:~~"~mqmaxmsg~~of~mqattr~~newline~\\
~~~~~~~~~~~"mqs~size:~"~mqmsgsize~of~mqattr~~newline~\\
~~~~~~~~~~~"cur~msgs:~"~mqcurmsqs~of~mqattr~\\
~~~~~~~end-display~\\
~~~~~~~.~\\
~\\
~~~~~~*~The~C~global~errno~error~display~paragraph~\\
~~~~~~~show-error.~\\
~~~~~~~~~~~call~"ERRORNUMBER"~returning~mqres~end-call~\\
~~~~~~~~~~~if~mqres~>~0~\\
~~~~~~~~~~~~~~~display~\\
~~~~~~~~~~~~~~~~~~~operation~"~errno:~"~mqres~\\
~~~~~~~~~~~~~~~end-display~\\
~~~~~~~~~~~~~~~call~"ERRORSTRING"~using~errstr~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~length~errstr~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~returning~mqres~end-call~\\
~~~~~~~~~~~~~~~if~mqres~>~0~\\
~~~~~~~~~~~~~~~~~~~display~\\
~~~~~~~~~~~~~~~~~~~~~~~"~~~~~strerror:~"~errstr(1:mqres)~\\
~~~~~~~~~~~~~~~~~~~end-display~\\
~~~~~~~~~~~~~~~end-if~\\
~~~~~~~~~~~end-if~\\
~~~~~~~.~\\
~~~~~~~end~program~mqsample.~\\
~\\
~~~~~~******************************************************************~\\
~~~~~~*~Author:~~~~Brian~Tiffin~\\
~~~~~~*~Date:~~~~~~August~2008~\\
~~~~~~*~Purpose:~~~Demonstration~of~OpenCOBOL~message~queue~notification~\\
~~~~~~*~Tectonics:~gcc~-c~ocmq.c~\\
~~~~~~*~~~~~~~~~~~~cobc~-Wall~-x~-lrt~mqsample.cob~ocmq.o~\\
~~~~~~******************************************************************~\\
~~~~~~~identification~division.~\\
~~~~~~~program-id.~MQSIGNAL.~\\
~\\
~~~~~~~data~division.~\\
~~~~~~~working-storage~section.~\\
~~~~~~~01~msgbuf~pic~x(8192).~\\
~~~~~~~01~msglen~usage~binary-long~value~8192.~\\
~~~~~~~01~msgprio~usage~binary-long.~\\
~~~~~~~01~mqres~~usage~binary-long.~\\
~\\
~~~~~~~linkage~section.~\\
~~~~~~~01~mqid~usage~binary-long.~\\
~\\
~~~~~~~procedure~division~using~mqid.~\\
~\\
~~~~~~~display~"in~MQSIGNAL".~\\
~~~~~~~display~"In~the~COBOL~procedure~with~"~mqid~end-display.~\\
~~~~~~~perform~\\
~~~~~~~~~~~with~test~after~\\
~~~~~~~~~~~until~mqres~<=~0~\\
~~~~~~*~Pull~highest~priority~message~off~queue~\\
~~~~~~~~~~~call~"MQRECEIVE"~using~by~value~mqid~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~msgbuf~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~value~msglen~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~by~reference~msgprio~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~returning~mqres~\\
~~~~~~~~~~~end-call~\\
~~~~~~~~~~~display~\\
~~~~~~~~~~~~~~~"recieve~len:~"~mqres~"~prio:~"~msgprio~\\
~~~~~~~~~~~end-display~\\
~~~~~~~~~~~if~mqres~>~0~\\
~~~~~~~~~~~~~~~display~\\
~~~~~~~~~~~~~~~~~~~"priority~31~message:~"~msgbuf(1:mqres)~\\
~~~~~~~~~~~~~~~end-display~\\
~~~~~~~~~~~end-if~\\
~~~~~~*~~~~move~"receive"~to~operation~\\
~~~~~~*~~~~perform~show-error~\\
~~~~~~~end-perform.~\\
~\\
~~~~~~~goback.~\\
~~~~~~~end~program~MQSIGNAL.
}\end{quote}
%___________________________________________________________________________
\hypertarget{can-opencobol-interface-with-lua}{}
\pdfbookmark[1]{5.11~~~Can OpenCOBOL interface with Lua?}{can-opencobol-interface-with-lua}
\subsection*{5.11~~~Can OpenCOBOL interface with Lua?}
\label{can-opencobol-interface-with-lua}
Yes. Lua can be embedded in OpenCOBOL applications.
\begin{quote}{\ttfamily \raggedright \noindent
*>{}>SOURCE~FORMAT~IS~FIXED~\\
*><*~=======================~\\
*><*~OpenCOBOL~Lua~Interface~\\
*><*~=======================~\\
*><*~\\
*><*~..~sidebar::~Contents~\\
*><*~\\
*><*~~~~~..~contents::~\\
*><*~~~~~~~~~:local:~\\
*><*~~~~~~~~~:depth:~2~\\
*><*~~~~~~~~~:backlinks:~entry~\\
*><*~\\
*><*~:Author:~~~~Brian~Tiffin~\\
*><*~:Date:~~~~~~28-Oct-2008~\\
*><*~:Purpose:~~~interface~to~Lua~scripting~\\
*><*~:Rights:~~~~|~Copyright~2008~Brian~Tiffin~\\
*><*~~~~~~~~~~~~~|~Licensed~under~the~GNU~General~Public~License~\\
*><*~~~~~~~~~~~~~|~No~warranty~expressed~or~implied~\\
*><*~:Tectonics:~|~cobc~-c~-I/usr/include/lua5.1/~oclua.c~\\
*><*~~~~~~~~~~~~~|~cobc~-x~-llua5.1~luacaller.cob~oclua.o~\\
*><*~~~~~~~~~~~~~|~./ocdoc~luacaller.cob~oclua.rst~oclua.html~ocfaq.css~\\
*><*~:Requires:~~lua5.1,~liblua5.1,~liblua5.1-dev~\\
*><*~:Link:~~~~~~http://www.lua.org~\\
*><*~:Thanks~to:~The~Lua~team,~Pontifical~Catholic~University~\\
*><*~~~~~~~~~~~~~of~Rio~de~Janeiro~in~Brazil.~\\
*><*~~~~~~~~~~~~~http://www.lua.org/authors.html~\\
*><*~:Sources:~~~|~http://opencobol.add1tocobol.com/luacaller.cob~\\
*><*~~~~~~~~~~~~~|~http://opencobol.add1tocobol.com/oclua.c~\\
*><*~~~~~~~~~~~~~|~http://opencobol.add1tocobol.com/oclua.lua~\\
*><*~~~~~~~~~~~~~|~http://opencobol.add1tocobol.com/oclua.rst~\\
*><*~~~~~~~~~~~~~|~http://opencobol.add1tocobol.com/ocfaq.rss~\\
*><*~\\
*>~***************************************************************~\\
~identification~division.~\\
~program-id.~luacaller.~\\
~\\
~data~division.~\\
~working-storage~section.~\\
~01~luastate~~~~~~~~~~~~~usage~pointer.~\\
~01~luascript~~~~~~~~~~~~pic~x(10)~value~'oclua.lua'~{\&}~x"00".~\\
~01~luacommand~~~~~~~~~~~pic~x(64).~\\
~01~luaresult~~~~~~~~~~~~pic~x(32).~\\
~01~lualength~~~~~~~~~~~~usage~binary-long.~\\
~\\
~01~items~~~~~~~~~~~~~~~~pic~9~usage~computational-5.~\\
~01~luastack.~\\
~~~~03~luaitem~~~~~~~~~~~pic~x(32)~occurs~5~times.~\\
~01~depth~~~~~~~~~~~~~~~~usage~binary-long.~\\
~\\
*>~**************************************************************~\\
~procedure~division.~\\
~\\
~call~"OCLUA{\_}OPEN"~returning~luastate~end-call~\\
~\\
~move~'return~"OpenCOBOL~"~..~1.0~+~0.1'~{\&}~x"00"~to~luacommand~\\
~call~"OCLUA{\_}DOSTRING"~\\
~~~~~using~\\
~~~~~~~~~by~value~luastate~\\
~~~~~~~~~by~reference~luacommand~\\
~~~~~~~~~by~reference~luaresult~\\
~~~~~~~~~by~value~function~length(luaresult)~\\
~~~~~returning~depth~\\
~end-call~\\
~display~\\
~~~~~"OpenCOBOL~displays:~"~depth~"~|"~luaresult~"|"~\\
~end-display~\\
~\\
~call~"OCLUA{\_}DOFILE"~\\
~~~~~using~\\
~~~~~~~~~by~value~luastate~\\
~~~~~~~~~by~reference~luascript~\\
~~~~~~~~~by~reference~luaresult~\\
~~~~~~~~~by~value~32~\\
~~~~~returning~depth~\\
~end-call~\\
~display~\\
~~~~~"OpenCOBOL~displays:~"~depth~"~|"~luaresult~"|"~\\
~end-display~\\
~\\
~call~"OCLUA{\_}DOFILE"~\\
~~~~~using~\\
~~~~~~~~~by~value~luastate~\\
~~~~~~~~~by~reference~luascript~\\
~~~~~~~~~by~reference~luaresult~\\
~~~~~~~~~by~value~32~\\
~~~~~returning~depth~\\
~end-call~\\
~display~\\
~~~~~"OpenCOBOL~displays:~"~depth~"~|"~luaresult~"|"~\\
~end-display~\\
~\\
~call~"OCLUA{\_}DEPTH"~\\
~~~~~using~\\
~~~~~~~~~by~value~luastate~\\
~~~~~returning~depth~\\
~end-call~\\
~display~"Lua~depth:~"~depth~end-display~\\
~\\
~perform~varying~items~from~1~by~1~\\
~~~~~until~items~>~depth~\\
~~~~~~~~~call~"OCLUA{\_}GET"~\\
~~~~~~~~~~~~~using~\\
~~~~~~~~~~~~~~~~~by~value~luastate~\\
~~~~~~~~~~~~~~~~~by~value~items~\\
~~~~~~~~~~~~~~~~~by~reference~luaresult~\\
~~~~~~~~~~~~~~~~~by~value~32~\\
~~~~~~~~~~~~~returning~lualength~\\
~~~~~~~~~end-call~\\
~~~~~~~~~move~luaresult~to~luaitem(items)~\\
~end-perform~\\
~\\
~perform~varying~items~from~1~by~1~\\
~~~~~until~items~>~depth~\\
~~~~~~~~~display~\\
~~~~~~~~~~~~~"Item~"~items~":~"~luaitem(items)~\\
~~~~~~~~~end-display~\\
~end-perform~\\
~\\
~call~"OCLUA{\_}POP"~\\
~~~~~using~\\
~~~~~~~~~by~value~luastate~\\
~~~~~~~~~by~value~depth~\\
~~~~~returning~depth~\\
~end-call~\\
~\\
~call~"OCLUA{\_}DEPTH"~\\
~~~~~using~\\
~~~~~~~~~by~value~luastate~\\
~~~~~returning~depth~\\
~end-call~\\
~\\
~display~"Lua~depth:~"~depth~end-display~\\
~\\
~call~"OCLUA{\_}CLOSE"~using~by~value~luastate~end-call~\\
~\\
~goback.~\\
~end~program~luacaller.~\\
*>~***************************************************************~\\
*><*~++++++++~\\
*><*~Overview~\\
*><*~++++++++~\\
*><*~The~OpenCOBOL~Lua~interface~is~defined~at~a~very~high~level.~\\
*><*~\\
*><*~The~objective~is~to~provide~easy~access~to~Lua~through~\\
*><*~script~files~or~strings~to~be~evaluated.~\\
*><*~\\
*><*~Command~strings~and~script~file~names~passed~to~Lua~MUST~be~\\
*><*~terminated~with~a~null~byte,~as~per~C~Language~conventions.~\\
*><*~\\
*><*~A~Lua~engine~is~started~with~a~call~to~OCLUA{\_}OPEN,~which~\\
*><*~returns~an~OpenCOBOL~POINTER~that~is~used~to~reference~\\
*><*~the~Lua~state~for~all~further~calls.~\\
*><*~\\
*><*~A~Lua~engine~is~run~down~with~a~call~to~OCLUA{\_}CLOSE.~\\
*><*~\\
*><*~..~Attention::~\\
*><*~~~Calls~to~Lua~without~a~valid~state~will~cause~\\
*><*~~~undefined~behaviour~and~crash~the~application.~\\
*><*~\\
*><*~Lua~uses~a~stack~and~results~of~the~Lua~RETURN~reserved~\\
*><*~word~are~placed~on~this~stack.~~Multiple~values~can~be~\\
*><*~returned~from~Lua.~\\
*><*~\\
*><*~The~developer~is~responsible~for~stack~overflow~conditions~\\
*><*~and~the~size~of~the~stack~(default~20~elements)~is~\\
*><*~controlled~with~OCLUA{\_}STACK~using~an~integer~that~\\
*><*~determines~the~numbers~of~slots~to~reserve.~\\
*><*~\\
*><*~Requires~package~installs~of:~\\
*><*~\\
*><*~*~lua5.1~\\
*><*~*~liblua5.1~\\
*><*~*~liblua5.1-dev~\\
*><*~\\
*><*~+++++++++++++++++~\\
*><*~OpenCOBOL~Lua~API~\\
*><*~+++++++++++++++++~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~OCLUA{\_}OPEN~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~Initialize~the~Lua~engine.~\\
*><*~\\
*><*~::~\\
*><*~\\
*><*~~~01~luastate~USAGE~POINTER.~\\
*><*~\\
*><*~~~CALL~"OCLUA{\_}OPEN"~RETURNING~luastate~END-CALL~\\
*><*~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~OCLUA{\_}STACK~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~Check~and~possibly~resize~the~Lua~data~stack.~~Returns~0~if~\\
*><*~Lua~cannot~expand~the~stack~to~the~requested~size.~\\
*><*~\\
*><*~::~\\
*><*~\\
*><*~~~01~elements~USAGE~BINARY-LONG~VALUE~32.~\\
*><*~~~01~result~~~USAGE~BINARY-LONG.~\\
*><*~\\
*><*~~~CALL~"OCLUA{\_}STACK"~\\
*><*~~~~~~~USING~\\
*><*~~~~~~~~~~~BY~VALUE~luastate~\\
*><*~~~~~~~~~~~BY~VALUE~elements~\\
*><*~~~~~~~RETURNING~result~\\
*><*~~~END-CALL~\\
*><*~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~OCLUA{\_}DOSTRING~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~Evaluate~a~null~terminated~alphanumeric~field~as~a~Lua~program~\\
*><*~producing~any~top~of~stack~entry~and~returning~the~depth~of~\\
*><*~stack~after~evaluation.~\\
*><*~\\
*><*~Takes~a~luastate,~a~null~terminated~command~string,~\\
*><*~a~result~field~and~length~and~returns~an~integer~depth.~\\
*><*~\\
*><*~..~Attention::~\\
*><*~~~The~Lua~stack~is~NOT~popped~while~returning~the~top~of~stack~entry.~\\
*><*~\\
*><*~::~\\
*><*~\\
*><*~~~01~luacommand~pic~x(64).~\\
*><*~~~01~luaresult~~pic~x(32).~\\
*><*~~~01~depth~~~~~~usage~binary-long.~\\
*><*~\\
*><*~~~move~'return~"OpenCOBOL~"~..~1.0~+~0.1'~{\&}~x"00"~to~luacommand~\\
*><*~~~call~"OCLUA{\_}DOSTRING"~\\
*><*~~~~~~~using~\\
*><*~~~~~~~~~~~by~value~luastate~\\
*><*~~~~~~~~~~~by~reference~luacommand~\\
*><*~~~~~~~~~~~by~reference~luaresult~\\
*><*~~~~~~~~~~~by~value~function~length(luaresult)~\\
*><*~~~~~~~returning~depth~\\
*><*~~~end-call~\\
*><*~~~display~\\
*><*~~~~~~~"OpenCOBOL~displays:~"~depth~"~|"~luaresult~"|"~\\
*><*~~~end-display~\\
*><*~\\
*><*~Outputs::~\\
*><*~\\
*><*~~~OpenCOBOL~displays:~+0000000001~|OpenCOBOL~1.1~~~~~~~~~~~~~~~~~~~||~\\
*><*~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~OCLUA{\_}DOFILE~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~Evaluate~a~script~using~a~null~terminated~alphanumeric~field~\\
*><*~naming~a~Lua~program~source~file,~retrieving~any~top~of~\\
*><*~stack~entry~and~returning~the~depth~of~stack~after~evaluation.~\\
*><*~\\
*><*~Takes~a~luastate,~a~null~terminated~filename,~\\
*><*~a~result~field~and~length~and~returns~an~integer~depth.~\\
*><*~\\
*><*~..~Attention::~\\
*><*~~~The~Lua~stack~is~NOT~popped~while~returning~the~top~of~\\
*><*~~~stack~entry.~\\
*><*~\\
*><*~::~\\
*><*~\\
*><*~~~01~luascript~~pic~x(10)~value~'oclua.lua'~{\&}~x"00".~\\
*><*~~~01~luaresult~~pic~x(32).~\\
*><*~\\
*><*~~~call~"OCLUA{\_}DOFILE"~\\
*><*~~~~~~~using~\\
*><*~~~~~~~~~~~by~value~luastate~\\
*><*~~~~~~~~~~~by~reference~luascript~\\
*><*~~~~~~~~~~~by~reference~luaresult~\\
*><*~~~~~~~~~~~by~value~function~length(luaresult)~\\
*><*~~~~~~~returning~depth~\\
*><*~~~end-call~\\
*><*~~~display~\\
*><*~~~~~~~"OpenCOBOL~displays:~"~depth~"~|"~luaresult~"|"~\\
*><*~~~end-display~\\
*><*~\\
*><*~Given~oclua.lua::~\\
*><*~\\
*><*~~~-{}-~Start~\\
*><*~~~-{}-~Script:~oclua.lua~\\
*><*~~~print("Lua~prints~hello")~\\
*><*~\\
*><*~~~hello~=~"Hello~OpenCOBOL~from~Lua"~\\
*><*~~~return~math.pi,~hello~\\
*><*~~~-{}-~End~\\
*><*~\\
*><*~Outputs::~\\
*><*~\\
*><*~~~Lua~prints~hello~\\
*><*~~~OpenCOBOL~displays:~+0000000002~|Hello~OpenCOBOL~from~Lua~~~~~~~~||~\\
*><*~\\
*><*~and~on~return~from~Lua,~there~is~*math.pi*~and~the~\\
*><*~Hello~string~remaining~on~the~Lua~state~stack.~\\
*><*~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~OCLUA{\_}DEPTH~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~Returns~the~current~number~of~elements~on~the~Lua~stack.~\\
*><*~\\
*><*~::~\\
*><*~\\
*><*~~~call~"OCLUA{\_}DEPTH"~\\
*><*~~~~~~~using~\\
*><*~~~~~~~~~~~by~value~luastate~\\
*><*~~~~~~~returning~depth~\\
*><*~~~end-call~\\
*><*~~~display~"Lua~depth:~"~depth~end-display~\\
*><*~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~OCLUA{\_}GET~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~Retrieves~values~from~the~Lua~stack,~returning~the~length~\\
*><*~of~the~retrieved~item.~\\
*><*~\\
*><*~An~example~that~populates~and~displays~an~OpenCOBOL~table::~\\
*><*~\\
*><*~~~01~items~~~~~~~~~~~~~~~~pic~9~usage~computational-5.~\\
*><*~~~01~luastack.~\\
*><*~~~~~~03~luaitem~~~~~~~~~~~pic~x(32)~occurs~5~times.~\\
*><*~\\
*><*~~~perform~varying~items~from~1~by~1~\\
*><*~~~~~~~until~items~>~depth~\\
*><*~~~~~~~~~~~call~"OCLUA{\_}GET"~\\
*><*~~~~~~~~~~~~~~~using~\\
*><*~~~~~~~~~~~~~~~~~~~by~value~luastate~\\
*><*~~~~~~~~~~~~~~~~~~~by~value~items~\\
*><*~~~~~~~~~~~~~~~~~~~by~reference~luaresult~\\
*><*~~~~~~~~~~~~~~~~~~~by~value~function~length(luaresult)~\\
*><*~~~~~~~~~~~~~~~returning~lualength~\\
*><*~~~~~~~~~~~end-call~\\
*><*~~~~~~~~~~~move~luaresult~to~luaitem(items)~\\
*><*~~~end-perform~\\
*><*~\\
*><*~~~perform~varying~items~from~1~by~1~\\
*><*~~~~~~~until~items~>~depth~\\
*><*~~~~~~~~~~~display~\\
*><*~~~~~~~~~~~~~~"Item~"~items~":~"~luaitem(items)~\\
*><*~~~~~~~~~~~end-display~\\
*><*~~~end-perform~\\
*><*~\\
*><*~Lua~numbers~the~indexes~of~stacked~items~from~1,~first~\\
*><*~item~to~n,~last~item~(current~top~of~stack).~Negative~\\
*><*~indexes~may~also~be~used~as~documented~by~Lua,~-1~being~\\
*><*~top~of~stack.~\\
*><*~\\
*><*~Sample~output::~\\
*><*~\\
*><*~~~Item~1:~OpenCOBOL~1.1~\\
*><*~~~Item~2:~3.1415926535898~\\
*><*~~~Item~3:~Hello~OpenCOBOL~from~Lua~\\
*><*~~~Item~4:~3.1415926535898~\\
*><*~~~Item~5:~Hello~OpenCOBOL~from~Lua~\\
*><*~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~OCLUA{\_}POP~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~Pops~the~given~number~of~elements~off~of~the~Lua~stack~\\
*><*~returning~the~depth~of~the~stack~after~the~pop.~\\
*><*~\\
*><*~Example~that~empties~the~Lua~stack::~\\
*><*~\\
*><*~~~call~"OCLUA{\_}POP"~\\
*><*~~~~~~~using~\\
*><*~~~~~~~~~~~by~value~luastate~\\
*><*~~~~~~~~~~~by~value~depth~\\
*><*~~~~~~~returning~depth~\\
*><*~~~end-call~\\
*><*~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~OCLUA{\_}CLOSE~\\
*><*~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
*><*~Close~and~free~the~Lua~engine.~\\
*><*~\\
*><*~..~Danger::~\\
*><*~~~~Further~calls~to~Lua~are~unpredictable~and~may~well~\\
*><*~~~~lead~to~a~SIGSEGV~crash.~\\
*><*~\\
*><*~::~\\
*><*~\\
*><*~~~call~"OCLUA{\_}CLOSE"~using~by~value~luastate~end-call~\\
*><*
}\end{quote}
The above code use a wrapper layer of C code
\begin{quote}{\ttfamily \raggedright \noindent
/*~OpenCOBOL~Lua~interface~*/~\\
/*~tectonics:~cobc~-c~-I/usr/include/lua5.1~oclua.c~*/~\\
~\\
{\#}include~~\\
{\#}include~~\\
{\#}include~~\\
~\\
/*~Include~the~Lua~API~header~files.~*/~\\
{\#}include~~\\
{\#}include~~\\
{\#}include~~\\
~\\
/*~Open~the~Lua~engine~and~load~all~the~default~libraries~*/~\\
lua{\_}State~*OCLUA{\_}OPEN()~{\{}~\\
~~~~lua{\_}State~*oclua{\_}state;~\\
~~~~oclua{\_}state~=~lua{\_}open();~\\
~~~~luaL{\_}openlibs(oclua{\_}state);~\\
~~~~return~oclua{\_}state;~\\
{\}}~\\
~\\
int~OCLUA{\_}DO(lua{\_}State~*L,~int~which,~const~char~*string,~unsigned~char~*cobol,~int~coblen)~{\{}~\\
~~~~int~result;~\\
~~~~int~stacked;~\\
~~~~const~char~*retstr;~\\
~~~~int~retlen;~\\
~\\
~~~~memset(cobol,~'~',~coblen);~\\
~~~~result~=~((which~==~0)~?~luaL{\_}dostring(L,~string)~:~luaL{\_}dofile(L,~string));~\\
~~~~if~(result~==~1)~{\{}~\\
~~~~/*~error~condition~*/~\\
~~~~return~-1;~\\
~~~~{\}}~else~{\{}~\\
~~~~stacked~=~lua{\_}gettop(L);~\\
~~~~if~(stacked~>~0)~{\{}~\\
~~~~~~~~/*~populate~cobol~field~with~top~of~stack~*/~\\
~~~~~~~~retstr~=~lua{\_}tolstring(L,~stacked,~{\&}retlen);~\\
~~~~~~~~memcpy(cobol,~retstr,~(coblen~>~retlen)~?~retlen~:~coblen);~\\
~~~~{\}}~\\
~~~~/*~return~number~of~items~on~the~stack~*/~\\
~~~~return~stacked;~\\
~~~~{\}}~\\
{\}}~\\
~\\
/*~by~filename~*/~\\
int~OCLUA{\_}DOFILE(lua{\_}State~*L,~const~char~*filename,~unsigned~char~*cobol,~int~coblen)~{\{}~\\
~~~~return~OCLUA{\_}DO(L,~1,~filename,~cobol,~coblen);~\\
{\}}~\\
~\\
/*~by~string~*/~\\
int~OCLUA{\_}DOSTRING(lua{\_}State~*L,~const~char~*string,~unsigned~char~*cobol,~int~coblen)~{\{}~\\
~~~~return~OCLUA{\_}DO(L,~0,~string,~cobol,~coblen);~\\
{\}}~\\
~\\
/*~retrieve~stack~item~as~string~*/~\\
int~OCLUA{\_}GET(lua{\_}State~*L,~int~element,~unsigned~char~*cobol,~int~coblen)~{\{}~\\
~~~~const~char~*retstr;~\\
~~~~int~retlen;~\\
~\\
~~~~/*~populate~cobol~field~with~top~of~stack~*/~\\
~~~~memset(cobol,~'~',~coblen);~\\
~~~~retstr~=~lua{\_}tolstring(L,~element,~{\&}retlen);~\\
~~~~if~(retstr~==~NULL)~{\{}~\\
~~~~return~-1;~\\
~~~~{\}}~else~{\{}~\\
~~~~memcpy(cobol,~retstr,~(coblen~>~retlen)~?~retlen~:~coblen);~\\
~~~~return~retlen;~\\
~~~~{\}}~\\
{\}}~\\
~\\
/*~check~the~stack,~resize~if~needed,~returns~false~if~stack~can't~grow~*/~\\
int~OCLUA{\_}STACK(lua{\_}State~*L,~int~extra)~{\{}~\\
~~~~return~lua{\_}checkstack(L,~extra);~\\
{\}}~\\
~\\
/*~depth~of~Lua~stack~*/~\\
int~OCLUA{\_}DEPTH(lua{\_}State~*L)~{\{}~\\
~~~~return~lua{\_}gettop(L);~\\
{\}}~\\
~\\
/*~pop~elements~off~stack~*/~\\
int~OCLUA{\_}POP(lua{\_}State~*L,~int~elements)~{\{}~\\
~~~~lua{\_}pop(L,~elements);~\\
~~~~return~lua{\_}gettop(L);~\\
{\}}~\\
~\\
/*~close~the~engine~*/~\\
void~OCLUA{\_}CLOSE(lua{\_}State~*L)~{\{}~\\
~~~~lua{\_}close(L);~\\
{\}}~\\
~\\
/**/
}\end{quote}
and uses a sample Lua script
\begin{quote}{\ttfamily \raggedright \noindent
-{}-~Start~\\
-{}-~Script:~oclua.lua~\\
print("Lua~prints~hello")~\\
~\\
hello~=~"Hello~OpenCOBOL~from~Lua"~\\
return~math.pi,~hello~\\
-{}-~End
}\end{quote}
%___________________________________________________________________________
\hypertarget{can-opencobol-use-ecmascript}{}
\pdfbookmark[1]{5.12~~~Can OpenCOBOL use ECMAScript?}{can-opencobol-use-ecmascript}
\subsection*{5.12~~~Can OpenCOBOL use ECMAScript?}
\label{can-opencobol-use-ecmascript}
Yes. Using the \href{http://www.mozilla.org/js/spidermonkey/}{SpiderMonkey} engine.
See \href{\#can-opencobol-use-javascript}{Can OpenCOBOL use JavaScript?}
%___________________________________________________________________________
\hypertarget{can-opencobol-use-javascript}{}
\pdfbookmark[1]{5.13~~~Can OpenCOBOL use JavaScript?}{can-opencobol-use-javascript}
\subsection*{5.13~~~Can OpenCOBOL use JavaScript?}
\label{can-opencobol-use-javascript}
Yes. A wrapper for the \href{http://www.mozilla.org/js/spidermonkey/}{SpiderMonkey} engine allows OpenCOBOL access to
core JavaScript.
\begin{quote}{\ttfamily \raggedright \noindent
/*~OpenCOBOL~with~embedded~spidermonkey~javascript~*/~\\
/*~~~cobc~-c~-I/usr/include/smjs~ocjs.c~\\
~*~~~cobc~-x~-lsmjs~jscaller.cob~\\
~*~~~some~people~found~mozjs~before~smjs~\\
~*/~\\
{\#}include~~\\
{\#}include~~\\
~\\
/*~javascript~api~requires~an~environment~type~*/~\\
{\#}define~XP{\_}UNIX~\\
~\\
{\#}if~(defined(XP{\_}WIN)~||~defined(XP{\_}UNIX)~||~defined(XP{\_}BEOS)~||~defined(XP{\_}OS2))~\\
{\#}include~"jsapi.h"~\\
{\#}else~\\
{\#}error~"Must~define~one~of~XP{\_}BEOS,~XP{\_}OS2,~XP{\_}WIN~or~XP{\_}UNIX"~\\
{\#}endif~\\
~\\
/*~Error~codes~*/~\\
{\#}define~OCJS{\_}ERROR{\_}RUNTIME~~-1~\\
{\#}define~OCJS{\_}ERROR{\_}CONTEXT~~-2~\\
{\#}define~OCJS{\_}ERROR{\_}GLOBAL~~~-3~\\
{\#}define~OCJS{\_}ERROR{\_}STANDARD~-4~\\
{\#}define~OCJS{\_}ERROR{\_}EVALUATE~-5~\\
~\\
/*~OpenCOBOL~main~CALL~interface~*/~\\
/*~javascript~layer~requires~\\
~*~~~a~runtime~per~process,~\\
~*~~~a~context~per~thread,~\\
~*~~~a~global~object~per~context~\\
~*~and~will~initialize~\\
~*~~~standard~classes.~\\
~*/~\\
static~JSRuntime~*rt;~\\
static~JSContext~*cx;~\\
static~JSObject~*global;~\\
static~JSClass~global{\_}class~=~{\{}~\\
~~~~"global",0,~\\
~~~~JS{\_}PropertyStub,JS{\_}PropertyStub,JS{\_}PropertyStub,JS{\_}PropertyStub,~\\
~~~~JS{\_}EnumerateStub,JS{\_}ResolveStub,JS{\_}ConvertStub,JS{\_}FinalizeStub~\\
{\}};~\\
~\\
/*~Initialize~the~engine~resources~*/~\\
int~ocjsInitialize(int~rtsize,~int~cxsize)~{\{}~\\
~~~~JSBool~ok;~\\
~\\
~~~~/*~on~zero~sizes,~pick~reasonable~values~*/~\\
~~~~if~(rtsize~==~0)~{\{}~rtsize~=~0x100000;~{\}}~\\
~~~~if~(cxsize~==~0)~{\{}~cxsize~=~0x1000;~{\}}~\\
~\\
~~~~/*~Initialize~a~runtime~space~*/~\\
~~~~rt~=~JS{\_}NewRuntime(rtsize);~\\
~~~~if~(rt~==~NULL)~{\{}~return~OCJS{\_}ERROR{\_}RUNTIME;~{\}}~\\
~~~~/*~Attach~a~context~*/~\\
~~~~cx~=~JS{\_}NewContext(rt,~cxsize);~\\
~~~~if~(cx~==~NULL)~{\{}~return~OCJS{\_}ERROR{\_}CONTEXT;~{\}}~\\
~~~~/*~And~a~default~global~*/~\\
~~~~global~=~JS{\_}NewObject(cx,~{\&}global{\_}class,~NULL,~NULL);~\\
~~~~if~(global~==~NULL)~{\{}~return~OCJS{\_}ERROR{\_}GLOBAL;~{\}}~\\
~~~~/*~Load~standard~classes~*/~\\
~~~~ok~=~JS{\_}InitStandardClasses(cx,~global);~\\
~\\
~~~~/*~Return~success~or~standard~class~load~error~*/~\\
~~~~return~(ok~==~JS{\_}TRUE)~?~0~:~OCJS{\_}ERROR{\_}STANDARD;~\\
{\}}~\\
~\\
/*~Evaluate~script~*/~\\
int~ocjsEvaluate(char~*script,~char~*result,~int~length)~{\{}~\\
~~~~jsval~rval;~\\
~~~~JSString~*str;~\\
~~~~int~reslen~=~OCJS{\_}ERROR{\_}EVALUATE;~\\
~\\
~~~~JSBool~ok;~\\
~\\
~~~~/*~filename~and~line~number,~not~reported~*/~\\
~~~~char~*filename~=~NULL;~\\
~~~~int~lineno~=~0;~\\
~\\
~~~~/*~clear~the~result~field~*/~\\
~~~~memset(result,~'~',~length);~\\
~\\
~~~~/*~Evaluate~javascript~*/~\\
~~~~ok~=~JS{\_}EvaluateScript(cx,~global,~script,~strlen(script),~filename,~lineno,~{\&}rval);~\\
~\\
~~~~/*~Convert~js~result~to~JSString~form~*/~\\
~~~~if~(ok~==~JS{\_}TRUE)~{\{}~\\
~~~~~~~~str~=~JS{\_}ValueToString(cx,~rval);~\\
~~~~~~~~reslen~=~strlen(JS{\_}GetStringBytes(str));~\\
~~~~~~~~if~(length~<~reslen)~{\{}~reslen~=~length;~{\}}~\\
~~~~~~~~/*~convert~down~to~char~and~move~to~OpenCOBOl~result~field~*/~\\
~~~~~~~~memcpy(result,~JS{\_}GetStringBytes(str),~reslen);~\\
~~~~{\}}~\\
~~~~return~reslen;~\\
{\}}~\\
~\\
/*~Evaluate~script~from~file~*/~\\
int~ocjsFromFile(char~*filename,~char~*result,~int~length)~{\{}~\\
~~~~FILE~*fin;~\\
~~~~int~bufsize~=~10240;~\\
~~~~char~inbuf{[}bufsize{]};~\\
~~~~int~reslen;~\\
~\\
~~~~fin~=~fopen(filename,~"r");~\\
~~~~if~(fin~==~NULL)~{\{}~return~OCJS{\_}ERROR{\_}EVALUATE;~{\}}~\\
~~~~//while~(fread(inbuf,~sizeof(char),~bufsize,~fin)~>~0)~{\{}~\\
~~~~if~(fread(inbuf,~1,~bufsize,~fin)~>~0)~{\{}~\\
~~~~~~~~reslen~=~ocjsEvaluate(inbuf,~result,~length);~\\
~~~~{\}}~\\
~~~~return~reslen;~\\
{\}}~\\
~\\
/*~release~js~engine~*/~\\
int~ocjsRunDown()~{\{}~\\
~~~~if~(cx~!=~NULL)~{\{}~JS{\_}DestroyContext(cx);~{\}}~\\
~~~~if~(rt~!=~NULL)~{\{}~JS{\_}DestroyRuntime(rt);~{\}}~\\
~~~~JS{\_}ShutDown();~\\
~~~~return~0;~\\
{\}}~\\
~\\
/*~Quick~call;~start~engine,~evaluate,~release~engine~*/~\\
int~ocjsString(char~*script,~char~*result,~int~length)~{\{}~\\
~~~~int~reslen;~\\
~\\
~~~~reslen~=~ocjsInitialize(0,~0);~\\
~~~~if~(reslen~<~0)~{\{}~return~reslen;~{\}}~\\
~~~~reslen~=~ocjsEvaluate(script,~result,~length);~\\
~~~~ocjsRunDown();~\\
~~~~return~reslen;~\\
{\}}~\\
/**/
}\end{quote}
A sample OpenCOBOL application:
\begin{quote}{\ttfamily \raggedright \noindent
*>{}>SOURCE~FORMAT~IS~FIXED~\\
*>****************************************************************~\\
*>Author:~~~~Brian~Tiffin~\\
*>Date:~~~~~~11-Sep-2008~\\
*>Purpose:~~~Embed~some~javascript~\\
*>Tectonics:~cobc~-c~-I/usr/include/smjs~ocjs.c~\\
*>~~~~~~~~~~~cobc~-x~-l/smjs~jscaller.cob~ocjs.o~\\
*>****************************************************************~\\
~identification~division.~\\
~program-id.~jscaller.~\\
~\\
~data~division.~\\
~\\
~working-storage~section.~\\
~78~ocjs-error-runtime~~value~-1.~\\
~78~ocjs-error-context~~value~-2.~\\
~78~ocjs-error-global~~~value~-3.~\\
~78~ocjs-error-standard~value~-4.~\\
~78~ocjs-error-evaluate~value~-5.~\\
~\\
~78~newline~~~~~~~~~~~~~~value~x"0a".~\\
~01~source-data~~~~~~~~~~pic~x(40)~\\
~~~~~~value~"-{}-{}-{}-+-{}-{}-{}-1-{}-{}-{}-+-{\$}56.78~90-{}-{}-{}-3-{}-{}-{}-+-{}-{}-{}-4".~\\
~01~result~~~~~~~~~~~~~~~pic~s9(9).~\\
~01~result-field~~~~~~~~~pic~x(81).~\\
~\\
~01~javascript~~~~~~~~~~~pic~x(1024).~\\
~01~safety-null~~~~~~~~~~pic~x~value~x"00".~\\
~\\
*>****************************************************************~\\
*><*~Evaluate~spidermonkey~code,~return~the~length~of~js~result~\\
~procedure~division.~\\
~\\
~display~"js>~"~with~no~advancing~end-display~\\
~accept~javascript~end-accept~\\
~call~"ocjsString"~\\
~~~~~using~javascript~\\
~~~~~~~~~result-field~\\
~~~~~~~~~by~value~function~length(result-field)~\\
~~~~~returning~result~\\
~end-call~\\
~display~"OpenCOBOL~result-field:~"~result-field~end-display~\\
~display~"OpenCOBOL~recieved~~~~:~"~result~newline~end-display~\\
~\\
*><*~Initialize~the~javascript~engine~\\
~call~"ocjsInitialize"~\\
~~~~~using~by~value~65536~\\
~~~~~~~~~by~value~1024~\\
~~~~~returning~result~\\
~end-call~\\
~if~result~less~0~\\
~~~~~stop~run~returning~result~\\
~end-if~\\
~\\
*><*~find~(zero~offest)~dollar~amount,~space,~number~\\
~move~spaces~to~javascript~\\
~string~\\
~~~~~"pat~=~/{\textbackslash}{\$}{\textbackslash}d+{\textbackslash}.{\textbackslash}d+{\textbackslash}s{\textbackslash}d+/;~"~\\
~~~~~'a~=~"'~delimited~by~size~\\
~~~~~source-data~delimited~by~size~\\
~~~~~'";~'~delimited~by~size~\\
~~~~~"a.search(pat);~"~delimited~by~size~\\
~~~~~x"00"~delimited~by~size~\\
~~~~~into~javascript~\\
~end-string~\\
~\\
~display~\\
~~~~~"Script:~"~function~trim(javascript,~trailing)~\\
~end-display~\\
~\\
~call~"ocjsEvaluate"~\\
~~~~~using~javascript~\\
~~~~~~~~~result-field~\\
~~~~~~~~~by~value~function~length(result-field)~\\
~~~~~returning~result~\\
~end-call~\\
~display~"OpenCOBOL~result-field:~"~result-field~end-display~\\
~display~"OpenCOBOL~recieved~~~~:~"~result~newline~end-display~\\
~\\
*><*~values~held~in~js~engine~across~calls~\\
~move~spaces~to~javascript~\\
~string~\\
~~~~~'a;'~delimited~by~size~\\
~~~~~x"00"~delimited~by~size~\\
~~~~~into~javascript~\\
~end-string~\\
~\\
~display~\\
~~~~~"Script:~"~function~trim(javascript,~trailing)~\\
~end-display~\\
~\\
~call~"ocjsEvaluate"~\\
~~~~~using~javascript~\\
~~~~~~~~~result-field~\\
~~~~~~~~~by~value~function~length(result-field)~\\
~~~~~returning~result~\\
~end-call~\\
~display~"OpenCOBOL~result-field:~"~result-field~end-display~\\
~display~"OpenCOBOL~recieved~~~~:~"~result~newline~end-display~\\
~\\
*><*~erroneous~script~\\
~move~spaces~to~javascript~\\
~string~\\
~~~~~'an~error~of~some~kind;'~delimited~by~size~\\
~~~~~x"00"~delimited~by~size~\\
~~~~~into~javascript~\\
~end-string~\\
~\\
~display~\\
~~~~~"Script:~"~function~trim(javascript,~trailing)~\\
~end-display~\\
~\\
~call~"ocjsEvaluate"~\\
~~~~~using~javascript~\\
~~~~~~~~~result-field~\\
~~~~~~~~~by~value~function~length(result-field)~\\
~~~~~returning~result~\\
~end-call~\\
~if~result~equal~ocjs-error-evaluate~\\
~~~~~display~"~***~script~problem~***"~end-display~\\
~end-if~\\
~display~"OpenCOBOL~result-field:~"~result-field~end-display~\\
~display~"OpenCOBOL~recieved~~~~:~"~result~newline~end-display~\\
~\\
*><*~script~from~file~\\
~move~spaces~to~javascript~\\
~string~\\
~~~~~'ocjsscript.js'~delimited~by~size~\\
~~~~~x"00"~delimited~by~size~\\
~~~~~into~javascript~\\
~end-string~\\
~\\
~display~\\
~~~~~"Script:~"~function~trim(javascript,~trailing)~\\
~end-display~\\
~\\
~call~"ocjsFromFile"~\\
~~~~~using~javascript~\\
~~~~~~~~~result-field~\\
~~~~~~~~~by~value~function~length(result-field)~\\
~~~~~returning~result~\\
~end-call~\\
~if~result~equal~ocjs-error-evaluate~\\
~~~~~display~"~***~script~problem~***"~end-display~\\
~end-if~\\
~display~"OpenCOBOL~result-field:~"~result-field~end-display~\\
~display~"OpenCOBOL~recieved~~~~:~"~result~newline~end-display~\\
~\\
*><*~Rundown~the~js~engine~\\
~call~"ocjsRunDown"~returning~result~\\
~\\
*><*~take~first~name~last~name,~return~last~","~first~\\
~move~spaces~to~javascript~\\
~string~\\
~~~~~"re~=~/({\textbackslash}w+){\textbackslash}s({\textbackslash}w+)/;~"~delimited~by~size~\\
~~~~~'str~=~"John~Smith";~'~delimited~by~size~\\
~~~~~'newstr~=~str.replace(re,~"{\$}2,~{\$}1");~'~delimited~by~size~\\
~~~~~"newstr;"~delimited~by~size~\\
~~~~~x"00"~delimited~by~size~\\
~~~~~into~javascript~\\
~end-string~\\
~\\
~display~\\
~~~~~"Script:~"~function~trim(javascript,~trailing)~\\
~end-display~\\
~\\
~call~"ocjsString"~\\
~~~~~using~javascript~\\
~~~~~~~~~result-field~\\
~~~~~~~~~by~value~function~length(result-field)~\\
~~~~~returning~result~\\
~end-call~\\
~display~"OpenCOBOL~result-field:~"~result-field~end-display~\\
~display~"OpenCOBOL~recieved~~~~:~"~result~newline~end-display~\\
~\\
*><*~split~a~string~using~numbers~return~array~(as~js~string~form)~\\
~move~spaces~to~javascript~\\
~string~\\
~~~~~'myString~=~"Hello~1~word.~Sentence~number~2.";~'~\\
~~~~~~~~~delimited~by~size~\\
~~~~~'splits~=~myString.split(/({\textbackslash}d)/);~'~delimited~by~size~\\
~~~~~'splits;'~~delimited~by~size~\\
~~~~~x"00"~delimited~by~size~\\
~~~~~into~javascript~\\
~end-string~\\
~\\
~display~\\
~~~~~"Script:~"~function~trim(javascript,~trailing)~\\
~end-display~\\
~\\
~call~"ocjsString"~\\
~~~~~using~javascript~\\
~~~~~~~~~result-field~\\
~~~~~~~~~by~value~function~length(result-field)~\\
~~~~~returning~result~\\
~end-call~\\
~display~"OpenCOBOL~result-field:~"~result-field~end-display~\\
~display~"OpenCOBOL~recieved~~~~:~"~result~newline~end-display~\\
~\\
*><*~Get~javascript~date~\\
~move~"new~Date()"~{\&}~x"00"~to~javascript~\\
~\\
~display~\\
~~~~~"Script:~"~function~trim(javascript,~trailing)~\\
~end-display~\\
~\\
~call~"ocjsString"~\\
~~~~~using~javascript~\\
~~~~~~~~~result-field~\\
~~~~~~~~~by~value~function~length(result-field)~\\
~~~~~returning~result~\\
~end-call~\\
~display~"OpenCOBOL~result-field:~"~result-field~end-display~\\
~display~"OpenCOBOL~recieved~~~~:~"~result~end-display~\\
~\\
~goback.~\\
~end~program~jscaller.
}\end{quote}
And with a sample script:
\begin{center}\begin{sffamily}
\fbox{\parbox{\admonitionwidth}{
\textbf{\large Attention!}
\vspace{2mm}
Need something for ocjsscript.js in the public domain
that is only Core js
}}
\end{sffamily}
\end{center}
Sample output:
\begin{quote}{\ttfamily \raggedright \noindent
js>~123~*~456~+~789~\\
OpenCOBOL~result-field:~56877~\\
OpenCOBOL~recieved~~~~:~+000000005~\\
~\\
Script:~pat~=~/{\textbackslash}{\$}{\textbackslash}d+{\textbackslash}.{\textbackslash}d+{\textbackslash}s{\textbackslash}d+/;~a~=~"-{}-{}-{}-+-{}-{}-{}-1-{}-{}-{}-+-{\$}56.78~90-{}-{}-{}-3-{}-{}-{}-+-{}-{}-{}-4";~a.search(pat);~\\
OpenCOBOL~result-field:~16~\\
OpenCOBOL~recieved~~~~:~+000000002~\\
~\\
Script:~a;~\\
OpenCOBOL~result-field:~-{}-{}-{}-+-{}-{}-{}-1-{}-{}-{}-+-{\$}56.78~90-{}-{}-{}-3-{}-{}-{}-+-{}-{}-{}-4~\\
OpenCOBOL~recieved~~~~:~+000000040~\\
~\\
Script:~an~error~of~some~kind;~\\
~***~script~problem~***~\\
OpenCOBOL~result-field:~\\
OpenCOBOL~recieved~~~~:~-000000005~\\
~\\
Script:~re~=~/({\textbackslash}w+){\textbackslash}s({\textbackslash}w+)/;~str~=~"John~Smith";~newstr~=~str.replace(re,~"{\$}2,~{\$}1");~newstr;~\\
OpenCOBOL~result-field:~Smith,~John~\\
OpenCOBOL~recieved~~~~:~+000000011~\\
~\\
Script:~myString~=~"Hello~1~word.~Sentence~number~2.";~splits~=~myString.split(/({\textbackslash}d)/);~splits;~\\
OpenCOBOL~result-field:~Hello~,1,~word.~Sentence~number~,2,.~\\
OpenCOBOL~recieved~~~~:~+000000036~\\
~\\
Script:~new~Date()~\\
OpenCOBOL~result-field:~Mon~Sep~15~2008~04:16:06~GMT-0400~(EDT)~\\
OpenCOBOL~recieved~~~~:~+000000039
}\end{quote}
%___________________________________________________________________________
\hypertarget{can-opencobol-interface-with-scheme}{}
\pdfbookmark[1]{5.14~~~Can OpenCOBOL interface with Scheme?}{can-opencobol-interface-with-scheme}
\subsection*{5.14~~~Can OpenCOBOL interface with Scheme?}
\label{can-opencobol-interface-with-scheme}
Yes, directly embedded with \href{http://www.gnu.org/software/guile/guile.html}{Guile} and libguile.
callguile.cob
\begin{quote}{\ttfamily \raggedright \noindent
*>{}>SOURCE~FORMAT~IS~FIXED~\\
*>~***************************************************************~\\
*>~Author:~~~~Brian~Tiffin~\\
*>~Date:~~~~~~20090215~\\
*>~Purpose:~~~Demonstrate~libguile~Scheme~interactions~\\
*>~Tectonics:~cobc~-x~-lguile~callguile.cob~\\
*>~***************************************************************~\\
~identification~division.~\\
~program-id.~callguile.~\\
~\\
~data~division.~\\
~working-storage~section.~\\
~01~tax-scm~~~~~~~~~~~~~~usage~pointer.~\\
~01~shipping-scm~~~~~~~~~usage~pointer.~\\
~01~scm-string~~~~~~~~~~~usage~pointer.~\\
~01~radix-scm~~~~~~~~~~~~usage~pointer.~\\
~\\
~01~subtotal~~~~~~~~~~~~~pic~999v99~value~80.00.~\\
~01~subtotal-display~~~~~pic~z(8)9.99.~\\
~01~weight~~~~~~~~~~~~~~~pic~99v99~~value~10.00.~\\
~01~weight-display~~~~~~~pic~Z9.99.~\\
~01~breadth~~~~~~~~~~~~~~pic~99v99~~value~20.00.~\\
~01~breadth-display~~~~~~pic~Z9.99.~\\
~\\
~01~answer~~~~~~~~~~~~~~~pic~x(80).~\\
~01~len~~~~~~~~~~~~~~~~~~usage~binary-long.~\\
~\\
~01~tax~~~~~~~~~~~~~~~~~~pic~9(9)v9(2).~\\
~01~tax-display~~~~~~~~~~pic~z(8)9.9(2).~\\
~01~shipping~~~~~~~~~~~~~pic~9(9)v9(2).~\\
~01~shipping-display~~~~~pic~z(8)9.9(2).~\\
~01~invoice-total~~~~~~~~pic~9(9)v9(2).~\\
~01~invoice-display~~~~~~pic~{\$}(8)9.9(2).~\\
~\\
*>~***************************************************************~\\
~procedure~division.~\\
~\\
~display~"OC:~initialize~libguile"~end-display~\\
~call~"scm{\_}init{\_}guile"~end-call~\\
~\\
~display~"OC:~load~scheme~code"~end-display~\\
~call~"scm{\_}c{\_}primitive{\_}load"~using~"script.scm"~{\&}~x"00"~end-call~\\
~display~"OC:"~end-display~\\
~\\
~display~"OC:~evaluate~one~of~the~defined~functions"~end-display~\\
~call~"scm{\_}c{\_}eval{\_}string"~using~"(do-hello)"~{\&}~x"00"~end-call~\\
~display~"OC:"~end-display~\\
~\\
~display~"OC:~perform~tax~calculation"~end-display~\\
~move~subtotal~to~subtotal-display~\\
~move~weight~to~weight-display~\\
~move~breadth~to~breadth-display~\\
~call~"scm{\_}c{\_}eval{\_}string"~\\
~~~~~using~\\
~~~~~~~~~function~concatenate(~\\
~~~~~~~~~~~~~"(compute-tax~";~subtotal-display;~")";~x"00"~\\
~~~~~~~~~)~\\
~~~~~returning~tax-scm~\\
~end-call~\\
~\\
~display~"OC:~perform~shipping~calculation"~end-display~\\
~display~"OC:~"~function~concatenate(~\\
~~~~~~~~~~~~~~~~~~~~"(compute-shipping~";~weight-display;~"~";~\\
~~~~~~~~~~~~~~~~~~~~breadth-display;~")";~x"00"~\\
~~~~~~~~~~~~~~~~)~\\
~end-display~\\
~call~"scm{\_}c{\_}eval{\_}string"~\\
~~~~~using~\\
~~~~~~~~~function~concatenate(~\\
~~~~~~~~~~~~~"(compute-shipping~";~weight-display;~"~";~\\
~~~~~~~~~~~~~breadth-display;~")";~x"00"~\\
~~~~~~~~~)~\\
~~~~~returning~shipping-scm~\\
~end-call~\\
~\\
~display~"OC:~have~guile~build~a~scheme~integer~10"~end-display~\\
~call~"scm{\_}from{\_}int32"~\\
~~~~~using~by~value~size~is~4~10~returning~radix-scm~\\
~end-call~\\
~\\
~display~"OC:~have~guile~convert~number,~base~10"~end-display~\\
~call~"scm{\_}number{\_}to{\_}string"~\\
~~~~~using~\\
~~~~~~~~~by~value~tax-scm~by~value~radix-scm~\\
~~~~~returning~scm-string~\\
~end-call~\\
~\\
~display~"OC:~get~numeric~string~to~COBOL"~end-display~\\
~call~"scm{\_}to{\_}locale{\_}stringbuf"~\\
~~~~~using~\\
~~~~~~~~~by~value~scm-string~\\
~~~~~~~~~by~reference~answer~\\
~~~~~~~~~by~value~80~\\
~~~~~returning~len~\\
~end-call~\\
~display~"OC:~tax~as~string:~"~answer~end-display~\\
~move~answer~to~tax~\\
~\\
~call~"scm{\_}number{\_}to{\_}string"~\\
~~~~~using~\\
~~~~~~~~~by~value~shipping-scm~by~value~radix-scm~\\
~~~~~returning~scm-string~\\
~end-call~\\
~\\
~call~"scm{\_}to{\_}locale{\_}stringbuf"~\\
~~~~~using~\\
~~~~~~~~~by~value~scm-string~\\
~~~~~~~~~by~reference~answer~\\
~~~~~~~~~by~value~80~\\
~~~~~returning~len~\\
~end-call~\\
~display~"OC:~shipping~as~string:~"~answer~end-display~\\
~move~answer~to~shipping~\\
~\\
~compute~invoice-total~=~subtotal~+~tax~+~shipping~end-compute~\\
~\\
~move~subtotal~to~subtotal-display~\\
~move~tax~to~tax-display~\\
~move~shipping~to~shipping-display~\\
~move~invoice-total~to~invoice-display~\\
~display~"OC:"~end-display~\\
~display~"OC:~subtotal~~~"~subtotal-display~end-display~\\
~display~"OC:~tax~~~~~~~~"~tax-display~end-display~\\
~display~"OC:~shipping~~~"~shipping-display~end-display~\\
~display~"OC:~total:~~~~~"~invoice-display~end-display~\\
~goback.~\\
~end~program~callguile.
}\end{quote}
script.scm
\begin{quote}{\ttfamily \raggedright \noindent
(define~(do-hello)~\\
~~(begin~\\
~~~~(display~"Welcome~to~Guile")~\\
~~~~(newline)))~\\
~\\
(define~(compute-tax~subtotal)~\\
~~(*~subtotal~0.0875))~\\
~\\
~\\
(define~(compute-shipping~weight~length)~\\
~\\
~~;;~For~small,~light~packages,~charge~the~minimum~\\
~~(if~(and~(<~weight~20)~(<~length~5))~\\
~~~~~~0.95~\\
~\\
~~~~~~;;~Otherwise~for~long~packages,~charge~a~lot~\\
~~~~~~(if~(>~length~100)~\\
~~~~~~~~~~(+~0.95~(*~weight~0.1))~\\
~\\
~~~~~~~~~~;;~Otherwise,~charge~the~usual~\\
~~~~~~~~~~(+~0.95~(*~weight~0.05)))))~\\
~\\
(display~"Loaded~script.scm")(newline)
}\end{quote}
Outputs:
\begin{quote}{\ttfamily \raggedright \noindent
OC:~initialize~libguile~\\
OC:~load~scheme~code~\\
Loaded~script.scm~\\
OC:~\\
OC:~evaluate~one~of~the~defined~functions~\\
Welcome~to~Guile~\\
OC:~\\
OC:~perform~tax~calculation~\\
OC:~perform~shipping~calculation~\\
OC:~(compute-shipping~10.00~20.00)~\\
OC:~have~guile~build~a~scheme~integer~10~\\
OC:~have~guile~convert~number,~base~10~\\
OC:~get~numeric~string~to~COBOL~\\
OC:~tax~as~string:~7.0~\\
OC:~shipping~as~string:~1.45~\\
OC:~\\
OC:~subtotal~~~~~~~~~~80.00~\\
OC:~tax~~~~~~~~~~~~~~~~7.00~\\
OC:~shipping~~~~~~~~~~~1.45~\\
OC:~total:~~~~~~~~~~~{\$}88.45
}\end{quote}
Of course using Scheme for financial calculations in an OpenCOBOL
application would not be a smart usage. This is just a working
sample.
%___________________________________________________________________________
\hypertarget{can-opencobol-interface-with-tcl-tk}{}
\pdfbookmark[1]{5.15~~~Can OpenCOBOL interface with Tcl/Tk?}{can-opencobol-interface-with-tcl-tk}
\subsection*{5.15~~~Can OpenCOBOL interface with Tcl/Tk?}
\label{can-opencobol-interface-with-tcl-tk}
Yes. OpenCOBOL supports the Tcl/Tk embedding engine developed
by Rildo Pragna as part of the TinyCOBOL project. We have been
given permission by Rildo to embed his engine in OpenCOBOL.
%___________________________________________________________________________
\hypertarget{can-opencobol-interface-with-falcon-pl}{}
\pdfbookmark[1]{5.16~~~Can OpenCOBOL interface with Falcon PL?}{can-opencobol-interface-with-falcon-pl}
\subsection*{5.16~~~Can OpenCOBOL interface with Falcon PL?}
\label{can-opencobol-interface-with-falcon-pl}
Not yet, but work with Giancarlo to allow embedding of Falcon scripts
is in progress.
FalconPL has some nice features.
\begin{quote}{\ttfamily \raggedright \noindent
saying~=~List("Have",~"a",~"nice",~"day")~\\
~\\
for~elem~in~saying~\\
~~~>{}>~elem~\\
~~~formiddle:~>{}>~"~"~\\
~~~forlast:~>~"!"~\\
end
}\end{quote}
%___________________________________________________________________________
\hypertarget{can-opencobol-interface-with-ada}{}
\pdfbookmark[1]{5.17~~~Can OpenCOBOL interface with Ada?}{can-opencobol-interface-with-ada}
\subsection*{5.17~~~Can OpenCOBOL interface with Ada?}
\label{can-opencobol-interface-with-ada}
Yes. The freely available \textbf{gnat} system can be used and will create
object files that can be included in an OpenCOBOL project.
This example compiles an gnat package that includes \emph{hello} and \emph{ingress}
PROCEDURE and a \emph{echo} FUNCTION. These will be called from an OpenCOBOL
\textbf{adacaller.cob} program.
The gnat specification file
\begin{quote}{\ttfamily \raggedright \noindent
with~Interfaces.C;~\\
use~Interfaces.C;~\\
package~HelloAda~is~\\
~\\
~~~procedure~hello;~\\
~~~procedure~ingress(value~:~in~INTEGER);~\\
~~~function~echo(message~:~in~char{\_}array)~return~integer;~\\
~~~pragma~export(C,~hello);~\\
~~~pragma~export(C,~ingress);~\\
~~~pragma~export(C,~echo);~\\
~\\
end~HelloAda;
}\end{quote}
The gnat implementation body:
\begin{quote}{\ttfamily \raggedright \noindent
with~Ada.Text{\_}IO,~Ada.Integer{\_}Text{\_}IO,~Interfaces.C;~\\
use~~Ada.Text{\_}IO,~Ada.Integer{\_}Text{\_}IO,~Interfaces.C;~\\
package~body~HelloAda~is~\\
~\\
procedure~hello~is~\\
begin~\\
~~~Put{\_}Line("Hello~from~Ada~and~OpenCOBOL");~\\
~~~New{\_}Line;~\\
end~hello;~\\
~\\
procedure~ingress(value~:~in~integer)~is~\\
begin~\\
~~~Put{\_}Line("Passing~integer~to~Ada~from~OpenCOBOL");~\\
~~~Put("OpenCOBOL~passed:~");~\\
~~~Put(value);~\\
~~~New{\_}Line;~\\
~~~New{\_}Line;~\\
end~ingress;~\\
~\\
function~echo(message~:~in~char{\_}array)~return~integer~is~\\
begin~\\
~~~~Put(To{\_}Ada(message,~true));~\\
~~~~return~To{\_}Ada(message,~true)'length;~\\
end~echo;~\\
~\\
end~HelloAda;
}\end{quote}
The adacaller.cob source file
\begin{quote}{\ttfamily \raggedright \noindent
*******************~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{\textasciitilde}helloada.abd~\\
*~~~~~~~~~~~~cobc~-x~-lgnat~caller.cob~helloada.o~b{\textasciitilde}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.
}\end{quote}
And the tectonics; Debian GNU/Linux \emph{build.sh}
\begin{quote}{\ttfamily \raggedright \noindent
gnatgcc~-c~helloada.adb~\\
gnatbind~-n~helloada~\\
gnatgcc~-c~b{\textasciitilde}helloada.adb~\\
cobc~-x~-lgnat~adacaller.cob~helloada.o~b{\textasciitilde}helloada.o
}\end{quote}
An important step is the creation of the object file from the \emph{gnatbind}
output \emph{with -n} that is used in the final OpenCOBOL executable.
Sample run using ./adacaller:
\begin{quote}{\ttfamily \raggedright \noindent
Hello~from~Ada~and~OpenCOBOL~\\
~\\
Passing~integer~to~Ada~from~OpenCOBOL~\\
OpenCOBOL~passed:~~~~~~~~~~42~\\
~\\
Ada~echo~\\
Ada~return:~+000000009
}\end{quote}
%___________________________________________________________________________
\hypertarget{can-opencobol-interface-with-vala}{}
\pdfbookmark[1]{5.18~~~Can OpenCOBOL interface with Vala?}{can-opencobol-interface-with-vala}
\subsection*{5.18~~~Can OpenCOBOL interface with Vala?}
\label{can-opencobol-interface-with-vala}
Yes. Very easily. The Vala design philosophy of producing
C application binary interface code means that Vala is directly
usable with OpenCOBOL's \href{\#call}{CALL} statement.
See \href{http://live.gnome.org/Vala}{http://live.gnome.org/Vala} for some details on this emerging
programming enviroment.
This interface will be seeing more and more use as it really does open the door
to some very powerful extensions.
\begin{itemize}
\item {}
WebKit embedding
\item {}
PDF Viewers
\item {}
GTK
\item {}
Media streaming
\item {}
much more
\end{itemize}
%___________________________________________________________________________
\hypertarget{can-opencobol-interface-with-s-lang}{}
\pdfbookmark[1]{5.19~~~Can OpenCOBOL interface with S-Lang?}{can-opencobol-interface-with-s-lang}
\subsection*{5.19~~~Can OpenCOBOL interface with S-Lang?}
\label{can-opencobol-interface-with-s-lang}
Yes. The S-Lang engine can be used with OpenCOBOL for two purposes. Supporting
a very nice terminal and keyboard programmer interface S-Lang can be used to
scan the keyboard for non-waiting ACCEPT key routines. As a bonus, S-Lang has
a very nice scripting engine that allows easy and direct linkage of script
variables with OpenCOBOL defined storage members.
%___________________________________________________________________________
\hypertarget{setup}{}
\pdfbookmark[2]{5.19.1~~~Setup}{setup}
\subsubsection*{5.19.1~~~Setup}
\label{setup}
You will need the S-Lang library for this interface. Under \href{\#debian}{Debian} that is
simply
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~apt-get~install~libslang2
}\end{quote}
See \href{http://www.s-lang.org/}{http://www.s-lang.org/} for details of this very capable library.
%___________________________________________________________________________
\hypertarget{keyboard-control}{}
\pdfbookmark[2]{5.19.2~~~Keyboard control}{keyboard-control}
\subsubsection*{5.19.2~~~Keyboard control}
\label{keyboard-control}
This sample only show S-Lang terminal input. A very sophisticated
terminal output control interface is also available.
\begin{quote}{\ttfamily \raggedright \noindent
*>{}>SOURCE~FORMAT~IS~FIXED~\\
*>~***************************************************************~\\
*>~Author:~~~~Brian~Tiffin~\\
*>~Date:~~~~~~20090503~\\
*>~Purpose:~~~Experimental~S-Lang~interface~\\
*>~Tectonics:~cobc~-x~slangkey.cob~-lslang~\\
*>~***************************************************************~\\
~identification~division.~\\
~program-id.~slangkey.~\\
~\\
~data~division.~\\
~working-storage~section.~\\
~01~thekey~~~~~~~~~~~~~~~usage~binary-long~unsigned.~\\
~01~thekm~~~~~~~~~~~~~~~~usage~binary-long.~\\
~01~result~~~~~~~~~~~~~~~usage~binary-long.~\\
~\\
*>~exit~handler~address~and~priority~(prio~is~IGNORED~with~OC1.1)~\\
~01~install-flag~~~~~~~pic~9~comp-x~value~0.~\\
~01~~install-params.~\\
~~~~~02~exit-addr~~~~~~usage~is~procedure-pointer.~\\
~~~~~02~handler-prio~~~pic~999~comp-x.~\\
~\\
*>~***************************************************************~\\
~procedure~division.~\\
~\\
*>~Initialize~low~and~high~level~S-Lang~terminal~routines~\\
~call~"SLtt{\_}get{\_}terminfo"~end-call~\\
~call~"SLkp{\_}init"~returning~result~end-call~\\
~if~result~equal~-1~\\
~~~~~display~"problem~intializing~S-Lang~tty"~end-display~\\
~~~~~stop~run~giving~1~\\
~end-if~\\
~\\
~call~"SLang{\_}init{\_}tty"~using~\\
~~~~~by~value~-1~~~~~*>~abort~char~\\
~~~~~by~value~-1~~~~~*>~flow~ctrl~\\
~~~~~by~value~0~~~~~~*>~output~processing~\\
~~~returning~result~\\
~end-call~\\
~if~result~equal~-1~\\
~~~~~display~"problem~intializing~S-Lang~tty"~end-display~\\
~~~~~stop~run~giving~1~\\
~else~\\
~~~~~display~"Keyboard~in~special~mode"~x"0d"~end-display~\\
~end-if~\\
~\\
*>~install~an~exit~handler~to~put~terminal~back~\\
~set~exit-addr~to~entry~"tty-reset"~\\
~call~"CBL{\_}EXIT{\_}PROC"~using~\\
~~~~~install-flag~\\
~~~~~install-params~\\
~~~~~returning~result~\\
~end-call~\\
~if~result~not~equal~zero~\\
~~~~~display~"error~installing~exit~procedure"~end-display~\\
~end-if~\\
~\\
*>~Not~sure?~~Have~SLang~handle~{\textasciicircum}C~or~let~OpenCOBOL~take~over?~\\
~call~"SLang{\_}set{\_}abort{\_}signal"~using~by~value~0~end-call~\\
~\\
*>~The~demo.~~Fetch~a~key,~then~fetch~a~keycode.~~4~times.~\\
*>~~~SLang~terminals~display~newline~as~newline.~~Need~explicit~\\
*>~~~CR~to~get~a~carriage~return.~~Hence~the~x"0d".~\\
*>~~~Plus,~output~is~buffered~until~line~terminators.~\\
~display~\\
~~~~~"Tap~a~normal~key,~then~tap~a~'special'~key,~ie~F1,~4~times"~\\
~~~~~x"0d"~\\
~end-display~\\
~perform~4~times~\\
~~~~~call~"SLang{\_}getkey"~returning~thekey~end-call~\\
~~~~~display~thekey~space~with~no~advancing~end-display~\\
~~~~~call~"SLkp{\_}getkey"~returning~thekm~end-call~\\
~~~~~display~thekm~x"0d"~end-display~\\
~end-perform~\\
~\\
*>~Exit~handler~will~take~care~of~resetting~terminal~\\
~goback.~\\
~\\
~\\
*>~***************************************************************~\\
*>~Exit~procedure~to~ensure~terminal~properly~reset~\\
*>~***************************************************************~\\
~entry~"tty-reset".~\\
~call~"SLang{\_}reset{\_}tty"~end-call~\\
~display~"exit~proc~reset~the~tty"~end-display~\\
~goback.~\\
~\\
~end~program~slangkey.
}\end{quote}
Outputs:
\begin{quote}{\ttfamily \raggedright \noindent
Keyboard~in~special~mode~\\
Tap~a~normal~key,~then~tap~a~'special'~key,~ie~F1,~4~times~\\
0000000097~+0000000513~\\
0000000001~+0000000002~\\
0000000099~+0000065535~\\
0000000003~+0000000003~\\
exit~proc~reset~the~tty
}\end{quote}
having tapped, A, F1, Ctrl-A, Ctrl-B, C, EscEsc and Ctrl-C. The S-Lang abort
handler pretty much takes over the Ctrl-C handling in this sample so it looks
at though Ctrl-C was tapped twice, but it wasn't.
%___________________________________________________________________________
\hypertarget{scripting}{}
\pdfbookmark[2]{5.19.3~~~Scripting}{scripting}
\subsubsection*{5.19.3~~~Scripting}
\label{scripting}
S-Lang also provides a very comprehensive scripting language, which is
very easy to embed.
\begin{quote}{\ttfamily \raggedright \noindent
*>{}>SOURCE~FORMAT~IS~FIXED~\\
*>~***************************************************************~\\
*>~Author:~~~~Brian~Tiffin~\\
*>~Date:~~~~~~20090505~\\
*>~Purpose:~~~Experimental~S-Lang~interface~\\
*>~Tectonics:~cobc~-x~callslang.cob~-lslang~\\
*>~***************************************************************~\\
~identification~division.~\\
~program-id.~callslang.~\\
~\\
~data~division.~\\
~working-storage~section.~\\
~01~result~~~~~~~~~~~~~~~usage~binary-long.~\\
~01~cobol-integer~~~~~~~~usage~binary-long~value~42.~\\
~01~cobol-float~~~~~~~~~~usage~float-long~value~0.0.~\\
~01~sl-int-type~~~~~~~~~~constant~as~20.~\\
~01~sl-double-type~~~~~~~constant~as~27.~\\
~01~read-write~~~~~~~~~~~constant~as~0.~\\
~\\
*>~***************************************************************~\\
~procedure~division.~\\
~\\
*>~Initialize~S-Lang~\\
~call~"SLang{\_}init{\_}all"~returning~result~\\
~if~result~equal~-1~\\
~~~~~display~"Sorry,~problem~initializing~SLang"~end-display~\\
~end-if~\\
~\\
*>~Register~"slint"~variable~\\
~call~"SLadd{\_}intrinsic{\_}variable"~using~\\
~~~~~by~reference~"slint"~{\&}~x"00"~\\
~~~~~by~reference~cobol-integer~\\
~~~~~by~value~sl-int-type~\\
~~~~~by~value~read-write~\\
~~~~~returning~result~\\
~end-call~\\
~if~result~equal~-1~\\
~~~~~display~"Could~not~register~cobol-integer"~end-display~\\
~end-if~\\
~\\
*>~Register~"sldbl"~variable~\\
~call~"SLadd{\_}intrinsic{\_}variable"~using~\\
~~~~~by~reference~"sldbl"~{\&}~x"00"~\\
~~~~~by~reference~cobol-float~\\
~~~~~by~value~sl-double-type~\\
~~~~~by~value~read-write~\\
~~~~~returning~result~\\
~end-call~\\
~if~result~equal~-1~\\
~~~~~display~"Could~not~register~cobol-float"~end-display~\\
~end-if~\\
~\\
~call~"SLang{\_}load{\_}string"~using~\\
~~~~~"sldbl~=~sum({[}0,~1,~2,~3,~4,~5,~6,~7,~8,~9{]});"~{\&}~x"00"~\\
~~~~~returning~result~\\
~end-call~\\
~if~result~equal~-1~\\
~~~~~display~"Could~not~interpret~sum~intrinsic"~end-display~\\
~end-if~\\
~display~"S-Lang~set~cobol-float~to~"~cobol-float~end-display~\\
~\\
~display~"Next~lines~of~output~are~S-Lang~printf"~end-display~\\
~call~"SLang{\_}load{\_}string"~using~\\
~~~~~'()~=~printf("slint~(cobol-integer)~=~{\%}d{\textbackslash}n",~slint);'~{\&}~x"00"~\\
~~~~~returning~result~\\
~end-call~\\
~if~result~equal~-1~\\
~~~~~display~"Could~not~interpret~printf"~end-display~\\
~end-if~\\
~\\
~add~1~to~cobol-integer~\\
~\\
~call~"SLang{\_}load{\_}string"~using~\\
~~~~~'()~=~printf("slint~after~COBOL~add~=~{\%}d{\textbackslash}n",~slint);'~{\&}~x"00"~\\
~~~~~returning~result~\\
~end-call~\\
~if~result~equal~-1~\\
~~~~~display~"error~with~printf~after~cobol~add"~end-display~\\
~end-if~\\
~\\
*>~Let's~get~out~of~here~and~do~the~Dilbert~Nerd~Dance...Woohoo!~\\
~goback.~\\
~end~program~callslang.~\\
*><*
}\end{quote}
Which produces:
\begin{quote}{\ttfamily \raggedright \noindent
S-Lang~set~cobol-float~to~45.000000000000000000~\\
Next~lines~of~output~are~S-Lang~printf~\\
slint~(cobol-integer)~=~42~\\
slint~after~COBOL~add~=~43
}\end{quote}
%___________________________________________________________________________
\hypertarget{can-the-gnat-programming-studio-be-used-with-opencobol}{}
\pdfbookmark[1]{5.20~~~Can the GNAT Programming Studio be used with OpenCOBOL?}{can-the-gnat-programming-studio-be-used-with-opencobol}
\subsection*{5.20~~~Can the GNAT Programming Studio be used with OpenCOBOL?}
\label{can-the-gnat-programming-studio-be-used-with-opencobol}
Yes. Extensions to smooth the integration of OpenCOBOL development
in gnat-gps is posted at \href{http://svn.wp0.org/ocdocs/brian/opencobol.xml}{http://svn.wp0.org/ocdocs/brian/opencobol.xml}
\begin{quote}{\ttfamily \raggedright \noindent
~\\
~\\
~~~\\
~~~~OpenCOBOL~\\
~~~~.cob~\\
~~~~.cbl~\\
~~~~.cpy~\\
~\\
~~~~{\textasciicircum}(identification|id|environment|data|procedure|division|~\\
~~~~program-id|author|~\\
~~~~configuration|source-computer|object-computer|~\\
~~~~special-names|repository|~\\
~~~~input-output|file-control|io-control|~\\
~~~~file|working-storage|local-storage|linkage|~\\
~~~~communication|report|screen|~\\
~~~~section|declaratives|~\\
~~~~end|~\\
~~~~perform|end-perform|until|times|varying|~\\
~~~~add|subtract|multiply|divide|compute|~\\
~~~~end-add|end-subtract|end-multiply|end-divide|end-compute|~\\
~~~~accept|display|read|write|rewrite|sort|~\\
~~~~end-accept|end-display|end-read|end-write|end-rewrite|~\\
~~~~move|evaluate|end-evaluate|if|end-if|when|~\\
~~~~(un)?string|end-(un)?string|call|end-call|~\\
~~~~goback|stop{[}{\textbackslash}s{]}+run|~\\
~~~~filler|low-value{[}s{]}?|high-value{[}s{]}?|space{[}s{]}?|zero{[}es{]}?{[}s{]}?){\textbackslash}b~\\
~\\
~~~~~\\
~~~~~~{\textbackslash}*{\&}gt;|{[}~{]}{\{}6{\}}{\textbackslash}*~\\
~~~~~~{\&}quot;~\\
~~~~~~{\&}apos;~\\
~~~~~~True~\\
~~~~~~True~\\
~~~~~~False~\\
~~~~~\\
~\\
~~~~~\\
~~~~~~~\\
~~~~~~~~procedure~\\
~~~~~~~~{\textasciicircum}{[}0-9a-z{]}+{\textbackslash}.~\\
~~~~~~~~1~\\
~~~~~~~~subprogram{\_}xpm~\\
~~~~~~~\\
~~~~~\\
~~~\\
~\\
~~~\\
~~~~prog~\\
~~~~*{\&}gt;OC{\&}lt;*~\\
~~~~~~*{\&}gt;{\&}gt;SOURCE~FORMAT~IS~FIXED~\\
~~~~~~*{\&}gt;~***************************************************************~\\
~~~~~~*{\&}gt;~Author:~~~~Brian~Tiffin~\\
~~~~~~*{\&}gt;~Date:~~~~~~{\%}D~\\
~~~~~~*{\&}gt;~Purpose:~~~{\%}{\_}~\\
~~~~~~*{\&}gt;~Tectonics:~make~\\
~~~~~~*{\&}gt;~***************************************************************~\\
~~~~~~~identification~division.~\\
~~~~~~~program-id~{\%}(pid).~\\
~\\
~~~~~~~environment~division.~\\
~~~~~~~configuration~section.~\\
~~~~~~~repository.~\\
~~~~~~~special-names.~\\
~~~~~~~input-output~section.~\\
~\\
~~~~~~~data~division.~\\
~~~~~~~file~section.~\\
~~~~~~~working-storage~section.~\\
~~~~~~~local-storage~section.~\\
~~~~~~~linkage~section.~\\
~~~~~~~screen~section.~\\
~\\
~~~~~~~procedure~division.~\\
~~~~~~~declaratives.~\\
~~~~~~~end~declaratives.~\\
~\\
~~~~~~~00-main.~\\
~\\
~~~~~~~.~\\
~~~~~~~00-finish.~\\
~~~~~~~goback.~\\
~~~~~~*{\&}gt;~***************************************************************~\\
~\\
~~~~~~~end~program~{\%}(pid).~\\
~~~~~\\
~~~\\
~\\
~~~\\
~~~~Vala~\\
~~~~.vala~\\
~\\
~~~~{\textasciicircum}(bool|char|constpointer|double|float|size{\_}t|ssize{\_}t|string|unichar|void|~\\
~~~~int|int8|int16|int32|int64|long|short|~\\
~~~~uint|uint8|uint16|uint32|uint64|ulong|ushort|~\\
~~~~class|delegate|enum|errordomain|interface|namespace|struct|~\\
~~~~break|continue|do|for|foreach|return|while|~\\
~~~~else|if|switch|~\\
~~~~case|default|~\\
~~~~abstract|const|dynamic|ensures|extern|inline|internal|override|~\\
~~~~private|protected|public|requires|signal|static|virtual|volatile|weak|~\\
~~~~false|null|true|~\\
~~~~try|catch|finally|throw|~\\
~~~~as|base|construct|delete|get|in|is|lock|new|out|params|ref|~\\
~~~~sizeof|set|this|throws|typeof|using|value|var|yield|yields){\textbackslash}b~\\
~\\
~~~~~\\
~~~~~~//~\\
~~~~~~/*~\\
~~~~~~*/~\\
~~~~~~{\&}quot;~\\
~~~~~~{\&}apos;~\\
~~~~~~True~\\
~~~~~~True~\\
~~~~~~True~\\
~~~~~\\
~\\
~~~~~\\
~~~~~~~\\
~~~~~~~~procedure~\\
~~~~~~~~{\textasciicircum}{[}0-9a-z{]}+{\textbackslash}.~\\
~~~~~~~~1~\\
~~~~~~~~subprogram{\_}xpm~\\
~~~~~~~\\
~~~~~\\
~~~\\
~\\
~~~\\
~~~~OpenCOBOL~\\
~~~~-m~\\
~~~~~~~\\
~~~~~~~~~Code~generation~\\
~~~~~~~~~Run-time~options~\\
~~~~~~~~~Source~forms~and~Warnings~\\
~~~~~~~~~~\\
~~~~~~~~~Debugging~\\
~~~~~~~~~Syntax~\\
~\\
~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~\\
~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~\\
~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~\\
~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~~~~\\
~~~~~~~~~~\\
~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~~~~\\
~~~~~~~\\
~~~\\
~\\
~~~\\
~~~~make~\\
~~~\\
~\\
~~~\\
~~~~cobc~-x~{\%}f~\\
~~~\\
~\\
~~~\\
~~~~cobcrun~{\%}p~\\
~~~\\
~\\
~~~\\
~~~~valac~-{}-pkg~gtk+-2.0~{\%}f~\\
~~~\\
~\\
~~~\\
~~~~konsole~-{}-vt{\_}sz~132x24~-e~gdb~./{\%}p~\\
~~~\\
~\\
~~~\\
~~~~konsole~-{}-vt{\_}sz~132x24~-e~cgdb~./{\%}p~\\
~~~\\
~\\
~~~\\
~~~~MDI.input{\_}dialog~"Enter~command~arguments"~"Args"~\\
~~~~konsole~-{}-vt{\_}sz~132x24~-e~cgdb~-{}-args~./{\%}p~{\%}1~\\
~~~\\
~\\
~~~\\
~~~~konsole~-{}-vt{\_}sz~132x24~-e~gdbtui~-{}-args~./{\%}p~{\%}1~\\
~~~\\
~\\
~~~\\
~~~~MDI.input{\_}dialog~"Enter~command~arguments"~"Args"~\\
~~~~konsole~-{}-vt{\_}sz~132x24~-e~gdbtui~-{}-args~./{\%}p~{\%}1~\\
~~~\\
~\\
~~~\\
~~~~ddd~./{\%}p~\\
~~~\\
~\\
~~~\\
~~~~OpenCOBOL~\\
~~~~~\\
~~~~~\\
~~~~~\\
~~~~~\\
~~~~~\\
~~~~~\\
~~~~~\\
~~~~~\\
~~~~~\\
~~~~~\\
~~~~~\\
~~~\\
}\end{quote}
%___________________________________________________________________________
\hypertarget{does-opencobol-support-screen-section}{}
\pdfbookmark[1]{5.21~~~Does OpenCOBOL support SCREEN SECTION?}{does-opencobol-support-screen-section}
\subsection*{5.21~~~Does OpenCOBOL support SCREEN SECTION?}
\label{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
\emph{Screen description entry} of the COBOL 20xx Draft standard.
External variables that influence screen handling include
\begin{description}
\item[{COB{\_}SCREEN{\_}EXCEPTIONS=Y}] \leavevmode
To enable exceptions during ACCEPT.
\item[{COB{\_}SCREEN{\_}ESC=Y}] \leavevmode
To enable handling of the escape key.
\end{description}
See \href{\#does-opencobol-support-crt-status}{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.
%___________________________________________________________________________
\hypertarget{what-are-the-opencobol-screen-section-colour-values}{}
\pdfbookmark[1]{5.22~~~What are the OpenCOBOL SCREEN SECTION colour values?}{what-are-the-opencobol-screen-section-colour-values}
\subsection*{5.22~~~What are the OpenCOBOL SCREEN SECTION colour values?}
\label{what-are-the-opencobol-screen-section-colour-values}
The FOREGROUND-COLOR and BACKGROUND-COLOR clauses will accept
\begin{quote}{\ttfamily \raggedright \noindent
78~~black~~~~~~~~~~~~~~~~~~~~~~~value~0.~\\
78~~blue~~~~~~~~~~~~~~~~~~~~~~~~value~1.~\\
78~~green~~~~~~~~~~~~~~~~~~~~~~~value~2.~\\
78~~cyan~~~~~~~~~~~~~~~~~~~~~~~~value~3.~\\
78~~red~~~~~~~~~~~~~~~~~~~~~~~~~value~4.~\\
78~~magenta~~~~~~~~~~~~~~~~~~~~~value~5.~\\
78~~brown~~~~~~~~~~~~~~~~~~~~~~~value~6.~\\
78~~white~~~~~~~~~~~~~~~~~~~~~~~value~7.
}\end{quote}
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.
%___________________________________________________________________________
\hypertarget{does-opencobol-support-crt-status}{}
\pdfbookmark[1]{5.23~~~Does OpenCOBOL support CRT STATUS?}{does-opencobol-support-crt-status}
\subsection*{5.23~~~Does OpenCOBOL support CRT STATUS?}
\label{does-opencobol-support-crt-status}
Yes.
\begin{quote}{\ttfamily \raggedright \noindent
ENVIRONMENT~DIVISION.~\\
CONFIGURATION~SECTION.~\\
SPECIAL-NAMES.~\\
~~~~CRT~STATUS~IS~screen-status.~\\
~\\
DATA~DIVISION.~\\
WORKING-STORAGE~SECTION.~\\
COPY~screenio.~\\
01~screen-status~pic~9(4).~\\
~\\
PROCEDURE~DIVISION.~\\
ACCEPT~screen-sample.~\\
IF~screen-status~=~COB-SCR-F1~\\
~~~~...
}\end{quote}
There is also a special OpenCOBOL variable, \textbf{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:
\begin{itemize}
\item {}
COB-SCR-F1 thru
\item {}
COB-SCR-F64
\item {}
COB-SCR-ESC
\end{itemize}
examine the file to see the other values.
%___________________________________________________________________________
\hypertarget{what-is-cobcurses}{}
\pdfbookmark[1]{5.24~~~What is CobCurses?}{what-is-cobcurses}
\subsection*{5.24~~~What is CobCurses?}
\label{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 \href{http://sourceforge.net/projects/cobcurses}{http://sourceforge.net/projects/cobcurses} for full details. This is a
major piece of work by Warren Gay, ve3wwg.
From an \href{http://opencobol.org/}{opencobol.org} posting by Warren announcing release 0.95:
\begin{quote}{\ttfamily \raggedright \noindent
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~{\textasciicircum}O).~\\
~\\
2.~To~support~menus,~FUNCTION~keys~are~now~available~in~\\
~Action~mode~(though~CONTROL-O~is~an~alternate~way~\\
~of~opening~a~menu).~This~included~a~new~event~\\
~callback~NC-FKEY-EVENT.~\\
~\\
3.~GRAPHIC~characters~in~the~screen~background.~It~is~now~\\
~possible~using~sdesign~to~draw~alternate-charset~\\
~graphics~in~your~screen~background.~See~the~notes~in~\\
~the~opening~help~screen~for~the~"Paint"~function.~\\
~\\
4.~TRACE~facilities.~CobCurses~now~includes~an~\\
~environment~variable~that~can~enable~capturing~of~\\
~trace~information~to~a~file~for~debugging.~A~routine~\\
~named~NC{\_}TRACE{\_}MSG~can~also~be~used~to~add~custom~\\
~messages~to~the~trace~file.~\\
~\\
INTERNAL~CHANGES:~\\
~\\
The~main~two~major~internal~changes~were:~\\
~\\
1.~The~terminal~support~has~been~virtualized,~so~that~\\
~the~CobCurses~routines~deal~with~a~"terminal"~\\
~object~(not~curses~routines).~This~will~eventually~\\
~lead~to~other~possible~windowing~interfaces~like~\\
~perhaps~graphic~X~Window~or~native~Windows~support.~\\
~\\
~The~other~motivation~for~this~was~to~allow~CobCurses~\\
~to~have~one~consistent~set~of~constants~for~colours,~\\
~attributes~and~character~sets.~Previously,~these~\\
~values~were~different~depending~upon~the~platform~\\
~and~implementation~of~curses~used.~\\
~\\
2.~Menu~support~has~been~provided~independently~of~curses.~\\
~This~is~important~for~portability~since~PDCurses~and~\\
~some~platforms~do~not~provide~a~curses~menu~library.~\\
~This~also~guarantees~that~CobCurses~menus~will~behave~\\
~consistently~on~all~platforms~(and~overcome~menu~paging~\\
~bugs~in~ncurses).~\\
~\\
PLANNED~FOR~THE~NEXT~RELEASE:~\\
~\\
Please~avoid~writing~much~code~that~works~with~colour~pairs.~\\
In~the~next~release,~it~is~planned~to~hide~the~colour~pair~\\
value~altogether~by~using~a~TDC~(Terminal~Drawing~Context).~\\
This~TDC~will~tie~together~attributes~and~colours,~and~\\
perhaps~other~"drawing~contexts"~so~that~you~won't~have~to~\\
manage~colour~pairs~(this~will~be~transparent).~This~will~\\
also~pave~the~way~for~graphical~interfaces~where~a~selected~\\
font~and~line~styles~etc.~may~also~be~supported.~\\
~\\
NOTES:~\\
~\\
HPUX~users~will~need~to~link~with~ncurses,~\\
instead~of~the~native~HPUX~curses~libraries.~I~didn't~\\
have~time~to~fully~investigate~this,~but~the~native~\\
include~files~define~things~like~MENU~and~ITEM~types~\\
that~conflict~with~the~CobCurses~defined~ones.~\\
~\\
====~\\
~\\
The~release~is~available~for~download~here:~\\
~\\
http://sourceforge.net/projects/cobcurses
}\end{quote}
%___________________________________________________________________________
\hypertarget{what-is-cobxref}{}
\pdfbookmark[1]{5.25~~~What is CobXRef?}{what-is-cobxref}
\subsection*{5.25~~~What is CobXRef?}
\label{what-is-cobxref}
CobXRef is a COBOL cross-referencing utility written by
Vincent Coen and ported to OpenCOBOL 1.1.
Current source code is available at \href{http://svn.wp0.org/add1/tools/cobxref}{http://svn.wp0.org/add1/tools/cobxref}
or \href{http://sourceforge.net/projects/cobxref/}{http://sourceforge.net/projects/cobxref/} and is currently \emph{(February 2009)} in active
development.
The system ships with full documentation and information for building
from source is included in the \emph{readme} file.
Fetching the utility
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~svn~checkout~http://svn.wp0.org/add1/tools/cobxref
}\end{quote}
Example \textbf{truncated} to 72 and using the ocdoc.cob OpenCOBOL program
for source code:
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~cobc~-save-temps~ocdoc.cob~\\
{\$}~cobxref~ocdoc.i~-L~\\
{\$}~cut~-c1-72~ocdoc.lst~\\
~\\
ACS~Cobol~Cross~Reference~Xref~v0.95.27~(04/01/2009@11:27)~Dictionary~Fi~\\
~\\
Symbols~of~Module:~ocdoc~(ocdoc)~\\
-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~\\
Data~Section~(FILE)~~~~~~~~~~~~~~~Defn~~~~Locations~\\
-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-+-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~\\
doc-output~~~~~~~~~~~~~~~~~~~~~~~000124F~~000252~000499~\\
doc-record~~~~~~~~~~~~~~~~~~~~~~~000125F~~000269~000381~000387~000390~00~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~000478~000482~000485~\\
source-input~~~~~~~~~~~~~~~~~~~~~000122F~~000251~000287~000458~000500~\\
source-record~~~~~~~~~~~~~~~~~~~~000123F~~000285~000288~000300~000316~00~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~000324~000355~000456~000459~\\
standard-input~~~~~~~~~~~~~~~~~~~000117F~~000256~000282~000453~000497~\\
standard-output~~~~~~~~~~~~~~~~~~000119F~~000257~000496~\\
stdin-record~~~~~~~~~~~~~~~~~~~~~000118F~~000283~000285~000454~000456~\\
stdout-record~~~~~~~~~~~~~~~~~~~~000120F~~000387~000388~000475~000476~\\
~\\
ACS~Cobol~Cross~Reference~Xref~v0.95.27~(04/01/2009@11:27)~Dictionary~Fi~\\
~\\
Symbols~of~Module:~ocdoc~(ocdoc)~\\
-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~\\
Data~Section~(WORKING-STORAGE)~~~~Defn~~~~Locations~\\
-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-+-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~\\
arguments~~~~~~~~~~~~~~~~~~~~~~~~000128W~~000219~000221~000244~000245~\\
autoappend~~~~~~~~~~~~~~~~~~~~~~~000187W~~000380~\\
autodoc~~~~~~~~~~~~~~~~~~~~~~~~~~000186W~~000385~\\
buffer-empty~~~~~~~~~~~~~~~~~~~~~000178W~~000267~000380~000398~000472~\\
buffer-flag~~~~~~~~~~~~~~~~~~~~~~000177W~\\
buffer-offset~~~~~~~~~~~~~~~~~~~~000176W~~000268~000382~000399~000433~00~\\
buffered-output~~~~~~~~~~~~~~~~~~000179W~~000385~000441~000471~\\
counter~~~~~~~~~~~~~~~~~~~~~~~~~~000181W~~000369~000410~000412~000416~\\
data-field1~~~~~~~~~~~~~~~~~~~~~~000193W~\\
data-field2~~~~~~~~~~~~~~~~~~~~~~000194W~\\
data-field3~~~~~~~~~~~~~~~~~~~~~~000197W~\\
data-record~~~~~~~~~~~~~~~~~~~~~~000192W~\\
data-subfield1~~~~~~~~~~~~~~~~~~~000195W~\\
data-subfield2~~~~~~~~~~~~~~~~~~~000196W~~000218~\\
doc-buffer~~~~~~~~~~~~~~~~~~~~~~~000175W~~000417~000419~000430~\\
doc-name~~~~~~~~~~~~~~~~~~~~~~~~~000130W~~000246~000505~000522~000532~\\
filter-flag~~~~~~~~~~~~~~~~~~~~~~000138W~\\
filtering~~~~~~~~~~~~~~~~~~~~~~~~000139W~~000254~000281~000386~000452~00~\\
first-part~~~~~~~~~~~~~~~~~~~~~~~000184W~~000368~\\
helping~~~~~~~~~~~~~~~~~~~~~~~~~~000137W~~000222~\\
here-data~~~~~~~~~~~~~~~~~~~~~~~~000169W~~000355~\\
here-record~~~~~~~~~~~~~~~~~~~~~~000167W~~000356~\\
heredoc~~~~~~~~~~~~~~~~~~~~~~~~~~000156W~~000315~000337~000354~\\
hereend~~~~~~~~~~~~~~~~~~~~~~~~~~000153W~~000340~000353~\\
hereflag~~~~~~~~~~~~~~~~~~~~~~~~~000155W~\\
herenone~~~~~~~~~~~~~~~~~~~~~~~~~000157W~~000341~\\
herestart~~~~~~~~~~~~~~~~~~~~~~~~000152W~~000336~000353~\\
len-of-comment~~~~~~~~~~~~~~~~~~~000182W~~000411~000415~000416~\\
line-count~~~~~~~~~~~~~~~~~~~~~~~000141W~~000270~000301~000435~\\
line-display~~~~~~~~~~~~~~~~~~~~~000142W~~000435~000438~\\
result~~~~~~~~~~~~~~~~~~~~~~~~~~~000190W~~000548~000551~000552~\\
result-name~~~~~~~~~~~~~~~~~~~~~~000131W~~000247~000518~000524~000534~\\
rst-command~~~~~~~~~~~~~~~~~~~~~~000189W~~000517~000525~000535~000542~00~\\
seq-data~~~~~~~~~~~~~~~~~~~~~~~~~000173W~~000317~\\
seq-record~~~~~~~~~~~~~~~~~~~~~~~000171W~~000318~\\
skipseqnum~~~~~~~~~~~~~~~~~~~~~~~000135W~~000314~\\
source-name~~~~~~~~~~~~~~~~~~~~~~000129W~~000246~000504~\\
special~~~~~~~~~~~~~~~~~~~~~~~~~~000185W~~000379~\\
style-name~~~~~~~~~~~~~~~~~~~~~~~000132W~~000247~000519~000530~\\
trimmed~~~~~~~~~~~~~~~~~~~~~~~~~~000151W~~000316~000321~000324~000356~00~\\
usagehelp~~~~~~~~~~~~~~~~~~~~~~~~000136W~~000221~\\
verbose~~~~~~~~~~~~~~~~~~~~~~~~~~000134W~~000392~000480~000503~000539~\\
verbosity~~~~~~~~~~~~~~~~~~~~~~~~000133W~~000248~\\
~\\
ACS~Cobol~Cross~Reference~Xref~v0.95.27~(04/01/2009@11:27)~Dictionary~Fi~\\
~\\
Variable~Tested~{[}S{]}~~~~~~~~~~~~Symbol~(88-Conditions)~\\
-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~\\
buffer-flag~~~~~~~~~~~~~~~~~~~~buffer-empty~\\
buffer-flag~~~~~~~~~~~~~~~~~~~~buffered-output~\\
filter-flag~~~~~~~~~~~~~~~~~~~~filtering~\\
first-part~~~~~~~~~~~~~~~~~~~~~special~\\
first-part~~~~~~~~~~~~~~~~~~~~~autodoc~\\
first-part~~~~~~~~~~~~~~~~~~~~~autoappend~\\
hereflag~~~~~~~~~~~~~~~~~~~~~~~heredoc~\\
hereflag~~~~~~~~~~~~~~~~~~~~~~~herenone~\\
trimmed~~~~~~~~~~~~~~~~~~~~~~~~herestart~\\
trimmed~~~~~~~~~~~~~~~~~~~~~~~~hereend~\\
usagehelp~~~~~~~~~~~~~~~~~~~~~~helping~\\
verbosity~~~~~~~~~~~~~~~~~~~~~~verbose~\\
verbosity~~~~~~~~~~~~~~~~~~~~~~skipseqnum~\\
~\\
ACS~Cobol~Cross~Reference~Xref~v0.95.27~(04/01/2009@11:27)~Dictionary~Fi~\\
~\\
Variable~Tested~~~~~~~~~~~~~~~~Symbol~(88-Conditions)~{[}S{]}~\\
-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~\\
first-part~~~~~~~~~~~~~~~~~~~~~autoappend~\\
first-part~~~~~~~~~~~~~~~~~~~~~autodoc~\\
buffer-flag~~~~~~~~~~~~~~~~~~~~buffer-empty~\\
buffer-flag~~~~~~~~~~~~~~~~~~~~buffered-output~\\
filter-flag~~~~~~~~~~~~~~~~~~~~filtering~\\
usagehelp~~~~~~~~~~~~~~~~~~~~~~helping~\\
hereflag~~~~~~~~~~~~~~~~~~~~~~~heredoc~\\
trimmed~~~~~~~~~~~~~~~~~~~~~~~~hereend~\\
hereflag~~~~~~~~~~~~~~~~~~~~~~~herenone~\\
trimmed~~~~~~~~~~~~~~~~~~~~~~~~herestart~\\
verbosity~~~~~~~~~~~~~~~~~~~~~~skipseqnum~\\
first-part~~~~~~~~~~~~~~~~~~~~~special~\\
verbosity~~~~~~~~~~~~~~~~~~~~~~verbose~\\
~\\
ACS~Cobol~Cross~Reference~Xref~v0.95.27~(04/01/2009@11:27)~Dictionary~Fi~\\
~\\
Procedure~~~~~~~~~~~~~~~~~~~~~~~~~Defn~~~~Locations~\\
-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-+-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~\\
~\\
trim~~~~~~~~~~~~~~~~~~~~~~~~~~~~~000324P~~000394~000430~000482~000504~00~\\
~\\
ACS~Cobol~Cross~Reference~Xref~v0.95.27~(04/01/2009@11:27)~Dictionary~Fi~\\
~\\
Unreferenced~Working~Storage~Symbols~\\
~\\
buffer-flag~~~~~~~~~~~~~~~~~~~~~~000177W~\\
data-field1~~~~~~~~~~~~~~~~~~~~~~000193W~\\
data-field2~~~~~~~~~~~~~~~~~~~~~~000194W~\\
data-field3~~~~~~~~~~~~~~~~~~~~~~000197W~\\
data-record~~~~~~~~~~~~~~~~~~~~~~000192W~\\
data-subfield1~~~~~~~~~~~~~~~~~~~000195W~\\
filter-flag~~~~~~~~~~~~~~~~~~~~~~000138W~\\
hereflag~~~~~~~~~~~~~~~~~~~~~~~~~000155W~\\
~\\
ACS~Cobol~Cross~Reference~Xref~v0.95.27~(04/01/2009@11:27)~Dictionary~Fi~\\
~\\
Unreferenced~Procedures~\\
~\\
None
}\end{quote}
\emph{CobXRef produces 132 column output by default and the commands used
here limit the width to 72 characters in order to fit the FAQ file.}
%___________________________________________________________________________
\hypertarget{does-opencobol-implement-report-writer}{}
\pdfbookmark[1]{5.26~~~Does OpenCOBOL implement Report Writer?}{does-opencobol-implement-report-writer}
\subsection*{5.26~~~Does OpenCOBOL implement Report Writer?}
\label{does-opencobol-implement-report-writer}
Not at this time. \emph{July, 2008}
But it does support LINAGE. See \href{\#does-opencobol-implement-linage}{Does OpenCOBOL implement LINAGE?}
%___________________________________________________________________________
\hypertarget{does-opencobol-implement-linage}{}
\pdfbookmark[1]{5.27~~~Does OpenCOBOL implement LINAGE?}{does-opencobol-implement-linage}
\subsection*{5.27~~~Does OpenCOBOL implement LINAGE?}
\label{does-opencobol-implement-linage}
Yes. LINAGE sets up logical pages inside file descriptors enhancing
the WRITE operations and enabling the END-OF-PAGE clause.
\begin{quote}{\ttfamily \raggedright \noindent
FILE~SECTION.~\\
FD~~A-REPORT~\\
~~~~LINAGE~IS~13~LINES~\\
~~~~TOP~2~\\
~~~~FOOTING~2~\\
~~~~BOTTOM~3.
}\end{quote}
LINAGE clauses can set:
\begin{quote}{\ttfamily \raggedright \noindent
TOP~\\
LINES~\\
FOOTING~\\
BOTTOM
}\end{quote}
The \href{\#linage-counter}{LINAGE-COUNTER} noun is maintained during writes to LINAGE output files.
See \href{\#linage}{LINAGE} for a sample program.
%___________________________________________________________________________
\hypertarget{can-i-use-ctags-with-opencobol}{}
\pdfbookmark[1]{5.28~~~Can I use ctags with OpenCOBOL?}{can-i-use-ctags-with-opencobol}
\subsection*{5.28~~~Can I use ctags with OpenCOBOL?}
\label{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 \textbf{emacs}, \textbf{vi}, \textbf{nedit} and
other editors that support the ctags format. \emph{ctags, by default, only
supports the competition, C and Fortran.}
After running ctags program.cob
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~vi~-t~WORKING-STORAGE
}\end{quote}
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 \emph{first} file with an
occurrence of WORKING-STORAGE found in the tags.
%___________________________________________________________________________
\hypertarget{what-about-debugging-opencobol-programs}{}
\pdfbookmark[1]{5.29~~~What about debugging OpenCOBOL programs?}{what-about-debugging-opencobol-programs}
\subsection*{5.29~~~What about debugging OpenCOBOL programs?}
\label{what-about-debugging-opencobol-programs}
OpenCOBOL internal runtime checks are enabled with \textbf{-debug}.
Support for tracing is enabled with \textbf{-ftrace} and \textbf{-ftraceall}.
Source line location is enabled with \textbf{-fsource-location}, and implied
with the \textbf{-g} and \textbf{-debug} options..
Activation of FIXED format \textbf{D} indicator debug lines is enabled with
\textbf{-fdebugging-line}. In FREE format, \textbf{{\textgreater}{\textgreater}D} can be used anywhere on
a line. See \href{\#does-opencobol-support-d-indicator-debug-lines}{Does OpenCOBOL support D indicator debug lines?}.
\textbf{-fstack-check} will perform stack checking when \textbf{-debug} or \textbf{-g} is
used.
\textbf{-fsyntax-only} will ask the compiler to only check for syntax errors,
and not emit any output.
To view the intermediate files that are generated, using \textbf{-C} will
produce the .c source files and any .c.l.h and c.h header files.
\textbf{-save-temps{[}=dir{]}} will leave all intermediate files in the current
directory or the optional directory specified, including .i files that
are the COBOL sources after COPY processing.
Support for \href{\#gdb}{gdb} is enabled with \textbf{-g}.
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~gdb~hello~\\
GNU~gdb~6.7.1-debian~\\
Copyright~(C)~2007~Free~Software~Foundation,~Inc.~\\
License~GPLv3+:~GNU~GPL~version~3~or~later~~\\
This~is~free~software:~you~are~free~to~change~and~redistribute~it.~\\
There~is~NO~WARRANTY,~to~the~extent~permitted~by~law.~~Type~"show~copying"~\\
and~"show~warranty"~for~details.~\\
This~GDB~was~configured~as~"i486-linux-gnu"...~\\
Using~host~libthread{\_}db~library~"/lib/i686/cmov/libthread{\_}db.so.1".~\\
(gdb)~break~106~\\
Breakpoint~1~at~0xOBFUSCA:~file~hello.c,~line~106.~\\
(gdb)~break~109~\\
Breakpoint~2~at~0xTETHESY:~file~hello.c,~line~109.~\\
(gdb)~run~\\
Starting~program:~/home/brian/writing/cobol/hello~\\
{[}Thread~debugging~using~libthread{\_}db~enabled{]}~\\
{[}New~Thread~0xSTEMADDR~(LWP~5782){]}~\\
{[}Switching~to~Thread~0xESSES6b0~(LWP~5782){]}~\\
~\\
Breakpoint~1,~hello{\_}~(entry=0)~at~hello.c:106~\\
106~~~~~~~~~cob{\_}new{\_}display~(0,~1,~1,~{\&}c{\_}1);~\\
(gdb)~cont~\\
Continuing.~\\
Hello~World!~\\
~\\
Breakpoint~2,~hello{\_}~(entry=0)~at~hello.c:109~\\
109~~~~~~~cob{\_}set{\_}location~("hello",~"hello.cob",~6,~"MAIN~SECTION",~"MAIN~PARAGRAPH",~"STOP");~\\
(gdb)~cont~\\
Continuing.~\\
~\\
Program~exited~normally.~\\
(gdb)
}\end{quote}
Setting a break at line 106 and 109 was found by a quick look through the C
code from \textbf{{\$} cobc -C hello.cob} and seeing where the DISPLAY call and
STOP RUN was located. \emph{Note: just because; the gdb displayed addresses were
obfuscated from this listing.}
%___________________________________________________________________________
\hypertarget{some-debugging-tricks}{}
\pdfbookmark[2]{5.29.1~~~Some debugging tricks}{some-debugging-tricks}
\subsubsection*{5.29.1~~~Some debugging tricks}
\label{some-debugging-tricks}
From [\hyperlink{human}{human}] on opencobol.org:
If you want to have different outputs in debug / normal mode use a fake
if 1 = 1 like
\begin{quote}{\ttfamily \raggedright \noindent
D~~~~IF~1~=~1~\\
D~~~~~~~DISPLAY~"Debug~Line"~~END-DISPLAY~\\
D~~~~ELSE~\\
~~~~~~~~DISPLAY~"Normal~Line"~END-DISPLAY~\\
D~~~~END-IF
}\end{quote}
For using the environment Just define
\begin{quote}{\ttfamily \raggedright \noindent
01~~debugmode~pic~x.~\\
~~~~88~~debugmode-on~values~'O',~'Y',~'J',~'o',~'y',~'j',~'1'.
}\end{quote}
put an
\begin{quote}{\ttfamily \raggedright \noindent
accept~debugmode~from~Environment~"DEBUGMODE"~\\
end-accept
}\end{quote}
at the beginning of each program (or define debugmode as external) and use
it in your programs like
\begin{quote}{\ttfamily \raggedright \noindent
IF~debugmode-on~\\
~~~DISPLAY~"Debug~Line"~~END-DISPLAY~\\
ELSE~\\
~~~DISPLAY~"Normal~Line"~END-DISPLAY~\\
END-IF
}\end{quote}
For having no debug code in runtime you can combine these two
\begin{quote}{\ttfamily \raggedright \noindent
D~01~debugmode~pic~x.~\\
D~~~~88~debugmode-on~values~'O',~'Y',~'J',~'o',~'y',~'j',~'1'.~\\
~\\
...~\\
~\\
D~~~~accept~debugmode~from~Environment~"DEBUGMODE"~\\
D~~~~end-accept~\\
~\\
...~\\
~\\
D~~~~IF~debugmode-on~\\
D~~~~~~~DISPLAY~"Debug~Line"~~END-DISPLAY~\\
D~~~~ELSE~\\
~~~~~~~~DISPLAY~"Normal~Line"~END-DISPLAY~\\
D~~~~END-IF
}\end{quote}
In this way you have fast code at runtime (if not compiled with
-fdebugging-line) and can switch the output during development.
The advantages over a compiler switch to disable the displays are:
\begin{itemize}
\item {}
You can always use display in your program, not only for debug
information.
\item {}
You see in the code what you do.
\item {}
If compiled with lines that have 'D' indicator you can switch at runtime.
\item {}
If compiled without lines that have 'D' indicator you can have faster and
smaller modules.
\end{itemize}
%___________________________________________________________________________
\hypertarget{is-there-a-c-interface-to-opencobol}{}
\pdfbookmark[1]{5.30~~~Is there a C interface to OpenCOBOL?}{is-there-a-c-interface-to-opencobol}
\subsection*{5.30~~~Is there a C interface to OpenCOBOL?}
\label{is-there-a-c-interface-to-opencobol}
Most definitely. See
\href{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.
%___________________________________________________________________________
\hypertarget{what-are-some-idioms-for-dealing-with-c-char-data-from-opencobol}{}
\pdfbookmark[1]{5.31~~~What are some idioms for dealing with C char * data from OpenCOBOL?}{what-are-some-idioms-for-dealing-with-c-char-data-from-opencobol}
\subsection*{5.31~~~What are some idioms for dealing with C char * data from OpenCOBOL?}
\label{what-are-some-idioms-for-dealing-with-c-char-data-from-opencobol}
\emph{Thanks to Frank Swarbrick for pointing these idioms out}
To add or remove a null terminator, use the STRING verb. For example
\begin{quote}{\ttfamily \raggedright \noindent
*~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.
}\end{quote}
Or to make changes in place
\begin{quote}{\ttfamily \raggedright \noindent
*~Change~nulls~to~spaces~\\
~INSPECT~current-url~\\
~~~~~REPLACING~ALL~X"00"~WITH~SPACE.
}\end{quote}
Or there is also modified references in OpenCOBOL
\begin{quote}{\ttfamily \raggedright \noindent
*~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).
}\end{quote}
[\hyperlink{roger}{Roger}] While points out:
\emph{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 \textbf{LOW-VALUE} or \emph{LOW-VALUES}. \emph{Except when a program collating
sequence is active and where the first character is not X``00''}.
% Note to maintainers. The section below is just wrong. BASED is a
% different thing altogether and simply means the item does not have any
% permanent storage area. Entry commented out until corrected.
% When a parameter needs to be passed between C and OpenCOBOL, you can use
% the BASED optional clause in WORKING-STORAGE::
%
% * Create a BASED allocation
% WORKING-STORAGE SECTION.
% 01 current-url PIC X(80) BASED.
%
% This may be a cleaner solution than::
%
% LINKAGE SECTION.
% 01 current-url PIC X(80).
%
% And a SET ADDRESS OF CARG ... sequence.
With the CALL verb, use ADDRESS OF and/or BY REFERENCE
\begin{quote}{\ttfamily \raggedright \noindent
CALL~"CFUNCTION"~USING~BY~REFERENCE~ADDRESS~OF~current-url.
}\end{quote}
The above being equivalent to char** in C.
COBOL, by it's nature, passes all arguments by reference. That can
be overridden with the \textbf{BY VALUE} clause and the \textbf{BY CONTENT} clause.
%___________________________________________________________________________
\hypertarget{does-opencobol-support-copy-includes}{}
\pdfbookmark[1]{5.32~~~Does OpenCOBOL support COPY includes?}{does-opencobol-support-copy-includes}
\subsection*{5.32~~~Does OpenCOBOL support COPY includes?}
\label{does-opencobol-support-copy-includes}
Yes. COPY is fully supported, all variations from the standards up to and
including the proposed 20xx standards.
Inline REPLACE text substitutions are also supported.
The \textbf{-I} compiler option influences the copybook search path and
\textbf{-E} can be used to examine the \emph{after} COPY preprocessor output.
There is also \textbf{-ffold-copy-upper} and \textbf{-ffold-copy-lower} compiler
controls.
%___________________________________________________________________________
\hypertarget{does-opencobol-support-when-compiled}{}
\pdfbookmark[1]{5.33~~~Does OpenCOBOL support WHEN-COMPILED?}{does-opencobol-support-when-compiled}
\subsection*{5.33~~~Does OpenCOBOL support WHEN-COMPILED?}
\label{does-opencobol-support-when-compiled}
Both as a noun and as an intrinsic function.
\begin{quote}{\ttfamily \raggedright \noindent
DISPLAY~WHEN-COMPILED.~\\
DISPLAY~FUNCTION~WHEN-COMPILED.~\\
~\\
07/05/0805.15.20~\\
2008070505152000-0400
}\end{quote}
Note: The noun WHEN-COMPILED is non-standard and was deemed obsolete in the
pre 85 standard.
%___________________________________________________________________________
\hypertarget{what-is-pi-in-opencobol}{}
\pdfbookmark[1]{5.34~~~What is PI in OpenCOBOL?}{what-is-pi-in-opencobol}
\subsection*{5.34~~~What is PI in OpenCOBOL?}
\label{what-is-pi-in-opencobol}
With OpenCOBOL 1.1
\begin{quote}{\ttfamily \raggedright \noindent
DISPLAY~FUNCTION~PI.~\\
3.1415926535897932384626433832795029~\\
~\\
DISPLAY~FUNCTION~E.~\\
2.7182818284590452353602874713526625
}\end{quote}
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 \href{\#gmp}{GMP}.
%___________________________________________________________________________
\hypertarget{does-opencobol-support-the-object-features-of-the-2002-standard}{}
\pdfbookmark[1]{5.35~~~Does OpenCOBOL support the Object features of the 2002 standard?}{does-opencobol-support-the-object-features-of-the-2002-standard}
\subsection*{5.35~~~Does OpenCOBOL support the Object features of the 2002 standard?}
\label{does-opencobol-support-the-object-features-of-the-2002-standard}
Not yet. \emph{July 2008}
%___________________________________________________________________________
\hypertarget{does-opencobol-implement-picture-78}{}
\pdfbookmark[1]{5.36~~~Does OpenCOBOL implement PICTURE 78?}{does-opencobol-implement-picture-78}
\subsection*{5.36~~~Does OpenCOBOL implement PICTURE 78?}
\label{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.
%___________________________________________________________________________
\hypertarget{does-opencobol-implement-constant}{}
\pdfbookmark[1]{5.37~~~Does OpenCOBOL implement CONSTANT?}{does-opencobol-implement-constant}
\subsection*{5.37~~~Does OpenCOBOL implement CONSTANT?}
\label{does-opencobol-implement-constant}
Current OC 1.1 has preliminary support for a subset of the standard
conforming ``CONSTANT'' phrase. eg
\begin{quote}{\ttfamily \raggedright \noindent
01~~MYCONST~CONSTANT~AS~1.
}\end{quote}
Note: there is a syntax difference between 78 and CONSTANT.
%___________________________________________________________________________
\hypertarget{what-source-formats-are-accepted-by-opencobol}{}
\pdfbookmark[1]{5.38~~~What source formats are accepted by OpenCOBOL?}{what-source-formats-are-accepted-by-opencobol}
\subsection*{5.38~~~What source formats are accepted by OpenCOBOL?}
\label{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:
\begin{quote}{\ttfamily \raggedright \noindent
Column~\\
12345678901234567890~\\
~~~~~~~>{}>SOURCE~FORMAT~IS~FREE~\\
~~~~~~~>{}>SOURCE~FORMAT~IS~FIXED
}\end{quote}
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 \textbf{{\&}} operator.
The special *{\textgreater} \emph{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.
% Note to readers. The comment operator is *>
% the backslash is for ReST
The \textbf{-free} and \textbf{-fixed} options to \textbf{cobc} also influence the expected
source formats, with the default being mandated by the standards as FIXED.
%___________________________________________________________________________
\hypertarget{does-opencobol-support-continuation-lines}{}
\pdfbookmark[1]{5.39~~~Does OpenCOBOL support continuation lines?}{does-opencobol-support-continuation-lines}
\subsection*{5.39~~~Does OpenCOBOL support continuation lines?}
\label{does-opencobol-support-continuation-lines}
Yes. A dash \textbf{-} 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
\emph{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
\begin{quote}{\ttfamily \raggedright \noindent
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.
}\end{quote}
Compiled with:
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~cobc~longcont.cob~\\
{\$}~cobcrun~longcont
}\end{quote}
produces:
\begin{quote}{\ttfamily \raggedright \noindent
This~will~all~be~one~string~in~FIXED~format~source~code~\\
80~\\
00000055~\\
this~~~~~~~~~~~~~~~~~~~~~~~~~~~string~will~have~spaces~between~the~words~\\
THIS~and~STRING,~as~~~continuation~lines~always~fill~to~column~72.~\\
148~\\
00000139
}\end{quote}
\emph{Note: The DISPLAY of} \textbf{otherstr} \emph{was split to avoid any wide
browser scrolling, not for any COBOL reasons.}
\emph{Also note that the rules for continuation lines are quite difficult to
describe simply and concerned OpenCOBOL programmers are urged to read
through the standards documents for full details.}
%___________________________________________________________________________
\hypertarget{does-opencobol-support-string-concatenation}{}
\pdfbookmark[1]{5.40~~~Does OpenCOBOL support string concatenation?}{does-opencobol-support-string-concatenation}
\subsection*{5.40~~~Does OpenCOBOL support string concatenation?}
\label{does-opencobol-support-string-concatenation}
Absolutely. Sources that need long strings, or those wishing to enhance
source code readability, can use the \textbf{{\&}} operator
\begin{quote}{\ttfamily \raggedright \noindent
identification~division.~\\
program-id.~longstr.~\\
~\\
data~division.~\\
working-storage~section.~\\
01~~longstr~~~~~pic~X(80)~\\
~~~~~~~~~~~~~~~~value~"This~"~{\&}~"will~"~{\&}~"all~"~{\&}~"be~"~{\&}~\\
~~~~~~~~~~~~~~~~~~~~~~"one~"~{\&}~\\
~~~~~~~~~~~~~~~~~~~~~~"string~"~{\&}~"in~both~FIXED~and~FREE"~{\&}~\\
~~~~~~~~~~~~~~~~~~~~~~"~format~source~code".~\\
procedure~division.~\\
display~longstr.~\\
goback.
}\end{quote}
Run this with
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~cobc~longstr.cob~\\
{\$}~cobcrun~longstr~\\
This~will~all~be~one~string~in~both~FIXED~and~FREE~format~source~code~\\
{\$}~cobc~-free~longstr.cob~\\
{\$}~cobcrun~longstr~\\
This~will~all~be~one~string~in~both~FIXED~and~FREE~format~source~code
}\end{quote}
And for an Intrinsic FUNCTION unique to OpenCOBOL, see \href{\#function-concatenate}{FUNCTION CONCATENATE}.
%___________________________________________________________________________
\hypertarget{does-opencobol-support-d-indicator-debug-lines}{}
\pdfbookmark[1]{5.41~~~Does OpenCOBOL support D indicator debug lines?}{does-opencobol-support-d-indicator-debug-lines}
\subsection*{5.41~~~Does OpenCOBOL support D indicator debug lines?}
\label{does-opencobol-support-d-indicator-debug-lines}
Yes, in two forms. As for continuation lines, column
7 has no meaning for SOURCE FORMAT IS FREE source code so the standard
\textbf{D} in column 7 can not be used. FORMAT FREE source code can use the
\textbf{{\textgreater}{\textgreater}D} compiler directive instead. Use \textbf{D} lines as
a conditional include of a source code line. These debug lines will only
be compiled if the \emph{-fdebugging-line} compiler switch is used.
From human on \href{http://opencobol.org/}{opencobol.org}
\begin{quote}{\ttfamily \raggedright \noindent
If~you~put~a~D~in~column~7~OC~handles~this~as~a~comment.~These~lines~are~\\
only~compiled~if~you~run~cobc~with~-fdebugging-line.~\\
~\\
By~using~this~you~can~put~some~test~messages~etc.~into~your~program~that~\\
are~only~used~if~necessary~(and~therefore~build~with~-fdebugging-line).
}\end{quote}
OpenCOBOL also supports a \textbf{{\textgreater}{\textgreater}D} debug compile time directive and
a handy trick for those that like to write code that be compiled in both
FIXED and FREE forms, is to place the directive in column 5, 6 and 7.
\begin{quote}{\ttfamily \raggedright \noindent
Column~\\
12345678901234567890~\\
~~~~~~~DISPLAY~"Normal~Line"~END-DISPLAY~\\
~~~~>{}>DDISPLAY~"Debug~Line"~END-DISPLAY
}\end{quote}
This allows use of the directive form in FORMAT FREE and also, with the
\textbf{D} in column 7, will compile properly in FORMAT FIXED. In FORMAT FIXED
the \textbf{{\textgreater}{\textgreater}} in columns 5 and 6 will be ignored as part of the
\emph{sequence number} field.
For more information on debugging support see
\href{\#what-about-debugging-opencobol-programs}{What about debugging OpenCOBOL programs?}
%___________________________________________________________________________
\hypertarget{does-opencobol-support-mixed-case-source-code}{}
\pdfbookmark[1]{5.42~~~Does OpenCOBOL support mixed case source code?}{does-opencobol-support-mixed-case-source-code}
\subsection*{5.42~~~Does OpenCOBOL support mixed case source code?}
\label{does-opencobol-support-mixed-case-source-code}
Absolutely, kind of. Mixed case and mixed format, \href{\#ascii}{ASCII} and \href{\#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 \emph{with certain rules} before translating.
The compiler is case insensitive to names
\begin{quote}{\ttfamily \raggedright \noindent
000100~identification~division.~\\
000200~program-id.~mixcase.~\\
000300~data~division.~\\
000400~working-storage~section.~\\
000500~01~SOMEUPPER~pic~x(9).~\\
000600~01~SomeUpper~pic~x(9).~\\
000700~01~someupper~pic~x(9).~\\
000800~\\
000900~procedure~division.~\\
001000~move~"SOMEUPPER"~to~SOMEUPPER.~\\
001100~move~"SomeUpper"~to~SomeUpper.~\\
001200~move~"someupper"~to~someupper.~\\
001300~display~"SOMEUPPER:~"~SOMEUPPER~end-display.~\\
001400~display~"SomeUpper:~"~SomeUpper~end-display.~\\
001500~display~"someupper:~"~someupper~end-display.~\\
001600~stop~run.
}\end{quote}
Attempted compile with:
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~cobc~-x~mixcase.cob
}\end{quote}
produces:
\begin{quote}{\ttfamily \raggedright \noindent
mixcase.cob:10:~Error:~'SOMEUPPER'~ambiguous;~need~qualification~\\
mixcase.cob:5:~Error:~'SOMEUPPER'~defined~here~\\
mixcase.cob:6:~Error:~'SOMEUPPER'~defined~here~\\
mixcase.cob:7:~Error:~'SOMEUPPER'~defined~here
}\end{quote}
Note; that although the folded declarations conflict, the DISPLAY quoted
strings will NOT be folded, and would display as expected.
\emph{Case sensitivity is also at the mercy of operating system conventions}.
Under GNU/Linux, OpenCOBOL's dynamic link loader is case sensitive.
\begin{quote}{\ttfamily \raggedright \noindent
CALL~"C{\$}JUSTIFY"~USING~center-string~"C"~END-CALL.
}\end{quote}
is not the same as
\begin{quote}{\ttfamily \raggedright \noindent
CALL~"c{\$}justify"~USING~center-string~"C"~END-CALL.
}\end{quote}
In support of case folding and COPY libraries, OpenCOBOL supports
\emph{-ffold-copy-lower} and \emph{-ffold-copy-upper}. For mixing and matching legacy
sources.
\begin{description}
\item[{Trivia}] \leavevmode
The expressions \emph{uppercase} and \emph{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.
\end{description}
%___________________________________________________________________________
\hypertarget{what-is-the-shortest-opencobol-program}{}
\pdfbookmark[1]{5.43~~~What is the shortest OpenCOBOL program?}{what-is-the-shortest-opencobol-program}
\subsection*{5.43~~~What is the shortest OpenCOBOL program?}
\label{what-is-the-shortest-opencobol-program}
All that is needed is a program-id. Doesn't do much.
\begin{quote}{\ttfamily \raggedright \noindent
program-id.~a.
}\end{quote}
%___________________________________________________________________________
\hypertarget{what-is-the-shortest-hello-world-program-in-opencobol}{}
\pdfbookmark[1]{5.44~~~What is the shortest Hello World program in OpenCOBOL?}{what-is-the-shortest-hello-world-program-in-opencobol}
\subsection*{5.44~~~What is the shortest Hello World program in OpenCOBOL?}
\label{what-is-the-shortest-hello-world-program-in-opencobol}
A short version of OpenCOBOL hello world, compiled -free
\begin{quote}{\ttfamily \raggedright \noindent
program-id.hello.procedure~division.display~"Hello~World!".
}\end{quote}
Thanks to human and the \href{http://opencobol.org/}{opencobol.org} forums.
\emph{Please note:} This is \textbf{not good} COBOL form, and is only shown as an
example of the possibilities.
%___________________________________________________________________________
\hypertarget{how-do-i-get-those-nifty-sequential-sequence-numbers-in-a-source-file}{}
\pdfbookmark[1]{5.45~~~How do I get those nifty sequential sequence numbers in a source file?}{how-do-i-get-those-nifty-sequential-sequence-numbers-in-a-source-file}
\subsection*{5.45~~~How do I get those nifty sequential sequence numbers in a source file?}
\label{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 \textbf{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 \textbf{vi} trick to renumber the sequence field by 100s.
Given
\begin{quote}{\ttfamily \raggedright \noindent
000005*~HELLO.COB~OpenCOBOL~FAQ~example~\\
000010~IDENTIFICATION~DIVISION.~\\
000020~PROGRAM-ID.~hello.~\\
000030~PROCEDURE~DIVISION.~\\
000040~DISPLAY~"Hello~World!".~\\
000100~STOP~RUN.
}\end{quote}
Running the following \textbf{ex} filter
\begin{quote}
:{\%}!perl -ne 'printf(``{\textbackslash}{\%}06d{\textbackslash}{\%}s{\textbackslash}n'', {\$}. * 100, substr({\$}{\_}, 6, -1));'
\end{quote}
% Note to readers of the plain text of this FAQ. ReStructuredText uses
% backslash to escape certain features. That line is actually
% :%!perl -ne 'printf("\%06d\%s\n", $. * 100, substr($_, 6, -1));'
produces a nicely resequenced source file.
\begin{quote}{\ttfamily \raggedright \noindent
000100*~HELLO.COB~OpenCOBOL~FAQ~example~\\
000200~IDENTIFICATION~DIVISION.~\\
000300~PROGRAM-ID.~hello.~\\
000400~PROCEDURE~DIVISION.~\\
000500~DISPLAY~"Hello~World!".~\\
000600~STOP~RUN.
}\end{quote}
\begin{itemize}
\item {}
Note: Only use this on already FIXED form source. If used on any FREE format
COBOL, the first 6 columns will be damaged.
\end{itemize}
This has no effect on the compilation process, it only effects the appearance
of the sources.
\begin{center}\begin{sffamily}
\fbox{\parbox{\admonitionwidth}{
\textbf{\large Attention!}
\vspace{2mm}
Be careful not to confuse SEQUENCE NUMBERS with source code
LINE NUMBERS. They are not the same.
}}
\end{sffamily}
\end{center}
\begin{itemize}
\item {}
Vim: For users of the Vim editor, the command
\end{itemize}
\begin{quote}{\ttfamily \raggedright \noindent
:set~number
}\end{quote}
will display the number of each source line. Many editors support the display
of line numbers. Even
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~less~-N
}\end{quote}
can be used to display line numbers of its input.
%___________________________________________________________________________
\hypertarget{is-there-a-way-to-count-trailing-spaces-in-data-fields-using-opencobol}{}
\pdfbookmark[1]{5.46~~~Is there a way to count trailing spaces in data fields using OpenCOBOL?}{is-there-a-way-to-count-trailing-spaces-in-data-fields-using-opencobol}
\subsection*{5.46~~~Is there a way to count trailing spaces in data fields using OpenCOBOL?}
\label{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
\begin{quote}{\ttfamily \raggedright \noindent
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.
}\end{quote}
produces:
\begin{quote}{\ttfamily \raggedright \noindent
062~\\
124~\\
062
}\end{quote}
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 \href{http://opencobol.org/}{opencobol.org} forum post.
%___________________________________________________________________________
\hypertarget{is-there-a-way-to-left-justify-an-edited-numeric-field}{}
\pdfbookmark[1]{5.47~~~Is there a way to left justify an edited numeric field?}{is-there-a-way-to-left-justify-an-edited-numeric-field}
\subsection*{5.47~~~Is there a way to left justify an edited numeric field?}
\label{is-there-a-way-to-left-justify-an-edited-numeric-field}
Yes, a couple of ways.
Assuming a working storage of
\begin{quote}{\ttfamily \raggedright \noindent
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
}\end{quote}
With OpenCOBOL, the intrinsic
\begin{quote}{\ttfamily \raggedright \noindent
FUNCTION~TRIM(myedit~LEADING)
}\end{quote}
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
\begin{quote}{\ttfamily \raggedright \noindent
CALL~"C{\$}JUSTIFY"~USING~mychars~"L"~END-CALL
}\end{quote}
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
\begin{quote}{\ttfamily \raggedright \noindent
MOVE~0~TO~spcount~\\
INSPECT~myedit~TALLYING~spcount~FOR~LEADING~SPACE~\\
MOVE~myedit(spcount~+~1:)~TO~mychars~\\
~\\
DISPLAY~myedit~END-DISPLAY~\\
DISPLAY~mychars~END-DISPLAY
}\end{quote}
\begin{quote}{\ttfamily \raggedright \noindent
~~~~~123~\\
123
}\end{quote}
\begin{quote}{\ttfamily \raggedright \noindent
MOVE~0~TO~spcount~\\
INSPECT~mynumber~TALLYING~spcount~FOR~LEADING~ZERO~\\
DISPLAY~mynumber~\\
DISPLAY~mynumber(spcount~+~1:)
}\end{quote}
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.
%___________________________________________________________________________
\hypertarget{is-there-a-way-to-detemermine-when-opencobol-is-running-ascii-or-ebcdic}{}
\pdfbookmark[1]{5.48~~~Is there a way to detemermine when OpenCOBOL is running ASCII or EBCDIC?}{is-there-a-way-to-detemermine-when-opencobol-is-running-ascii-or-ebcdic}
\subsection*{5.48~~~Is there a way to detemermine when OpenCOBOL is running ASCII or EBCDIC?}
\label{is-there-a-way-to-detemermine-when-opencobol-is-running-ascii-or-ebcdic}
OpenCOBOL supports both ASCII and EBCDIC character encodings. A simple test
such as
\begin{quote}{\ttfamily \raggedright \noindent
01~~MYSPACE~~~PIC~X~VALUE~X"20".~\\
~~~~88~MYISASCII~~~VALUE~SPACE.~\\
~\\
IF~MYISASCII~\\
~~~~DISPLAY~"I'm~ASCII"~END-DISPLAY~\\
END-IF
}\end{quote}
can be used to determine the character set at run-time.
%___________________________________________________________________________
\hypertarget{is-there-a-way-to-determine-when-opencobol-is-running-on-32-or-64-bits}{}
\pdfbookmark[1]{5.49~~~Is there a way to determine when OpenCOBOL is running on 32 or 64 bits?}{is-there-a-way-to-determine-when-opencobol-is-running-on-32-or-64-bits}
\subsection*{5.49~~~Is there a way to determine when OpenCOBOL is running on 32 or 64 bits?}
\label{is-there-a-way-to-determine-when-opencobol-is-running-on-32-or-64-bits}
OpenCOBOL builds and supports both 32 and 64 bit architectures. A simple
test such as
\begin{quote}{\ttfamily \raggedright \noindent
01~~MYPOINTER~~~~USAGE~POINTER.~\\
~\\
IF~FUNCTION~LENGTH(MYPOINTER)~EQUALS~8~\\
~~~~DISPLAY~"This~is~a~64~bit~machine"~END-DISPLAY~\\
END-IF
}\end{quote}
can be used to determine the native bit size at run-time.
%___________________________________________________________________________
\hypertarget{does-opencobol-support-recursion}{}
\pdfbookmark[1]{5.50~~~Does OpenCOBOL support recursion?}{does-opencobol-support-recursion}
\subsection*{5.50~~~Does OpenCOBOL support recursion?}
\label{does-opencobol-support-recursion}
Yes. Not completely to standard currently \emph{(February 2009)}, as there are no restrictions
on calling programs in a recursive manner, but yes.
A made up example using a factorial called program
\begin{quote}{\ttfamily \raggedright \noindent
*>~**~*>~***************************************************************~\\
~~~~~~*>~Author:~~~~Brian~Tiffin~\\
~~~~~~*>~Date:~~~~~~29-Dec-2008~\\
~~~~~~*>~Purpose:~~~Horsing~around~with~recursion~\\
~~~~~~*>~Tectonics:~cobc~-x~recurse.cob~\\
~~~~~~*>~***************************************************************~\\
~~~~~~~identification~division.~\\
~~~~~~~program-id.~recurse.~\\
~\\
~~~~~~~data~division.~\\
~~~~~~~working-storage~section.~\\
~~~~~~~78~n~~~~~~value~4.~\\
~~~~~~~01~fact~usage~binary-long.~\\
~\\
~~~~~~*>~***************************************************************~\\
~~~~~~~procedure~division.~\\
~\\
~~~~~~~call~"factorial"~using~by~value~n~returning~fact~end-call~\\
~~~~~~~display~n~"!~=~"~fact~end-display~\\
~\\
~~~~~~~goback.~\\
~~~~~~~end~program~recurse.~\\
~~~~~~*>~***************************************************************~\\
~~~~~~*>~***************************************************************~\\
~\\
~~~~~~*>~***************************************************************~\\
~~~~~~~identification~division.~\\
~~~~~~~program-id.~factorial~is~recursive.~\\
~\\
~~~~~~~data~division.~\\
~~~~~~~local-storage~section.~\\
~~~~~~~01~result~usage~is~binary-long.~\\
~\\
~~~~~~~linkage~section.~\\
~~~~~~~01~num~usage~is~binary-long.~\\
~\\
~~~~~~*>~***************************************************************~\\
~~~~~~~procedure~division~using~by~value~num.~\\
~\\
~~~~~~~display~"num:~"~num~end-display~\\
~~~~~~~if~num~equal~zero~\\
~~~~~~~~~~~move~1~to~return-code~\\
~~~~~~~~~~~display~"ret:~"~return-code~end-display~\\
~~~~~~~~~~~goback~\\
~~~~~~~end-if~\\
~\\
~~~~~~~subtract~1~from~num~end-subtract~\\
~~~~~~~call~"factorial"~using~by~value~num~returning~result~end-call~\\
~~~~~~~compute~return-code~=~(num~+~1)~*~result~end-compute~\\
~~~~~~~display~"ret:~"~return-code~end-display~\\
~~~~~~~goback.~\\
~\\
~~~~~~~end~program~factorial.
}\end{quote}
Produces:
\begin{quote}{\ttfamily \raggedright \noindent
num:~+0000000004~\\
num:~+0000000003~\\
num:~+0000000002~\\
num:~+0000000001~\\
num:~+0000000000~\\
ret:~+000000001~\\
ret:~+000000001~\\
ret:~+000000002~\\
ret:~+000000006~\\
ret:~+000000024~\\
4!~=~+0000000024
}\end{quote}
Of course the \emph{Intrinsic FUNCTION FACTORIAL} might be a more efficient
and much easier way at getting factorials.
%___________________________________________________________________________
\hypertarget{does-opencobol-capture-arithmetic-overflow}{}
\pdfbookmark[1]{5.51~~~Does OpenCOBOL capture arithmetic overflow?}{does-opencobol-capture-arithmetic-overflow}
\subsection*{5.51~~~Does OpenCOBOL capture arithmetic overflow?}
\label{does-opencobol-capture-arithmetic-overflow}
Yes. Here is one sample using \emph{ADD} with \emph{ON SIZE ERROR}.
\begin{quote}{\ttfamily \raggedright \noindent
*>~**~*>~***************************************************************~\\
~~~~~~*>~Author:~~~~Brian~Tiffin~\\
~~~~~~*>~Date:~~~~~~04-Feb-2009~\\
~~~~~~*>~Purpose:~~~Factorial~and~overflow~\\
~~~~~~*>~Tectonics:~cobc~-x~overflowing.cob~\\
~~~~~~*>~***************************************************************~\\
~~~~~~~identification~division.~\\
~~~~~~~program-id.~overflowing.~\\
~\\
~~~~~~~data~division.~\\
~~~~~~~working-storage~section.~\\
~~~~~~~01~fact~~~usage~binary-long.~\\
~~~~~~~01~answer~usage~binary-double.~\\
~\\
~~~~~~*>~***************************************************************~\\
~~~~~~~procedure~division.~\\
~~~~~~~00-main.~\\
~\\
~~~~~~~perform~\\
~~~~~~~~~~~varying~fact~from~1~by~1~\\
~~~~~~~~~~~until~fact~>~21~\\
~~~~~~~~~~~~~~~add~function~factorial(fact)~to~zero~giving~answer~\\
~~~~~~~~~~~~~~~~~~~on~size~error~\\
~~~~~~~~~~~~~~~~~~~~~~~display~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~"overflow~at:~"~fact~"~is~"~answer~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~"~without~test~"~function~factorial(fact)~\\
~~~~~~~~~~~~~~~~~~~~~~~end-display~\\
~~~~~~~~~~~~~~~~~~~not~on~size~error~\\
~~~~~~~~~~~~~~~~~~~~~~~display~fact~":~"~answer~end-display~\\
~~~~~~~~~~~~~~~end-add~\\
~~~~~~~end-perform~\\
~~~~~~~.~\\
~\\
~~~~~~~00-leave.~\\
~~~~~~~goback.~\\
~\\
~~~~~~~end~program~overflowing.~\\
~~~~~~*>~***************************************************************
}\end{quote}
which outputs:
\begin{quote}{\ttfamily \raggedright \noindent
+0000000001:~+00000000000000000001~\\
+0000000002:~+00000000000000000002~\\
+0000000003:~+00000000000000000006~\\
+0000000004:~+00000000000000000024~\\
+0000000005:~+00000000000000000120~\\
+0000000006:~+00000000000000000720~\\
+0000000007:~+00000000000000005040~\\
+0000000008:~+00000000000000040320~\\
+0000000009:~+00000000000000362880~\\
+0000000010:~+00000000000003628800~\\
+0000000011:~+00000000000039916800~\\
+0000000012:~+00000000000479001600~\\
+0000000013:~+00000000006227020800~\\
+0000000014:~+00000000087178291200~\\
+0000000015:~+00000001307674368000~\\
+0000000016:~+00000020922789888000~\\
+0000000017:~+00000355687428096000~\\
+0000000018:~+00006402373705728000~\\
+0000000019:~+00121645100408832000~\\
overflow~at:~+0000000020~is~+00121645100408832000~without~test~432902008176640000~\\
overflow~at:~+0000000021~is~+00121645100408832000~without~test~197454024290336768
}\end{quote}
%___________________________________________________________________________
\hypertarget{can-opencobol-be-used-for-plotting}{}
\pdfbookmark[1]{5.52~~~Can OpenCOBOL be used for plotting?}{can-opencobol-be-used-for-plotting}
\subsection*{5.52~~~Can OpenCOBOL be used for plotting?}
\label{can-opencobol-be-used-for-plotting}
Yes? One way is with an external call to \emph{gnuplot}.
\begin{quote}{\ttfamily \raggedright \noindent
COBOL~~>{}>SOURCE~FORMAT~IS~FIXED~\\
~~~~~~******************************************************************~\\
~~~~~~*~Author:~~~~Brian~Tiffin~\\
~~~~~~*~Date:~~~~~~29-July-2008~\\
~~~~~~*~Purpose:~~~Plot~trig~and~a~random~income/expense/worth~report~\\
~~~~~~*~Tectonics:~requires~access~to~gnuplot.~http://www.gnuplot.info~\\
~~~~~~*~~~~~~~~~~~~cobc~-Wall~-x~plotworth.cob~\\
~~~~~~*~~OVERWRITES~ocgenplot.gp~ocgpdata.txt~sincos.png~ploworth.png~\\
~~~~~~******************************************************************~\\
~~~~~~~identification~division.~\\
~~~~~~~program-id.~plotworth.~\\
~\\
~~~~~~~environment~division.~\\
~~~~~~~input-output~section.~\\
~~~~~~~file-control.~\\
~~~~~~~~~~select~scriptfile~\\
~~~~~~~~~~~~~~assign~to~"ocgenplot.gp"~\\
~~~~~~~~~~~~~~organization~is~line~sequential.~\\
~~~~~~~~~~select~outfile~\\
~~~~~~~~~~~~~~assign~to~"ocgpdata.txt"~\\
~~~~~~~~~~~~~~organization~is~line~sequential.~\\
~~~~~~~~~~select~moneyfile~\\
~~~~~~~~~~~~~~assign~to~"ocgpdata.txt"~\\
~~~~~~~~~~~~~~organization~is~line~sequential.~\\
~\\
~~~~~~~data~division.~\\
~~~~~~~file~section.~\\
~~~~~~~fd~scriptfile.~\\
~~~~~~~~~01~gnuplot-command~pic~x(82).~\\
~~~~~~~fd~outfile.~\\
~~~~~~~~~01~outrec.~\\
~~~~~~~~~~~~03~x-value~~~pic~-zzzzzz9.99.~\\
~~~~~~~~~~~~03~filler~~~~pic~x.~\\
~~~~~~~~~~~~03~sin-value~pic~-zzzz9.9999.~\\
~~~~~~~~~~~~03~filler~~~~pic~x.~\\
~~~~~~~~~~~~03~cos-value~pic~-zzzz9.9999.~\\
~~~~~~~fd~moneyfile.~\\
~~~~~~~~~01~moneyrec.~\\
~~~~~~~~~~~~03~timefield~pic~9(8).~\\
~~~~~~~~~~~~03~filler~~~~pic~x.~\\
~~~~~~~~~~~~03~income~~~~pic~-zzzzzz9.99.~\\
~~~~~~~~~~~~03~filler~~~~pic~x.~\\
~~~~~~~~~~~~03~expense~~~pic~-zzzzzz9.99.~\\
~~~~~~~~~~~~03~filler~~~~pic~x.~\\
~~~~~~~~~~~~03~networth~~pic~-zzzzzz9.99.~\\
~\\
~~~~~~~working-storage~section.~\\
~~~~~~~01~angle~~~pic~s9(7)v99.~\\
~\\
~~~~~~~01~dates~~~pic~9(8).~\\
~~~~~~~01~days~~~~pic~s9(9).~\\
~~~~~~~01~worth~~~pic~s9(9).~\\
~~~~~~~01~amount~~pic~s9(9).~\\
~\\
~~~~~~~01~gplot~~~pic~x(80)~value~is~'gnuplot~-persist~ocgenplot.gp'.~\\
~~~~~~~01~result~~pic~s9(9).~\\
~\\
~~~~~~~procedure~division.~\\
~\\
~~~~~~*~Create~the~script~to~plot~sin~and~cos~\\
~~~~~~~open~output~scriptfile.~\\
~~~~~~~move~"plot~'ocgpdata.txt'~using~1:2~with~lines~title~'sin(x)'"~\\
~~~~~~-~to~gnuplot-command.~\\
~~~~~~~write~gnuplot-command.~\\
~~~~~~~move~"replot~'ocgpdata.txt'~using~1:3~with~lines~title~'cos(x)'"~\\
~~~~~~-~to~gnuplot-command.~\\
~~~~~~~write~gnuplot-command.~\\
~~~~~~~move~"set~terminal~png;~set~output~'sincos.png';~replot"~\\
~~~~~~-~to~gnuplot-command.~\\
~~~~~~~write~gnuplot-command.~\\
~~~~~~~close~scriptfile.~\\
~\\
~~~~~~*~Create~the~sinoidal~data~\\
~~~~~~~open~output~outfile.~\\
~~~~~~~move~spaces~to~outrec.~\\
~~~~~~~perform~varying~angle~from~-10~by~0.01~\\
~~~~~~~~~~until~angle~>~10~\\
~~~~~~~~~~~~~~move~angle~to~x-value~\\
~~~~~~~~~~~~~~move~function~sin(angle)~to~sin-value~\\
~~~~~~~~~~~~~~move~function~cos(angle)~to~cos-value~\\
~~~~~~~~~~~~~~write~outrec~\\
~~~~~~~end-perform.~\\
~~~~~~~close~outfile.~\\
~\\
~~~~~~*~Invoke~gnuplot~\\
~~~~~~~call~"SYSTEM"~using~gplot~\\
~~~~~~~~~~~~~~~~~~~~returning~result.~\\
~~~~~~~if~result~not~=~0~\\
~~~~~~~~~~display~"Problem:~"~result~\\
~~~~~~~~~~stop~run~returning~result~\\
~~~~~~~end-if.~\\
~\\
~~~~~~*~Generate~script~to~plot~the~random~networth~\\
~~~~~~~open~output~scriptfile.~\\
~~~~~~~move~"set~xdata~time"~to~gnuplot-command.~\\
~~~~~~~write~gnuplot-command.~\\
~~~~~~~move~'set~timefmt~"{\%}Y{\%}m{\%}d"'~to~gnuplot-command.~\\
~~~~~~~write~gnuplot-command.~\\
~~~~~~~move~'set~format~x~"{\%}m"'~to~gnuplot-command.~\\
~~~~~~~write~gnuplot-command.~\\
~~~~~~~move~'set~title~"Income~and~expenses"'~to~gnuplot-command.~\\
~~~~~~~write~gnuplot-command.~\\
~~~~~~~move~'set~xlabel~"2008~/~2009"'~to~gnuplot-command.~\\
~~~~~~~write~gnuplot-command.~\\
~~~~~~~move~'plot~"ocgpdata.txt"~using~1:2~with~boxes~title~"Income"~\\
~~~~~~-'~linecolor~rgb~"green"'~to~gnuplot-command.~\\
~~~~~~~write~gnuplot-command.~\\
~~~~~~~move~'replot~"ocgpdata.txt"~using~1:3~with~boxes~title~"Expense"~\\
~~~~~~-'~linecolor~rgb~"red"'~to~gnuplot-command.~\\
~~~~~~~write~gnuplot-command.~\\
~~~~~~~move~'replot~"ocgpdata.txt"~using~1:4~with~lines~title~"Worth"'~\\
~~~~~~-~~~~to~gnuplot-command.~\\
~~~~~~~write~gnuplot-command.~\\
~~~~~~~move~'set~terminal~png;~set~output~"plotworth.png";~replot'~\\
~~~~~~-~~~~to~gnuplot-command.~\\
~~~~~~~write~gnuplot-command.~\\
~~~~~~~close~scriptfile.~\\
~\\
~~~~~~*~Generate~a~bi-weekly~dataset~with~date,~income,~expense,~worth~\\
~~~~~~~open~output~moneyfile.~\\
~~~~~~~move~spaces~to~moneyrec.~\\
~~~~~~~move~function~integer-of-date(20080601)~to~dates.~\\
~~~~~~~move~function~random(0)~to~amount.~\\
~\\
~~~~~~~perform~varying~days~from~dates~by~14~\\
~~~~~~~~~~until~days~>~dates~+~365~\\
~~~~~~~~~~~~~~move~function~date-of-integer(days)~to~timefield~\\
~~~~~~~~~~~~~~compute~amount~=~function~random()~*~2000~\\
~~~~~~~~~~~~~~compute~worth~=~worth~+~amount~\\
~~~~~~~~~~~~~~move~amount~to~income~\\
~~~~~~~~~~~~~~compute~amount~~=~function~random()~*~1800~\\
~~~~~~~~~~~~~~compute~worth~=~worth~-~amount~\\
~~~~~~~~~~~~~~move~amount~to~expense~\\
~~~~~~~~~~~~~~move~worth~to~networth~\\
~~~~~~~~~~~~~~write~moneyrec~\\
~~~~~~~end-perform.~\\
~~~~~~~close~moneyfile.~\\
~\\
~~~~~~*~Invoke~gnuplot~again.~~Will~open~new~window.~\\
~~~~~~~call~"SYSTEM"~using~gplot~\\
~~~~~~~~~~~~~~~~~~~~returning~result.~\\
~~~~~~~if~result~not~=~0~\\
~~~~~~~~~~display~"Problem:~"~result~\\
~~~~~~~~~~stop~run~returning~result~\\
~~~~~~~end-if.~\\
~\\
~~~~~~~goback.
}\end{quote}
Which displays and saves:
\includegraphics{images/sincos.png}
\includegraphics{images/plotworth.png}
%___________________________________________________________________________
\hypertarget{does-opencobol-support-the-gimp-toolkit-gtk}{}
\pdfbookmark[1]{5.53~~~Does OpenCOBOL support the GIMP ToolKit, GTK+?}{does-opencobol-support-the-gimp-toolkit-gtk}
\subsection*{5.53~~~Does OpenCOBOL support the GIMP ToolKit, GTK+?}
\label{does-opencobol-support-the-gimp-toolkit-gtk}
Yes. A binding for GTK+ is in the works. Early samples have proven
workable and screenshots of OpenCOBOL GUI screens are shown here.
\setlength{\locallinewidth}{0.9\admonitionwidth}
\begin{center}\begin{sffamily}
\fbox{\colorbox[gray]{0.80}{\parbox{\admonitionwidth}{
\textbf{\large What does GIMP stand for?}
\smallskip
\begin{description}
\item[{GIMP}] \leavevmode
is an acronym for the \emph{GNU Image Manipulation Program},
a very complete and robust grapic design tool.
See the \href{http://www.gimp.org}{GIMP} site for more information.
\item[{GTK+}] \leavevmode
is the GIMP ToolKit. See the \href{http://www.gtk.org}{GTK} site for more information.
\end{description}
}}}
\end{sffamily}
\end{center}
\setlength{\locallinewidth}{\linewidth}
Simple buttons
\includegraphics{images/gtkhello.png}
Text entry widget
\includegraphics{images/gtkhello1.png}
Sample OpenCOBOL that generated the above
\begin{quote}{\ttfamily \raggedright \noindent
*>~**~*>{}>SOURCE~FORMAT~IS~FIXED~\\
~~~~~~*>~***************************************************************~\\
~~~~~~*>~Author:~~~~Brian~Tiffin~\\
~~~~~~*>~Date:~~~~~~03-Dec-2008~\\
~~~~~~*>~Purpose:~~~Hello~from~GTK+~\\
~~~~~~*>~Requires:~~libgtk2.0,~libgtk2.0-dev,~gtk2.0,~pkg-config~\\
~~~~~~*>~Tectonics:~\\
~~~~~~*>~~~~~cobc~-c~`pkg-config~-{}-cflags~gtk+-2.0`~ocgtk.c~\\
~~~~~~*>~~~~~cobc~-x~`pkg-config~-{}-libs~gtk+-2.0`~gtkhello.cob~ocgtk.o~\\
~~~~~~*>~***************************************************************~\\
~~~~~~~identification~division.~\\
~~~~~~~program-id.~gtkhello.~\\
~\\
~~~~~~~data~division.~\\
~\\
~~~~~~~working-storage~section.~\\
~~~~~~~01~result~~~~~~~~~~~~~~~usage~binary-long.~\\
~~~~~~~01~gtk-window~~~~~~~~~~~usage~pointer.~\\
~~~~~~~01~gtk-box~~~~~~~~~~~~~~usage~pointer.~\\
~~~~~~~01~gtk-hello~~~~~~~~~~~~usage~pointer.~\\
~~~~~~~01~gtk-textentry~~~~~~~~usage~pointer.~\\
~~~~~~~01~gtk-goodbye~~~~~~~~~~usage~pointer.~\\
~\\
~~~~~~~01~callback~~~~~~~~~~~~~usage~procedure-pointer.~\\
~~~~~~~01~params~~~~~~~~~~~~~~~usage~pointer.~\\
~\\
~~~~~~*>~**************************************************************~\\
~~~~~~~procedure~division.~\\
~\\
~~~~~~*>~Initialize~GTK~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}INIT{\_}CHECK"~returning~result~END-CALL~\\
~~~~>{}>D~~~display~"init:~"~result~end-display~\\
~\\
~~~~~~*>~Create~a~toplevel~window~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}WINDOW{\_}NEW"~returning~gtk-window~END-CALL~\\
~~~~>{}>D~~~display~"win:~"~gtk-window~end-display~\\
~\\
~~~~~~*>~Set~the~titlebar~-~using~cob{\_}field~now~**HERE**~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}WINDOW{\_}SET{\_}TITLE"~\\
~~~~~~~~~~~using~by~value~gtk-window~\\
~~~~~~~~~~~~~~~by~reference~"OpenCOBOL~GTK+"~\\
~~~~~~~END-CALL~\\
~~~~>{}>D~~~display~"title:~"~gtk-window~end-display~\\
~\\
~~~~~~*>~Set~the~border~width~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}CONTAINER{\_}SET{\_}BORDER{\_}WIDTH"~\\
~~~~~~~~~~~using~by~value~gtk-window~\\
~~~~~~~~~~~~~~~by~value~5~\\
~~~~~~~END-CALL~\\
~~~~>{}>D~~~display~"border:~"~gtk-window~end-display~\\
~\\
~~~~~~*>~connect~a~window~destroy,~quit~main~loop~handler~\\
~~~~~~~set~callback~to~entry~"CBL{\_}OC{\_}destroy"~\\
~~~~~~~CALL~"CBL{\_}OC{\_}G{\_}SIGNAL{\_}CONNECT"~\\
~~~~~~~~~~~using~by~value~gtk-window~\\
~~~~~~~~~~~~~~~by~reference~"delete{\_}event"~{\&}~x"00"~\\
~~~~~~~~~~~~~~~by~value~callback~\\
~~~~~~~~~~~~~~~by~value~params~\\
~~~~~~~END-CALL~\\
~\\
~~~~~~*>~Create~a~vertically~packed~box~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}VBOX{\_}NEW"~\\
~~~~~~~~~~~using~by~value~0~\\
~~~~~~~~~~~~~~~by~value~5~\\
~~~~~~~~~~~returning~gtk-box~\\
~~~~~~~END-CALL~\\
~~~~>{}>D~~~display~"box:~"~gtk-box~end-display~\\
~\\
~~~~~~*>~Add~the~box~to~the~window~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}CONTAINER{\_}ADD"~\\
~~~~~~~~~~~using~by~value~gtk-window~\\
~~~~~~~~~~~~~~~by~value~gtk-box~\\
~~~~~~~END-CALL~\\
~\\
~~~~~~*>~Create~the~hello~button~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}BUTTON{\_}NEW{\_}WITH{\_}LABEL"~\\
~~~~~~~using~by~reference~"Hello~from~OpenCOBOL~and~GTK"~{\&}~x"00"~\\
~~~~~~~returning~gtk-hello~\\
~~~~~~~END-CALL~\\
~~~~>{}>D~~~display~"button:~"~gtk-hello~end-display~\\
~\\
~~~~~~*>~Connect~the~hello~button~to~the~hello~code~\\
~~~~~~~set~callback~to~entry~"CBL{\_}OC{\_}hello"~\\
~~~~~~~CALL~"CBL{\_}OC{\_}G{\_}SIGNAL{\_}CONNECT"~\\
~~~~~~~~~~~using~by~value~gtk-hello~\\
~~~~~~~~~~~~~~~by~reference~"clicked"~{\&}~x"00"~\\
~~~~~~~~~~~~~~~by~value~callback~\\
~~~~~~~~~~~~~~~by~value~params~\\
~~~~~~~END-CALL~\\
~\\
~~~~~~*>~Pack~the~button~into~the~box,~top~to~bottom~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}BOX{\_}PACK{\_}START"~\\
~~~~~~~~~~~using~by~value~gtk-box~\\
~~~~~~~~~~~~~~~by~value~gtk-hello~\\
~~~~~~~~~~~~~~~by~value~1~\\
~~~~~~~~~~~~~~~by~value~1~\\
~~~~~~~~~~~~~~~by~value~0~\\
~~~~~~~END-CALL~\\
~\\
~~~~~~*>~button~is~ready~to~show~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}WIDGET{\_}SHOW"~\\
~~~~~~~~~~~using~by~value~gtk-hello~\\
~~~~~~~END-CALL~\\
~\\
~~~~~~*>~Add~a~text~entry~field~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}ENTRY{\_}NEW"~\\
~~~~~~~~~~~returning~gtk-textentry~\\
~~~~~~~END-CALL~\\
~\\
~~~~~~*>~Connect~code~to~the~text~entry,~passing~the~entry~widget~\\
~~~~~~~set~callback~to~entry~"CBL{\_}OC{\_}activate"~\\
~~~~~~~CALL~"CBL{\_}OC{\_}G{\_}SIGNAL{\_}CONNECT"~\\
~~~~~~~~~~~using~by~value~gtk-textentry~\\
~~~~~~~~~~~~~~~by~reference~"activate"~{\&}~x"00"~\\
~~~~~~~~~~~~~~~by~value~callback~\\
~~~~~~~~~~~~~~~by~value~gtk-textentry~\\
~~~~~~~END-CALL~\\
~\\
~~~~~~*>~Pack~the~text~field~into~the~box,~top~to~bottom~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}BOX{\_}PACK{\_}START"~\\
~~~~~~~~~~~using~by~value~gtk-box~\\
~~~~~~~~~~~~~~~by~value~gtk-textentry~\\
~~~~~~~~~~~~~~~by~value~1~\\
~~~~~~~~~~~~~~~by~value~1~\\
~~~~~~~~~~~~~~~by~value~0~\\
~~~~~~~END-CALL~\\
~\\
~~~~~~*>~text~field~is~ready~to~show~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}WIDGET{\_}SHOW"~\\
~~~~~~~~~~~using~by~value~gtk-textentry~\\
~~~~~~~END-CALL~\\
~\\
~~~~~~*>~Create~the~bye~button~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}BUTTON{\_}NEW{\_}WITH{\_}LABEL"~\\
~~~~~~~using~by~reference~"Goodbye~from~OpenCOBOL~and~GTK"~{\&}~x"00"~\\
~~~~~~~~~~~returning~gtk-goodbye~\\
~~~~~~~END-CALL~\\
~~~~>{}>D~~~display~"button:~"~gtk-goodbye~end-display~\\
~\\
~~~~~~*>~Connect~the~bye~button~to~the~bye~code~\\
~~~~~~~set~callback~to~entry~"CBL{\_}OC{\_}destroy"~\\
~~~~~~~CALL~"CBL{\_}OC{\_}G{\_}SIGNAL{\_}CONNECT"~\\
~~~~~~~~~~~using~by~value~gtk-goodbye~\\
~~~~~~~~~~~~~~~by~reference~"clicked"~{\&}~x"00"~\\
~~~~~~~~~~~~~~~by~value~callback~\\
~~~~~~~~~~~~~~~by~value~params~\\
~~~~~~~END-CALL~\\
~\\
~~~~~~*>~Pack~the~button~into~the~box,~under~hello~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}BOX{\_}PACK{\_}START"~\\
~~~~~~~~~~~using~by~value~gtk-box~\\
~~~~~~~~~~~~~~~by~value~gtk-goodbye~\\
~~~~~~~~~~~~~~~by~value~1~\\
~~~~~~~~~~~~~~~by~value~1~\\
~~~~~~~~~~~~~~~by~value~0~\\
~~~~~~~END-CALL~\\
~~~~>{}>D~~~display~"pack:~"~gtk-box~end-display~\\
~\\
~~~~~~*>~button~is~ready~to~show~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}WIDGET{\_}SHOW"~\\
~~~~~~~~~~~using~by~value~gtk-goodbye~\\
~~~~~~~END-CALL~\\
~\\
~~~~~~*>~box~is~ready~to~show~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}WIDGET{\_}SHOW"~\\
~~~~~~~~~~~using~by~value~gtk-box~\\
~~~~~~~END-CALL~\\
~\\
~~~~~~*>~window~is~ready~to~show~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}WIDGET{\_}SHOW"~\\
~~~~~~~~~~~using~by~value~gtk-window~\\
~~~~~~~END-CALL~\\
~\\
~~~~~~*>~Start~up~the~event~loop,~control~returned~when~GTK~main~exits~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}MAIN"~END-CALL~\\
~\\
~~~~~~*>~Something~terminated~the~GTK~main~loop,~sys-close~or~bye~or~\\
~~~~~~~display~"ending..."~end-display~\\
~\\
~~~~~~~goback.~\\
~~~~~~~end~program~gtkhello.~\\
~~~~~~*>~**************************************************************~\\
~\\
~~~~~~*>~****~window~shutdown~callback~********************************~\\
~~~~~~~identification~division.~\\
~~~~~~~program-id.~CBL{\_}OC{\_}destroy.~\\
~~~~~~~data~division.~\\
~~~~~~~linkage~section.~\\
~~~~~~~01~gtk-window~~~~~~~~~~~usage~pointer.~\\
~~~~~~~01~gtk-data~~~~~~~~~~~~~usage~pointer.~\\
~\\
~~~~~~~procedure~division~using~by~value~gtk-window~by~value~gtk-data.~\\
~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}MAIN{\_}QUIT"~END-CALL~\\
~\\
~~~~~~~goback.~\\
~~~~~~~end~program~CBL{\_}OC{\_}destroy.~\\
~~~~~~*>~**************************************************************~\\
~\\
~\\
~~~~~~*>~****~hello~button~click~callback~*****************************~\\
~~~~~~~identification~division.~\\
~~~~~~~program-id.~CBL{\_}OC{\_}hello.~\\
~~~~~~~data~division.~\\
~~~~~~~linkage~section.~\\
~~~~~~~01~gtk-window~~~~~~~~~~~usage~pointer.~\\
~~~~~~~01~gtk-data~~~~~~~~~~~~~usage~pointer.~\\
~\\
~~~~~~~procedure~division~using~by~value~gtk-window~by~value~gtk-data.~\\
~~~~~~~display~\\
~~~~~~~~~~~"Hello~from~GTK~in~OpenCOBOL~at~"~\\
~~~~~~~~~~~function~current-date~\\
~~~~~~~end-display~\\
~\\
~~~~~~~goback.~\\
~~~~~~~end~program~CBL{\_}OC{\_}hello.~\\
~\\
~~~~~~*>~****~text~entry~activation~callback~**************************~\\
~~~~~~*>~This~procedure~called~from~GTK~on~enter~key~pressed~in~entry~\\
~~~~~~~identification~division.~\\
~~~~~~~program-id.~CBL{\_}OC{\_}activate.~\\
~~~~~~~data~division.~\\
~~~~~~~working-storage~section.~\\
~~~~~~~01~textfield~~~~~~~~~~~~pic~x(32).~\\
~~~~~~~01~textlen~~~~~~~~~~~~~~usage~binary-long.~\\
~\\
~~~~~~~linkage~section.~\\
~~~~~~~01~gtk-window~~~~~~~~~~~usage~pointer.~\\
~~~~~~~01~gtk-data~~~~~~~~~~~~~usage~pointer.~\\
~\\
~~~~~~~procedure~division~using~by~value~gtk-window~by~value~gtk-data.~\\
~\\
~~~~~~~CALL~"CBL{\_}OC{\_}GTK{\_}ENTRY{\_}GET{\_}TEXT"~\\
~~~~~~~~~~~using~by~value~gtk-data~\\
~~~~~~~~~~~~~~~textfield~\\
~~~~~~~~~~~returning~textlen~\\
~~~~~~~END-CALL~\\
~~~~~~~display~"text:~"~textfield~",~"~textlen~end-display~\\
~\\
~~~~~~~goback.~\\
~~~~~~~end~program~CBL{\_}OC{\_}activate.~\\
~~~~~~~*><*
}\end{quote}
A screenshot with added menu and file dialog after hitting File -{\textgreater} Open
\includegraphics{images/gtkhello2.png}
%___________________________________________________________________________
\hypertarget{notes}{}
\pdfbookmark[0]{6~~~Notes}{notes}
\section*{6~~~Notes}
\label{notes}
% These are the internal, non question information nodes.
%___________________________________________________________________________
\hypertarget{big-endian}{}
\pdfbookmark[1]{6.1~~~big-endian}{big-endian}
\subsection*{6.1~~~big-endian}
\label{big-endian}
Binary values stored with the most significant byte at the lowest memory
address.
\textbf{Big End First}.
See \href{http://en.wikipedia.org/wiki/Endianness}{http://en.wikipedia.org/wiki/Endianness} for
more details.
The OpenCOBOL compiler \emph{default} storage format for \href{\#usage}{USAGE} BINARY and COMP.
%___________________________________________________________________________
\hypertarget{little-endian}{}
\pdfbookmark[1]{6.2~~~little-endian}{little-endian}
\subsection*{6.2~~~little-endian}
\label{little-endian}
Binary values stored with the most significant byte at the highest memory
address.
\textbf{Little End First}.
\href{http://en.wikipedia.org/wiki/Endianness}{http://en.wikipedia.org/wiki/Endianness} for more details.
This is the common Intel architecture form, and \href{\#usage}{USAGE} clauses
of COMPUTATIONAL-5, BINARY-CHAR, BINARY-SHORT, BINARY-LONG, BINARY-DOUBLE
are a true performance boost on this hardware. See
\href{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.
%___________________________________________________________________________
\hypertarget{ascii}{}
\pdfbookmark[1]{6.3~~~ASCII}{ascii}
\subsection*{6.3~~~ASCII}
\label{ascii}
American Symbolic Code for Information Interchange.
The character encoding common to personal computers and the Internet Age,
therefore OpenCOBOL. OpenCOBOL also supports the \href{\#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
\href{http://en.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange}{http://en.wikipedia.org/wiki/American{\_}Standard{\_}Code{\_}for{\_}Information{\_}Interchange}
for more info.
\begin{center}\begin{sffamily}
\fbox{\parbox{\admonitionwidth}{
\textbf{\large Attention!}
\vspace{2mm}
Unicode?
}}
\end{sffamily}
\end{center}
%___________________________________________________________________________
\hypertarget{currency-symbol}{}
\pdfbookmark[1]{6.4~~~currency symbol}{currency-symbol}
\subsection*{6.4~~~currency symbol}
\label{currency-symbol}
COBOL allows a SPECIAL NAMES clause that determines the currency symbol. This
effects both source codes and input/output \href{\#picture}{PICTURE} definitions.
\begin{quote}{\ttfamily \raggedright \noindent
CONFIGURATION~SECTION.~\\
SPECIAL~NAMES.~\\
CURRENCY~SIGN~IS~"{\#}".
}\end{quote}
%___________________________________________________________________________
\hypertarget{dso}{}
\pdfbookmark[1]{6.5~~~DSO}{dso}
\subsection*{6.5~~~DSO}
\label{dso}
Dynamic Shared Objects.
Similar to but subtlet different from \emph{share libraries}.
%___________________________________________________________________________
\hypertarget{errno}{}
\pdfbookmark[1]{6.6~~~errno}{errno}
\subsection*{6.6~~~errno}
\label{errno}
OpenCOBOL and C are fairly closely related as OpenCOBOL produces
intermediate C source code and passes this off to another compiler.
Some C functions had no easy way to report out-of-bound errors so
a global int \textbf{errno} is defined in the standard C library as a
thread safe variable. Conscientious programmers will reset and test
this variable for any and all functions documented as setting \textbf{errno}.
This is not straight forward for OpenCOBOL, but a small wrapper along
the lines of
\begin{quote}{\ttfamily \raggedright \noindent
/*~set/get~errno~*/~\\
~\\
{\#}include~~\\
~\\
int~reset{\_}errno()~{\{}~\\
~~~~errno~=~0;~\\
~~~~return~errno;~\\
{\}}~\\
~\\
int~get{\_}errno()~{\{}~\\
~~~~return~errno;~\\
{\}}~\\
/**/
}\end{quote}
exposes this critical run-time variable.
Usage:
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~cobc~-c~geterrno.c~\\
{\$}~cobc~-x~program.cob~geterrno.o
}\end{quote}
and then something like
\begin{quote}{\ttfamily \raggedright \noindent
CALL~"reset{\_}errno"~END-CALL~\\
MOVE~FUNCTION~SQRT(-1)~TO~root~\\
CALL~"get{\_}errno"~RETURNING~result~END-CALL~\\
IF~result~NOT~EQUAL~ZERO~\\
~~~CALL~"perror"~USING~NULL~END-CALL~\\
END-IF
}\end{quote}
Outputs:
\begin{quote}{\ttfamily \raggedright \noindent
Numerical~argument~out~of~domain
}\end{quote}
%___________________________________________________________________________
\hypertarget{gdb}{}
\pdfbookmark[1]{6.7~~~gdb}{gdb}
\subsection*{6.7~~~gdb}
\label{gdb}
The GNU symbolic debugger. Big, deep, wide.
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~info~gdb~for~the~details.
}\end{quote}
or visit \href{http://www.gnu.org/software/gdb/documentation/}{http://www.gnu.org/software/gdb/documentation/}
%___________________________________________________________________________
\hypertarget{gmp}{}
\pdfbookmark[1]{6.8~~~GMP}{gmp}
\subsection*{6.8~~~GMP}
\label{gmp}
GNU MP libgmp. GNU Library for decimal arithmetic. See \href{http://gmplib.org/}{http://gmplib.org/}
for complete details on the library advertised as
\emph{Arithmetic without limitations}.
%___________________________________________________________________________
\hypertarget{isam}{}
\pdfbookmark[1]{6.9~~~ISAM}{isam}
\subsection*{6.9~~~ISAM}
\label{isam}
Indexed Sequential Access Method. A system to allow a variety of access
methods for data records in file storage.
See \href{http://en.wikipedia.org/wiki/ISAM}{http://en.wikipedia.org/wiki/ISAM} for more details.
%___________________________________________________________________________
\hypertarget{line-sequential}{}
\pdfbookmark[1]{6.10~~~line sequential}{line-sequential}
\subsection*{6.10~~~line sequential}
\label{line-sequential}
An access method for newline terminated files. OpenCOBOL reads each line
and strips off carriage returns and line feeds. Filling the record buffer
with the current line and padding with spaces.
%___________________________________________________________________________
\hypertarget{apt}{}
\pdfbookmark[1]{6.11~~~APT}{apt}
\subsection*{6.11~~~APT}
\label{apt}
Advanced Package Tool. One of the strengths of the Debian GNU/Linux
system. Allows for dependency checked binary packages.
%___________________________________________________________________________
\hypertarget{robodoc-support}{}
\pdfbookmark[1]{6.12~~~ROBODoc Support}{robodoc-support}
\subsection*{6.12~~~ROBODoc Support}
\label{robodoc-support}
Below is a sample of a configuration file for using ROBODoc with OpenCOBOL
programs.
\begin{quote}{\ttfamily \raggedright \noindent
{\#}~robodoc.rc~for~OpenCOBOL~\\
{\#}~\\
items:~\\
~~~~NAME~\\
~~~~AUTHOR~\\
~~~~DATE~\\
~~~~PURPOSE~\\
~~~~TECTONICS~\\
~~~~SYNOPSIS~\\
~~~~INPUTS~\\
~~~~OUTPUTS~\\
~~~~SIDE~EFFECTS~\\
~~~~HISTORY~\\
~~~~BUGS~\\
~~~~EXAMPLE~\\
~~~~SOURCE~\\
ignore~items:~\\
~~~~HISTORY~\\
~~~~BUGS~\\
item~order:~\\
~~~~PURPOSE~\\
~~~~SYNOPSIS~\\
~~~~INPUTS~\\
~~~~OUTPUTS~\\
source~items:~\\
~~~~SYNOPSIS~\\
preformatted~items:~\\
~~~~INPUTS~\\
~~~~OUTPUTS~\\
format~items:~\\
~~~~PURPOSE~\\
~~~~SIDE~EFFECTS~\\
options:~\\
{\#}~~~~-{}-src~./~\\
{\#}~~~~-{}-doc~./doc~\\
~~~~-{}-html~\\
~~~~-{}-syntaxcolors~\\
{\#}~~~~-{}-singledoc~\\
{\#}~~~-{}-multidoc~\\
~~~~-{}-index~\\
~~~~-{}-tabsize~4~\\
headertypes:~\\
~~~~J~~"Projects"~~~~~~~~~~robo{\_}projects~~~~2~\\
~~~~F~~"Files"~~~~~~~~~~~~~robo{\_}files~~~~~~~1~\\
~~~~e~~"Makefile~Entries"~~robo{\_}mk{\_}entries~\\
~~~~x~~"System~Tests"~~~~~~robo{\_}syst{\_}tests~\\
~~~~q~~Queries~~~~~~~~~~~~~robo{\_}queries~\\
ignore~files:~\\
~~~~README~\\
~~~~CVS~\\
~~~~*.bak~\\
~~~~*{\textasciitilde}~\\
~~~~"a~test{\_}*"~\\
accept~files:~\\
~~~~*.cob~\\
~~~~*.COB~\\
~~~~*.cbl~\\
~~~~*.CBL~\\
~~~~*.cpy~\\
~~~~*.CPY~\\
header~markers:~\\
~~~~*>****~\\
remark~markers:~\\
~~~~*>~\\
end~markers:~\\
~~~~*>****~\\
header~separate~characters:~\\
~~~~,~\\
header~ignore~characters:~\\
~~~~{[}~\\
remark~begin~markers:~\\
~~~~*>+~\\
remark~end~markers:~\\
~~~~*>-~\\
source~line~comments:~\\
~~~~*>~\\
{\#}~OpenCOBOL~keywords~*><*~\\
keywords:~\\
~~~~accept~\\
~~~~access~\\
~~~~active-class~\\
~~~~add~\\
~~~~address~\\
~~~~advancing~\\
~~~~after~\\
~~~~aligned~\\
~~~~all~\\
~~~~allocate~\\
~~~~alphabet~\\
~~~~alphabetic~\\
~~~~alphabetic-lower~\\
~~~~alphabetic-upper~\\
~~~~alphanumeric~\\
~~~~alphanumeric-edited~\\
~~~~also~\\
~~~~alter~\\
~~~~alternate~\\
~~~~and~\\
~~~~any~\\
~~~~anycase~\\
~~~~are~\\
~~~~area~\\
~~~~areas~\\
~~~~argument-number~\\
~~~~argument-value~\\
~~~~arithmetic~\\
~~~~as~\\
~~~~ascending~\\
~~~~assign~\\
~~~~at~\\
~~~~attribute~\\
~~~~auto~\\
~~~~auto-skip~\\
~~~~automatic~\\
~~~~autoterminate~\\
~~~~b-and~\\
~~~~b-not~\\
~~~~b-or~\\
~~~~b-xor~\\
~~~~background-color~\\
~~~~based~\\
~~~~beep~\\
~~~~before~\\
~~~~bell~\\
~~~~binary~\\
~~~~binary-c-long~\\
~~~~binary-char~\\
~~~~binary-double~\\
~~~~binary-long~\\
~~~~binary-short~\\
~~~~bit~\\
~~~~blank~\\
~~~~blink~\\
~~~~block~\\
~~~~boolean~\\
~~~~bottom~\\
~~~~by~\\
~~~~byte-length~\\
~~~~call~\\
~~~~cancel~\\
~~~~cd~\\
~~~~center~\\
~~~~cf~\\
~~~~ch~\\
~~~~chain~\\
~~~~chaining~\\
~~~~character~\\
~~~~characters~\\
~~~~class~\\
~~~~class-id~\\
~~~~classification~\\
~~~~close~\\
~~~~code~\\
~~~~code-set~\\
~~~~col~\\
~~~~collating~\\
~~~~cols~\\
~~~~column~\\
~~~~columns~\\
~~~~comma~\\
~~~~command-line~\\
~~~~commit~\\
~~~~common~\\
~~~~communication~\\
~~~~comp~\\
~~~~comp-1~\\
~~~~comp-2~\\
~~~~comp-3~\\
~~~~comp-4~\\
~~~~comp-5~\\
~~~~comp-x~\\
~~~~computational~\\
~~~~computational-1~\\
~~~~computational-2~\\
~~~~computational-3~\\
~~~~computational-4~\\
~~~~computational-5~\\
~~~~computational-x~\\
~~~~compute~\\
~~~~condition~\\
~~~~configuration~\\
~~~~constant~\\
~~~~contains~\\
~~~~content~\\
~~~~continue~\\
~~~~control~\\
~~~~controls~\\
~~~~converting~\\
~~~~copy~\\
~~~~corr~\\
~~~~corresponding~\\
~~~~count~\\
~~~~crt~\\
~~~~currency~\\
~~~~cursor~\\
~~~~cycle~\\
~~~~data~\\
~~~~data-pointer~\\
~~~~date~\\
~~~~day~\\
~~~~day-of-week~\\
~~~~de~\\
~~~~debugging~\\
~~~~decimal-point~\\
~~~~declaratives~\\
~~~~default~\\
~~~~delete~\\
~~~~delimited~\\
~~~~delimiter~\\
~~~~depending~\\
~~~~descending~\\
~~~~destination~\\
~~~~detail~\\
~~~~disable~\\
~~~~disk~\\
~~~~display~\\
~~~~divide~\\
~~~~division~\\
~~~~down~\\
~~~~duplicates~\\
~~~~dynamic~\\
~~~~ebcdic~\\
~~~~ec~\\
~~~~egi~\\
~~~~else~\\
~~~~emi~\\
~~~~enable~\\
~~~~end~\\
~~~~end-accept~\\
~~~~end-add~\\
~~~~end-call~\\
~~~~end-compute~\\
~~~~end-delete~\\
~~~~end-display~\\
~~~~end-divide~\\
~~~~end-evaluate~\\
~~~~end-if~\\
~~~~end-multiply~\\
~~~~end-of-page~\\
~~~~end-perform~\\
~~~~end-read~\\
~~~~end-receive~\\
~~~~end-return~\\
~~~~end-rewrite~\\
~~~~end-search~\\
~~~~end-start~\\
~~~~end-string~\\
~~~~end-subtract~\\
~~~~end-unstring~\\
~~~~end-write~\\
~~~~entry~\\
~~~~entry-convention~\\
~~~~environment~\\
~~~~environment-name~\\
~~~~environment-value~\\
~~~~eo~\\
~~~~eol~\\
~~~~eop~\\
~~~~eos~\\
~~~~equal~\\
~~~~equals~\\
~~~~erase~\\
~~~~error~\\
~~~~escape~\\
~~~~esi~\\
~~~~evaluate~\\
~~~~exception~\\
~~~~exception-object~\\
~~~~exclusive~\\
~~~~exit~\\
~~~~expands~\\
~~~~extend~\\
~~~~external~\\
~~~~factory~\\
~~~~false~\\
~~~~fd~\\
~~~~file~\\
~~~~file-control~\\
~~~~file-id~\\
~~~~filler~\\
~~~~final~\\
~~~~first~\\
~~~~float-extended~\\
~~~~float-long~\\
~~~~float-short~\\
~~~~footing~\\
~~~~for~\\
~~~~foreground-color~\\
~~~~forever~\\
~~~~format~\\
~~~~free~\\
~~~~from~\\
~~~~full~\\
~~~~function~\\
~~~~function-id~\\
~~~~generate~\\
~~~~get~\\
~~~~giving~\\
~~~~global~\\
~~~~go~\\
~~~~goback~\\
~~~~greater~\\
~~~~group~\\
~~~~group-usage~\\
~~~~heading~\\
~~~~high-value~\\
~~~~high-values~\\
~~~~highlight~\\
~~~~i-o~\\
~~~~i-o-control~\\
~~~~id~\\
~~~~identification~\\
~~~~if~\\
~~~~ignoring~\\
~~~~implements~\\
~~~~in~\\
~~~~index~\\
~~~~indexed~\\
~~~~indicate~\\
~~~~inherits~\\
~~~~initial~\\
~~~~initialize~\\
~~~~initialized~\\
~~~~initiate~\\
~~~~input~\\
~~~~input-output~\\
~~~~inspect~\\
~~~~interface~\\
~~~~interface-id~\\
~~~~into~\\
~~~~intrinsic~\\
~~~~invalid~\\
~~~~invoke~\\
~~~~is~\\
~~~~just~\\
~~~~justified~\\
~~~~key~\\
~~~~label~\\
~~~~last~\\
~~~~lc{\_}all~\\
~~~~lc{\_}collate~\\
~~~~lc{\_}ctype~\\
~~~~lc{\_}messages~\\
~~~~lc{\_}monetary~\\
~~~~lc{\_}numeric~\\
~~~~lc{\_}time~\\
~~~~leading~\\
~~~~left~\\
~~~~length~\\
~~~~less~\\
~~~~limit~\\
~~~~limits~\\
~~~~linage~\\
~~~~linage-counter~\\
~~~~line~\\
~~~~line-counter~\\
~~~~lines~\\
~~~~linkage~\\
~~~~local-storage~\\
~~~~locale~\\
~~~~lock~\\
~~~~low-value~\\
~~~~low-values~\\
~~~~lowlight~\\
~~~~manual~\\
~~~~memory~\\
~~~~merge~\\
~~~~message~\\
~~~~method~\\
~~~~method-id~\\
~~~~minus~\\
~~~~mode~\\
~~~~move~\\
~~~~multiple~\\
~~~~multiply~\\
~~~~national~\\
~~~~national-edited~\\
~~~~native~\\
~~~~negative~\\
~~~~nested~\\
~~~~next~\\
~~~~no~\\
~~~~none~\\
~~~~normal~\\
~~~~not~\\
~~~~null~\\
~~~~nulls~\\
~~~~number~\\
~~~~numbers~\\
~~~~numeric~\\
~~~~numeric-edited~\\
~~~~object~\\
~~~~object-computer~\\
~~~~object-reference~\\
~~~~occurs~\\
~~~~of~\\
~~~~off~\\
~~~~omitted~\\
~~~~on~\\
~~~~only~\\
~~~~open~\\
~~~~optional~\\
~~~~options~\\
~~~~or~\\
~~~~order~\\
~~~~organization~\\
~~~~other~\\
~~~~output~\\
~~~~overflow~\\
~~~~overline~\\
~~~~override~\\
~~~~packed-decimal~\\
~~~~padding~\\
~~~~page~\\
~~~~page-counter~\\
~~~~paragraph~\\
~~~~perform~\\
~~~~pf~\\
~~~~ph~\\
~~~~pic~\\
~~~~picture~\\
~~~~plus~\\
~~~~pointer~\\
~~~~position~\\
~~~~positive~\\
~~~~present~\\
~~~~previous~\\
~~~~printer~\\
~~~~printing~\\
~~~~procedure~\\
~~~~procedure-pointer~\\
~~~~procedures~\\
~~~~proceed~\\
~~~~program~\\
~~~~program-id~\\
~~~~program-pointer~\\
~~~~prompt~\\
~~~~property~\\
~~~~prototype~\\
~~~~purge~\\
~~~~queue~\\
~~~~quote~\\
~~~~quotes~\\
~~~~raise~\\
~~~~raising~\\
~~~~random~\\
~~~~rd~\\
~~~~read~\\
~~~~receive~\\
~~~~record~\\
~~~~recording~\\
~~~~records~\\
~~~~recursive~\\
~~~~redefines~\\
~~~~reel~\\
~~~~reference~\\
~~~~relation~\\
~~~~relative~\\
~~~~release~\\
~~~~remainder~\\
~~~~removal~\\
~~~~renames~\\
~~~~replace~\\
~~~~replacing~\\
~~~~report~\\
~~~~reporting~\\
~~~~reports~\\
~~~~repository~\\
~~~~required~\\
~~~~reserve~\\
~~~~reset~\\
~~~~resume~\\
~~~~retry~\\
~~~~return~\\
~~~~returning~\\
~~~~reverse-video~\\
~~~~rewind~\\
~~~~rewrite~\\
~~~~rf~\\
~~~~rh~\\
~~~~right~\\
~~~~rollback~\\
~~~~rounded~\\
~~~~run~\\
~~~~same~\\
~~~~screen~\\
~~~~sd~\\
~~~~search~\\
~~~~seconds~\\
~~~~section~\\
~~~~secure~\\
~~~~segment~\\
~~~~select~\\
~~~~self~\\
~~~~send~\\
~~~~sentence~\\
~~~~separate~\\
~~~~sequence~\\
~~~~sequential~\\
~~~~set~\\
~~~~sharing~\\
~~~~sign~\\
~~~~signed~\\
~~~~signed-int~\\
~~~~signed-long~\\
~~~~signed-short~\\
~~~~size~\\
~~~~sort~\\
~~~~sort-merge~\\
~~~~source~\\
~~~~source-computer~\\
~~~~sources~\\
~~~~space~\\
~~~~spaces~\\
~~~~special-names~\\
~~~~standard~\\
~~~~standard-1~\\
~~~~standard-2~\\
~~~~start~\\
~~~~statement~\\
~~~~status~\\
~~~~step~\\
~~~~stop~\\
~~~~string~\\
~~~~strong~\\
~~~~sub-queue-1~\\
~~~~sub-queue-2~\\
~~~~sub-queue-3~\\
~~~~subtract~\\
~~~~sum~\\
~~~~super~\\
~~~~suppress~\\
~~~~symbol~\\
~~~~symbolic~\\
~~~~sync~\\
~~~~synchronized~\\
~~~~system-default~\\
~~~~table~\\
~~~~tallying~\\
~~~~tape~\\
~~~~terminal~\\
~~~~terminate~\\
~~~~test~\\
~~~~text~\\
~~~~than~\\
~~~~then~\\
~~~~through~\\
~~~~thru~\\
~~~~time~\\
~~~~times~\\
~~~~to~\\
~~~~top~\\
~~~~trailing~\\
~~~~true~\\
~~~~type~\\
~~~~typedef~\\
~~~~ucs-4~\\
~~~~underline~\\
~~~~unit~\\
~~~~universal~\\
~~~~unlock~\\
~~~~unsigned~\\
~~~~unsigned-int~\\
~~~~unsigned-long~\\
~~~~unsigned-short~\\
~~~~unstring~\\
~~~~until~\\
~~~~up~\\
~~~~update~\\
~~~~upon~\\
~~~~usage~\\
~~~~use~\\
~~~~user-default~\\
~~~~using~\\
~~~~utf-16~\\
~~~~utf-8~\\
~~~~val-status~\\
~~~~valid~\\
~~~~validate~\\
~~~~validate-status~\\
~~~~value~\\
~~~~values~\\
~~~~varying~\\
~~~~when~\\
~~~~with~\\
~~~~working-storage~\\
~~~~write~\\
~~~~yyyyddd~\\
~~~~yyyymmdd~\\
~~~~zero~\\
~~~~zeroes~\\
~~~~zeros
}\end{quote}
To be used with
\begin{quote}{\ttfamily \raggedright \noindent
{\$}~robodoc~-{}-src~program.cob~-{}-doc~program~-{}-singlefile~-{}-rc~robocob.rc
}\end{quote}
Producing a nice HTML file documenting the program using embedded
ROBODoc comment line directives. See \href{http://www.xs4all.nl/~rfsber/Robo/robodoc.html}{ROBODoc} for more information.
%___________________________________________________________________________
\hypertarget{make-check-listing}{}
\pdfbookmark[1]{6.13~~~make check listing}{make-check-listing}
\subsection*{6.13~~~make check listing}
\label{make-check-listing}
A make check from February 2009:
\begin{quote}{\ttfamily \raggedright \noindent
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
{\#}{\#}~OpenCOBOL~1.1~test~suite:~Syntax~Tests.~{\#}{\#}~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
~~1:~COPY:~file~not~found~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~2:~COPY:~replacement~order~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~3:~COPY:~separators~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~4:~COPY:~partial~replacement~~~~~~~~~~~~~~~~~~~~ok~\\
~~5:~COPY:~recursive~replacement~~~~~~~~~~~~~~~~~~ok~\\
~~6:~Invalid~PROGRAM-ID~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~7:~Invalid~PROGRAM-ID~type~clause~(1)~~~~~~~~~~~ok~\\
~~8:~Invalid~PROGRAM-ID~type~clause~(2)~~~~~~~~~~~ok~\\
~~9:~Undefined~data~name~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~10:~Undefined~group~name~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~11:~Undefined~data~name~in~group~~~~~~~~~~~~~~~~~ok~\\
~12:~Reference~not~a~group~name~~~~~~~~~~~~~~~~~~~ok~\\
~13:~Incomplete~01~definition~~~~~~~~~~~~~~~~~~~~~ok~\\
~14:~Same~labels~in~different~sections~~~~~~~~~~~~ok~\\
~15:~Redefinition~of~01~items~~~~~~~~~~~~~~~~~~~~~ok~\\
~16:~Redefinition~of~01~and~02~items~~~~~~~~~~~~~~ok~\\
~17:~Redefinition~of~02~items~~~~~~~~~~~~~~~~~~~~~ok~\\
~18:~Redefinition~of~77~items~~~~~~~~~~~~~~~~~~~~~ok~\\
~19:~Redefinition~of~01~and~77~items~~~~~~~~~~~~~~ok~\\
~20:~Redefinition~of~88~items~~~~~~~~~~~~~~~~~~~~~ok~\\
~21:~Ambiguous~reference~to~02~items~~~~~~~~~~~~~~ok~\\
~22:~Ambiguous~reference~to~02~and~03~items~~~~~~~ok~\\
~23:~Ambiguous~reference~with~qualification~~~~~~~ok~\\
~24:~Unique~reference~with~ambiguous~qualifiers~~~ok~\\
~25:~Undefined~procedure~name~~~~~~~~~~~~~~~~~~~~~ok~\\
~26:~Redefinition~of~section~names~~~~~~~~~~~~~~~~ok~\\
~27:~Redefinition~of~section~and~paragraph~names~~ok~\\
~28:~Redefinition~of~paragraph~names~~~~~~~~~~~~~~ok~\\
~29:~Ambiguous~reference~to~paragraph~name~~~~~~~~ok~\\
~30:~Non-matching~level~numbers~(extension)~~~~~~~ok~\\
~31:~Ambiguous~AND/OR~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~32:~START~on~SEQUENTIAL~file~~~~~~~~~~~~~~~~~~~~~ok~\\
~33:~Subscripted~item~requires~OCCURS~clause~~~~~~ok~\\
~34:~The~number~of~subscripts~~~~~~~~~~~~~~~~~~~~~ok~\\
~35:~OCCURS~with~level~01,~66,~77,~and~88~~~~~~~~~ok~\\
~36:~OCCURS~with~variable-occurrence~data~item~~~~ok~\\
~37:~Nested~OCCURS~clause~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~38:~OCCURS~DEPENDING~followed~by~another~field~~~ok~\\
~39:~OCCURS~DEPENDING~without~TO~clause~~~~~~~~~~~ok~\\
~40:~REDEFINES:~not~following~entry-name~~~~~~~~~~ok~\\
~41:~REDEFINES:~level~02~by~01~~~~~~~~~~~~~~~~~~~~ok~\\
~42:~REDEFINES:~level~03~by~02~~~~~~~~~~~~~~~~~~~~ok~\\
~43:~REDEFINES:~level~66~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~44:~REDEFINES:~level~88~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~45:~REDEFINES:~lower~level~number~~~~~~~~~~~~~~~~ok~\\
~46:~REDEFINES:~with~OCCURS~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~47:~REDEFINES:~with~subscript~~~~~~~~~~~~~~~~~~~~ok~\\
~48:~REDEFINES:~with~variable~occurrence~~~~~~~~~~ok~\\
~49:~REDEFINES:~with~qualification~~~~~~~~~~~~~~~~ok~\\
~50:~REDEFINES:~multiple~redefinition~~~~~~~~~~~~~ok~\\
~51:~REDEFINES:~size~exceeds~~~~~~~~~~~~~~~~~~~~~~ok~\\
~52:~REDEFINES:~with~VALUE~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~53:~REDEFINES:~with~intervention~~~~~~~~~~~~~~~~~ok~\\
~54:~REDEFINES:~within~REDEFINES~~~~~~~~~~~~~~~~~~ok~\\
~55:~Numeric~item~(integer)~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~56:~Numeric~item~(non-integer)~~~~~~~~~~~~~~~~~~~ok~\\
~57:~Numeric~item~with~picture~P~~~~~~~~~~~~~~~~~~ok~\\
~58:~Signed~numeric~literal~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~59:~Alphabetic~item~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~60:~Alphanumeric~item~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~61:~Alphanumeric~group~item~~~~~~~~~~~~~~~~~~~~~~ok~\\
~62:~Numeric-edited~item~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~63:~Alphanumeric-edited~item~~~~~~~~~~~~~~~~~~~~~ok~\\
~64:~MOVE~SPACE~TO~numeric~or~numeric-edited~item~ok~\\
~65:~MOVE~ZERO~TO~alphabetic~item~~~~~~~~~~~~~~~~~ok~\\
~66:~MOVE~alphabetic~TO~x~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~67:~MOVE~alphanumeric~TO~x~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~68:~MOVE~alphanumeric-edited~TO~x~~~~~~~~~~~~~~~~ok~\\
~69:~MOVE~numeric~(integer)~TO~x~~~~~~~~~~~~~~~~~~ok~\\
~70:~MOVE~numeric~(non-integer)~TO~x~~~~~~~~~~~~~~ok~\\
~71:~MOVE~numeric-edited~TO~x~~~~~~~~~~~~~~~~~~~~~ok~\\
~72:~Operands~must~be~groups~~~~~~~~~~~~~~~~~~~~~~ok~\\
~73:~MOVE:~misc~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~74:~Category~check~of~Format~1~~~~~~~~~~~~~~~~~~~ok~\\
~75:~Category~check~of~Format~2~~~~~~~~~~~~~~~~~~~ok~\\
~76:~Category~check~of~literals~~~~~~~~~~~~~~~~~~~ok~\\
~77:~SET:~misc~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
{\#}{\#}~Test~results.~{\#}{\#}~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
~\\
All~77~tests~were~successful.~\\
PASS:~./syntax~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
{\#}{\#}~OpenCOBOL~1.1~test~suite:~Run~Tests.~{\#}{\#}~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
~~1:~DISPLAY~literals~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~2:~DISPLAY~literals,~DECIMAL-POINT~is~COMMA~~~~~ok~\\
~~3:~Hexadecimal~literal~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~4:~DISPLAY~data~items~with~VALUE~clause~~~~~~~~~ok~\\
~~5:~DISPLAY~data~items~with~MOVE~statement~~~~~~~ok~\\
~~6:~GLOBAL~at~same~level~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~7:~GLOBAL~at~lower~level~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~8:~non-numeric~subscript~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~9:~The~range~of~subscripts~~~~~~~~~~~~~~~~~~~~~~ok~\\
~10:~Subscript~out~of~bounds~(1)~~~~~~~~~~~~~~~~~~ok~\\
~11:~Subscript~out~of~bounds~(2)~~~~~~~~~~~~~~~~~~ok~\\
~12:~Value~of~DEPENDING~ON~N~out~of~bounds~(lower)ok~\\
~13:~Value~of~DEPENDING~ON~N~out~of~bounds~(upper)ok~\\
~14:~Subscript~bounds~with~ODO~(lower)~~~~~~~~~~~~ok~\\
~15:~Subscript~bounds~with~ODO~(upper)~~~~~~~~~~~~ok~\\
~16:~Subscript~bounds~with~ODO~~~~~~~~~~~~~~~~~~~~ok~\\
~17:~Subscript~by~arithmetic~expression~~~~~~~~~~~ok~\\
~18:~Separate~sign~positions~~~~~~~~~~~~~~~~~~~~~~ok~\\
~19:~Static~reference~modification~~~~~~~~~~~~~~~~ok~\\
~20:~Dynamic~reference~modification~~~~~~~~~~~~~~~ok~\\
~21:~Static~out~of~bounds~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~22:~Offset~underflow~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~23:~Offset~overflow~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~24:~Length~underflow~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~25:~Length~overflow~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~26:~ACCEPT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~27:~INITIALIZE~group~entry~with~OCCURS~~~~~~~~~~~ok~\\
~28:~INITIALIZE~OCCURS~with~numeric~edited~~~~~~~~ok~\\
~29:~INITIALIZE~complex~group~(1)~~~~~~~~~~~~~~~~~ok~\\
~30:~INITIALIZE~complex~group~(2)~~~~~~~~~~~~~~~~~ok~\\
~31:~INITIALIZE~with~REDEFINES~~~~~~~~~~~~~~~~~~~~ok~\\
~32:~Source~file~not~found~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~33:~Comma~separator~without~space~~~~~~~~~~~~~~~~ok~\\
~34:~LOCAL-STORAGE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~35:~EXTERNAL~data~item~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~36:~EXTERNAL~AS~data~item~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~37:~cobcrun~validation~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~38:~MOVE~to~itself~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~39:~MOVE~with~refmod~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~40:~MOVE~with~refmod~(variable)~~~~~~~~~~~~~~~~~~ok~\\
~41:~MOVE~with~group~refmod~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~42:~MOVE~indexes~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~43:~MOVE~X'00'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~44:~Level~01~subscripts~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~45:~Class~check~with~reference~modification~~~~~~ok~\\
~46:~Index~and~parenthesized~expression~~~~~~~~~~~ok~\\
~47:~Alphanumeric~and~binary~numeric~~~~~~~~~~~~~~ok~\\
~48:~Dynamic~call~with~static~linking~~~~~~~~~~~~~ok~\\
~49:~CALL~m1.~CALL~m2.~CALL~m1.~~~~~~~~~~~~~~~~~~~ok~\\
~50:~CALL~binary~literal~parameter/LENGTH~OF~~~~~~ok~\\
~51:~INSPECT~REPLACING~LEADING~ZEROS~BY~SPACES~~~~ok~\\
~52:~INSPECT:~No~repeat~conversion~check~~~~~~~~~~ok~\\
~53:~INSPECT:~REPLACING~figurative~constant~~~~~~~ok~\\
~54:~INSPECT:~TALLYING~BEFORE~~~~~~~~~~~~~~~~~~~~~ok~\\
~55:~INSPECT:~TALLYING~AFTER~~~~~~~~~~~~~~~~~~~~~~ok~\\
~56:~INSPECT~REPLACING~TRAILING~ZEROS~BY~SPACES~~~ok~\\
~57:~INSPECT~REPLACING~complex~~~~~~~~~~~~~~~~~~~~ok~\\
~58:~SWITCHES~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~59:~Nested~PERFORM~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~60:~EXIT~PERFORM~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~61:~EXIT~PERFORM~CYCLE~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~62:~EXIT~PARAGRAPH~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~63:~EXIT~SECTION~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~64:~88~with~FILLER~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~65:~Non-overflow~after~overflow~~~~~~~~~~~~~~~~~~ok~\\
~66:~PERFORM~...~CONTINUE~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~67:~STRING~with~subscript~reference~~~~~~~~~~~~~~ok~\\
~68:~UNSTRING~DELIMITED~ALL~LOW-VALUE~~~~~~~~~~~~~ok~\\
~69:~READ~INTO~AT-END~sequence~~~~~~~~~~~~~~~~~~~~ok~\\
~70:~First~READ~on~empty~SEQUENTIAL~INDEXED~file~~ok~\\
~71:~REWRITE~a~RELATIVE~file~with~RANDOM~access~~~ok~\\
~72:~SORT:~table~sort~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~73:~SORT:~EBCDIC~table~sort~~~~~~~~~~~~~~~~~~~~~~ok~\\
~74:~SORT~nonexistent~file~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~75:~PIC~ZZZ-,~ZZZ+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~76:~Larger~REDEFINES~lengths~~~~~~~~~~~~~~~~~~~~~ok~\\
~77:~PERFORM~type~OSVS~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~78:~Sticky~LINKAGE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~79:~COB{\_}PRE{\_}LOAD~test~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~80:~COB{\_}LOAD{\_}CASE=UPPER~test~~~~~~~~~~~~~~~~~~~~~ok~\\
~81:~88~level~with~FALSE~IS~clause~~~~~~~~~~~~~~~~ok~\\
~82:~ALLOCATE/FREE~with~BASED~item~~~~~~~~~~~~~~~~ok~\\
~83:~INITIZIALIZE~with~reference~modification~~~~~ok~\\
~84:~CALL~with~OMITTED~parameter~~~~~~~~~~~~~~~~~~ok~\\
~85:~ANY~LENGTH~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~86:~BASED~item~non-ALLOCATED~(debug)~~~~~~~~~~~~~ok~\\
~87:~COMP-5~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~88:~Hexadecimal~numeric~literal~~~~~~~~~~~~~~~~~~ok~\\
~89:~Semi-parenthesized~condition~~~~~~~~~~~~~~~~~ok~\\
~90:~ADDRESS~OF~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~91:~LENGTH~OF~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~92:~WHEN-COMPILED~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~93:~Complex~OCCURS~DEPENDING~ON~~~~~~~~~~~~~~~~~~ok~\\
~94:~MOVE~NON-INTEGER~TO~ALPHA-NUMERIC~~~~~~~~~~~~ok~\\
~95:~CALL~USING~file-name~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~96:~CALL~unusual~PROGRAM-ID.~~~~~~~~~~~~~~~~~~~~~ok~\\
~97:~Case~independent~PROGRAM-ID~~~~~~~~~~~~~~~~~~ok~\\
~98:~PROGRAM-ID~AS~clause~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~99:~Quoted~PROGRAM-ID~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
100:~ASSIGN~MF~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
101:~ASSIGN~IBM~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
102:~ASSIGN~mapping~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
103:~ASSIGN~expansion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
104:~ASSIGN~with~COB{\_}FILE{\_}PATH~~~~~~~~~~~~~~~~~~~~ok~\\
105:~NUMBER-OF-CALL-PARAMETERS~~~~~~~~~~~~~~~~~~~~ok~\\
106:~PROCEDURE~DIVISION~USING~BY~...~~~~~~~~~~~~~~ok~\\
107:~PROCEDURE~DIVISION~CHAINING~...~~~~~~~~~~~~~~ok~\\
108:~STOP~RUN~RETURNING~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
109:~ENTRY~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
110:~LINE~SEQUENTIAL~write~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
111:~LINE~SEQUENTIAL~read~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
112:~ASSIGN~to~KEYBOARD/DISPLAY~~~~~~~~~~~~~~~~~~~ok~\\
113:~Environment/Argument~variable~~~~~~~~~~~~~~~~ok~\\
114:~DECIMAL-POINT~is~COMMA~(1)~~~~~~~~~~~~~~~~~~~ok~\\
115:~DECIMAL-POINT~is~COMMA~(2)~~~~~~~~~~~~~~~~~~~ok~\\
116:~DECIMAL-POINT~is~COMMA~(3)~~~~~~~~~~~~~~~~~~~ok~\\
117:~DECIMAL-POINT~is~COMMA~(4)~~~~~~~~~~~~~~~~~~~ok~\\
118:~DECIMAL-POINT~is~COMMA~(5)~~~~~~~~~~~~~~~~~~~ok~\\
119:~78~Level~(1)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
120:~78~Level~(2)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
121:~78~Level~(3)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
122:~Unreachable~statement~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
123:~RETURN-CODE~moving~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
124:~RETURN-CODE~passing~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
125:~RETURN-CODE~nested~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
126:~FUNCTION~ABS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
127:~FUNCTION~ACOS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
128:~FUNCTION~ANNUITY~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
129:~FUNCTION~ASIN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
130:~FUNCTION~ATAN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
131:~FUNCTION~CHAR~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
132:~FUNCTION~COMBINED-DATETIME~~~~~~~~~~~~~~~~~~~ok~\\
133:~FUNCTION~CONCATENATE~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
134:~FUNCTION~CONCATENATE~with~reference~modding~~ok~\\
135:~FUNCTION~COS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
136:~FUNCTION~DATE-OF-INTEGER~~~~~~~~~~~~~~~~~~~~~ok~\\
137:~FUNCTION~DATE-TO-YYYYMMDD~~~~~~~~~~~~~~~~~~~~ok~\\
138:~FUNCTION~DAY-OF-INTEGER~~~~~~~~~~~~~~~~~~~~~~ok~\\
139:~FUNCTION~DAY-TO-YYYYDDD~~~~~~~~~~~~~~~~~~~~~~ok~\\
140:~FUNCTION~E~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
141:~FUNCTION~EXCEPTION-FILE~~~~~~~~~~~~~~~~~~~~~~ok~\\
142:~FUNCTION~EXCEPTION-LOCATION~~~~~~~~~~~~~~~~~~ok~\\
143:~FUNCTION~EXCEPTION-STATEMENT~~~~~~~~~~~~~~~~~ok~\\
144:~FUNCTION~EXCEPTION-STATUS~~~~~~~~~~~~~~~~~~~~ok~\\
145:~FUNCTION~EXP~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
146:~FUNCTION~FACTORIAL~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
147:~FUNCTION~FRACTION-PART~~~~~~~~~~~~~~~~~~~~~~~ok~\\
148:~FUNCTION~INTEGER~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
149:~FUNCTION~INTEGER-OF-DATE~~~~~~~~~~~~~~~~~~~~~ok~\\
150:~FUNCTION~INTEGER-OF-DAY~~~~~~~~~~~~~~~~~~~~~~ok~\\
151:~FUNCTION~INTEGER-PART~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
152:~FUNCTION~LENGTH~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
153:~FUNCTION~LOCALE-DATE~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
154:~FUNCTION~LOCALE-TIME~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
155:~FUNCTION~LOCALE-TIME-FROM-SECONDS~~~~~~~~~~~~ok~\\
156:~FUNCTION~LOG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
157:~FUNCTION~LOG10~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
158:~FUNCTION~LOWER-CASE~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
159:~FUNCTION~LOWER-CASE~with~reference~modding~~~ok~\\
160:~FUNCTION~MAX~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
161:~FUNCTION~MEAN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
162:~FUNCTION~MEDIAN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
163:~FUNCTION~MIDRANGE~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
164:~FUNCTION~MIN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
165:~FUNCTION~MOD~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
166:~FUNCTION~NUMVAL~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
167:~FUNCTION~NUMVAL-C~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
168:~FUNCTION~ORD~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
169:~FUNCTION~ORD-MAX~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
170:~FUNCTION~ORD-MIN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
171:~FUNCTION~PI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
172:~FUNCTION~PRESENT-VALUE~~~~~~~~~~~~~~~~~~~~~~~ok~\\
173:~FUNCTION~RANGE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
174:~FUNCTION~REM~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
175:~FUNCTION~REVERSE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
176:~FUNCTION~REVERSE~with~reference~modding~~~~~~ok~\\
177:~FUNCTION~SECONDS-FROM-FORMATTED-TIME~~~~~~~~~ok~\\
178:~FUNCTION~SECONDS-PAST-MIDNIGHT~~~~~~~~~~~~~~~ok~\\
179:~FUNCTION~SIGN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
180:~FUNCTION~SIN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
181:~FUNCTION~SQRT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
182:~FUNCTION~STANDARD-DEVIATION~~~~~~~~~~~~~~~~~~ok~\\
183:~FUNCTION~STORED-CHAR-LENGTH~~~~~~~~~~~~~~~~~~ok~\\
184:~FUNCTION~SUBSTITUTE~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
185:~FUNCTION~SUBSTITUTE~with~reference~modding~~~ok~\\
186:~FUNCTION~SUBSTITUTE-CASE~~~~~~~~~~~~~~~~~~~~~ok~\\
187:~FUNCTION~SUBSTITUTE-CASE~with~reference~mod~~ok~\\
188:~FUNCTION~TAN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
189:~FUNCTION~TRIM~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
190:~FUNCTION~TRIM~with~reference~modding~~~~~~~~~ok~\\
191:~FUNCTION~UPPER-CASE~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
192:~FUNCTION~UPPER-CASE~with~reference~modding~~~ok~\\
193:~FUNCTION~VARIANCE~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
194:~FUNCTION~WHEN-COMPILED~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
{\#}{\#}~Test~results.~{\#}{\#}~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
~\\
All~194~tests~were~successful.~\\
PASS:~./run~\\
~\\
{\#}{\#}~Run~time~tests~with~-O~option~{\#}{\#}~\\
~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
{\#}{\#}~OpenCOBOL~1.1~test~suite:~Run~Tests.~{\#}{\#}~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
~~1:~DISPLAY~literals~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~2:~DISPLAY~literals,~DECIMAL-POINT~is~COMMA~~~~~ok~\\
~~3:~Hexadecimal~literal~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~4:~DISPLAY~data~items~with~VALUE~clause~~~~~~~~~ok~\\
~~5:~DISPLAY~data~items~with~MOVE~statement~~~~~~~ok~\\
~~6:~GLOBAL~at~same~level~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~7:~GLOBAL~at~lower~level~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~8:~non-numeric~subscript~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~9:~The~range~of~subscripts~~~~~~~~~~~~~~~~~~~~~~ok~\\
~10:~Subscript~out~of~bounds~(1)~~~~~~~~~~~~~~~~~~ok~\\
~11:~Subscript~out~of~bounds~(2)~~~~~~~~~~~~~~~~~~ok~\\
~12:~Value~of~DEPENDING~ON~N~out~of~bounds~(lower)ok~\\
~13:~Value~of~DEPENDING~ON~N~out~of~bounds~(upper)ok~\\
~14:~Subscript~bounds~with~ODO~(lower)~~~~~~~~~~~~ok~\\
~15:~Subscript~bounds~with~ODO~(upper)~~~~~~~~~~~~ok~\\
~16:~Subscript~bounds~with~ODO~~~~~~~~~~~~~~~~~~~~ok~\\
~17:~Subscript~by~arithmetic~expression~~~~~~~~~~~ok~\\
~18:~Separate~sign~positions~~~~~~~~~~~~~~~~~~~~~~ok~\\
~19:~Static~reference~modification~~~~~~~~~~~~~~~~ok~\\
~20:~Dynamic~reference~modification~~~~~~~~~~~~~~~ok~\\
~21:~Static~out~of~bounds~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~22:~Offset~underflow~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~23:~Offset~overflow~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~24:~Length~underflow~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~25:~Length~overflow~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~26:~ACCEPT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~27:~INITIALIZE~group~entry~with~OCCURS~~~~~~~~~~~ok~\\
~28:~INITIALIZE~OCCURS~with~numeric~edited~~~~~~~~ok~\\
~29:~INITIALIZE~complex~group~(1)~~~~~~~~~~~~~~~~~ok~\\
~30:~INITIALIZE~complex~group~(2)~~~~~~~~~~~~~~~~~ok~\\
~31:~INITIALIZE~with~REDEFINES~~~~~~~~~~~~~~~~~~~~ok~\\
~32:~Source~file~not~found~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~33:~Comma~separator~without~space~~~~~~~~~~~~~~~~ok~\\
~34:~LOCAL-STORAGE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~35:~EXTERNAL~data~item~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~36:~EXTERNAL~AS~data~item~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~37:~cobcrun~validation~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~38:~MOVE~to~itself~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~39:~MOVE~with~refmod~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~40:~MOVE~with~refmod~(variable)~~~~~~~~~~~~~~~~~~ok~\\
~41:~MOVE~with~group~refmod~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~42:~MOVE~indexes~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~43:~MOVE~X'00'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~44:~Level~01~subscripts~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~45:~Class~check~with~reference~modification~~~~~~ok~\\
~46:~Index~and~parenthesized~expression~~~~~~~~~~~ok~\\
~47:~Alphanumeric~and~binary~numeric~~~~~~~~~~~~~~ok~\\
~48:~Dynamic~call~with~static~linking~~~~~~~~~~~~~ok~\\
~49:~CALL~m1.~CALL~m2.~CALL~m1.~~~~~~~~~~~~~~~~~~~ok~\\
~50:~CALL~binary~literal~parameter/LENGTH~OF~~~~~~ok~\\
~51:~INSPECT~REPLACING~LEADING~ZEROS~BY~SPACES~~~~ok~\\
~52:~INSPECT:~No~repeat~conversion~check~~~~~~~~~~ok~\\
~53:~INSPECT:~REPLACING~figurative~constant~~~~~~~ok~\\
~54:~INSPECT:~TALLYING~BEFORE~~~~~~~~~~~~~~~~~~~~~ok~\\
~55:~INSPECT:~TALLYING~AFTER~~~~~~~~~~~~~~~~~~~~~~ok~\\
~56:~INSPECT~REPLACING~TRAILING~ZEROS~BY~SPACES~~~ok~\\
~57:~INSPECT~REPLACING~complex~~~~~~~~~~~~~~~~~~~~ok~\\
~58:~SWITCHES~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~59:~Nested~PERFORM~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~60:~EXIT~PERFORM~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~61:~EXIT~PERFORM~CYCLE~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~62:~EXIT~PARAGRAPH~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~63:~EXIT~SECTION~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~64:~88~with~FILLER~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~65:~Non-overflow~after~overflow~~~~~~~~~~~~~~~~~~ok~\\
~66:~PERFORM~...~CONTINUE~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~67:~STRING~with~subscript~reference~~~~~~~~~~~~~~ok~\\
~68:~UNSTRING~DELIMITED~ALL~LOW-VALUE~~~~~~~~~~~~~ok~\\
~69:~READ~INTO~AT-END~sequence~~~~~~~~~~~~~~~~~~~~ok~\\
~70:~First~READ~on~empty~SEQUENTIAL~INDEXED~file~~ok~\\
~71:~REWRITE~a~RELATIVE~file~with~RANDOM~access~~~ok~\\
~72:~SORT:~table~sort~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~73:~SORT:~EBCDIC~table~sort~~~~~~~~~~~~~~~~~~~~~~ok~\\
~74:~SORT~nonexistent~file~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~75:~PIC~ZZZ-,~ZZZ+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~76:~Larger~REDEFINES~lengths~~~~~~~~~~~~~~~~~~~~~ok~\\
~77:~PERFORM~type~OSVS~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~78:~Sticky~LINKAGE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~79:~COB{\_}PRE{\_}LOAD~test~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~80:~COB{\_}LOAD{\_}CASE=UPPER~test~~~~~~~~~~~~~~~~~~~~~ok~\\
~81:~88~level~with~FALSE~IS~clause~~~~~~~~~~~~~~~~ok~\\
~82:~ALLOCATE/FREE~with~BASED~item~~~~~~~~~~~~~~~~ok~\\
~83:~INITIZIALIZE~with~reference~modification~~~~~ok~\\
~84:~CALL~with~OMITTED~parameter~~~~~~~~~~~~~~~~~~ok~\\
~85:~ANY~LENGTH~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~86:~BASED~item~non-ALLOCATED~(debug)~~~~~~~~~~~~~ok~\\
~87:~COMP-5~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~88:~Hexadecimal~numeric~literal~~~~~~~~~~~~~~~~~~ok~\\
~89:~Semi-parenthesized~condition~~~~~~~~~~~~~~~~~ok~\\
~90:~ADDRESS~OF~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~91:~LENGTH~OF~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~92:~WHEN-COMPILED~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~93:~Complex~OCCURS~DEPENDING~ON~~~~~~~~~~~~~~~~~~ok~\\
~94:~MOVE~NON-INTEGER~TO~ALPHA-NUMERIC~~~~~~~~~~~~ok~\\
~95:~CALL~USING~file-name~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~96:~CALL~unusual~PROGRAM-ID.~~~~~~~~~~~~~~~~~~~~~ok~\\
~97:~Case~independent~PROGRAM-ID~~~~~~~~~~~~~~~~~~ok~\\
~98:~PROGRAM-ID~AS~clause~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~99:~Quoted~PROGRAM-ID~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
100:~ASSIGN~MF~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
101:~ASSIGN~IBM~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
102:~ASSIGN~mapping~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
103:~ASSIGN~expansion~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
104:~ASSIGN~with~COB{\_}FILE{\_}PATH~~~~~~~~~~~~~~~~~~~~ok~\\
105:~NUMBER-OF-CALL-PARAMETERS~~~~~~~~~~~~~~~~~~~~ok~\\
106:~PROCEDURE~DIVISION~USING~BY~...~~~~~~~~~~~~~~ok~\\
107:~PROCEDURE~DIVISION~CHAINING~...~~~~~~~~~~~~~~ok~\\
108:~STOP~RUN~RETURNING~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
109:~ENTRY~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
110:~LINE~SEQUENTIAL~write~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
111:~LINE~SEQUENTIAL~read~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
112:~ASSIGN~to~KEYBOARD/DISPLAY~~~~~~~~~~~~~~~~~~~ok~\\
113:~Environment/Argument~variable~~~~~~~~~~~~~~~~ok~\\
114:~DECIMAL-POINT~is~COMMA~(1)~~~~~~~~~~~~~~~~~~~ok~\\
115:~DECIMAL-POINT~is~COMMA~(2)~~~~~~~~~~~~~~~~~~~ok~\\
116:~DECIMAL-POINT~is~COMMA~(3)~~~~~~~~~~~~~~~~~~~ok~\\
117:~DECIMAL-POINT~is~COMMA~(4)~~~~~~~~~~~~~~~~~~~ok~\\
118:~DECIMAL-POINT~is~COMMA~(5)~~~~~~~~~~~~~~~~~~~ok~\\
119:~78~Level~(1)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
120:~78~Level~(2)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
121:~78~Level~(3)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
122:~Unreachable~statement~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
123:~RETURN-CODE~moving~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
124:~RETURN-CODE~passing~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
125:~RETURN-CODE~nested~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
126:~FUNCTION~ABS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
127:~FUNCTION~ACOS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
128:~FUNCTION~ANNUITY~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
129:~FUNCTION~ASIN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
130:~FUNCTION~ATAN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
131:~FUNCTION~CHAR~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
132:~FUNCTION~COMBINED-DATETIME~~~~~~~~~~~~~~~~~~~ok~\\
133:~FUNCTION~CONCATENATE~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
134:~FUNCTION~CONCATENATE~with~reference~modding~~ok~\\
135:~FUNCTION~COS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
136:~FUNCTION~DATE-OF-INTEGER~~~~~~~~~~~~~~~~~~~~~ok~\\
137:~FUNCTION~DATE-TO-YYYYMMDD~~~~~~~~~~~~~~~~~~~~ok~\\
138:~FUNCTION~DAY-OF-INTEGER~~~~~~~~~~~~~~~~~~~~~~ok~\\
139:~FUNCTION~DAY-TO-YYYYDDD~~~~~~~~~~~~~~~~~~~~~~ok~\\
140:~FUNCTION~E~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
141:~FUNCTION~EXCEPTION-FILE~~~~~~~~~~~~~~~~~~~~~~ok~\\
142:~FUNCTION~EXCEPTION-LOCATION~~~~~~~~~~~~~~~~~~ok~\\
143:~FUNCTION~EXCEPTION-STATEMENT~~~~~~~~~~~~~~~~~ok~\\
144:~FUNCTION~EXCEPTION-STATUS~~~~~~~~~~~~~~~~~~~~ok~\\
145:~FUNCTION~EXP~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
146:~FUNCTION~FACTORIAL~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
147:~FUNCTION~FRACTION-PART~~~~~~~~~~~~~~~~~~~~~~~ok~\\
148:~FUNCTION~INTEGER~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
149:~FUNCTION~INTEGER-OF-DATE~~~~~~~~~~~~~~~~~~~~~ok~\\
150:~FUNCTION~INTEGER-OF-DAY~~~~~~~~~~~~~~~~~~~~~~ok~\\
151:~FUNCTION~INTEGER-PART~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
152:~FUNCTION~LENGTH~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
153:~FUNCTION~LOCALE-DATE~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
154:~FUNCTION~LOCALE-TIME~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
155:~FUNCTION~LOCALE-TIME-FROM-SECONDS~~~~~~~~~~~~ok~\\
156:~FUNCTION~LOG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
157:~FUNCTION~LOG10~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
158:~FUNCTION~LOWER-CASE~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
159:~FUNCTION~LOWER-CASE~with~reference~modding~~~ok~\\
160:~FUNCTION~MAX~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
161:~FUNCTION~MEAN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
162:~FUNCTION~MEDIAN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
163:~FUNCTION~MIDRANGE~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
164:~FUNCTION~MIN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
165:~FUNCTION~MOD~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
166:~FUNCTION~NUMVAL~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
167:~FUNCTION~NUMVAL-C~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
168:~FUNCTION~ORD~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
169:~FUNCTION~ORD-MAX~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
170:~FUNCTION~ORD-MIN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
171:~FUNCTION~PI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
172:~FUNCTION~PRESENT-VALUE~~~~~~~~~~~~~~~~~~~~~~~ok~\\
173:~FUNCTION~RANGE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
174:~FUNCTION~REM~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
175:~FUNCTION~REVERSE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
176:~FUNCTION~REVERSE~with~reference~modding~~~~~~ok~\\
177:~FUNCTION~SECONDS-FROM-FORMATTED-TIME~~~~~~~~~ok~\\
178:~FUNCTION~SECONDS-PAST-MIDNIGHT~~~~~~~~~~~~~~~ok~\\
179:~FUNCTION~SIGN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
180:~FUNCTION~SIN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
181:~FUNCTION~SQRT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
182:~FUNCTION~STANDARD-DEVIATION~~~~~~~~~~~~~~~~~~ok~\\
183:~FUNCTION~STORED-CHAR-LENGTH~~~~~~~~~~~~~~~~~~ok~\\
184:~FUNCTION~SUBSTITUTE~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
185:~FUNCTION~SUBSTITUTE~with~reference~modding~~~ok~\\
186:~FUNCTION~SUBSTITUTE-CASE~~~~~~~~~~~~~~~~~~~~~ok~\\
187:~FUNCTION~SUBSTITUTE-CASE~with~reference~mod~~ok~\\
188:~FUNCTION~TAN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
189:~FUNCTION~TRIM~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
190:~FUNCTION~TRIM~with~reference~modding~~~~~~~~~ok~\\
191:~FUNCTION~UPPER-CASE~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
192:~FUNCTION~UPPER-CASE~with~reference~modding~~~ok~\\
193:~FUNCTION~VARIANCE~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
194:~FUNCTION~WHEN-COMPILED~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
{\#}{\#}~Test~results.~{\#}{\#}~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
~\\
All~194~tests~were~successful.~\\
PASS:~./run-O~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
{\#}{\#}~OpenCOBOL~1.1~test~suite:~Data~Representation.~{\#}{\#}~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
~~1:~BINARY:~2-4-8~big-endian~~~~~~~~~~~~~~~~~~~~~ok~\\
~~2:~BINARY:~2-4-8~native~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~3:~BINARY:~1-2-4-8~big-endian~~~~~~~~~~~~~~~~~~~ok~\\
~~4:~BINARY:~1-2-4-8~native~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~5:~BINARY:~1-{}-8~big-endian~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~6:~BINARY:~1-{}-8~native~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~7:~BINARY:~full-print~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~8:~DISPLAY:~Sign~ASCII~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~9:~DISPLAY:~Sign~ASCII~(2)~~~~~~~~~~~~~~~~~~~~~~ok~\\
~10:~DISPLAY:~Sign~EBCDIC~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~11:~PACKED-DECIMAL~dump~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~12:~PACKED-DECIMAL~display~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~13:~PACKED-DECIMAL~move~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~14:~PACKED-DECIMAL~arithmetic~(1)~~~~~~~~~~~~~~~~ok~\\
~15:~PACKED-DECIMAL~arithmetic~(2)~~~~~~~~~~~~~~~~ok~\\
~16:~PACKED-DECIMAL~numeric~test~~~~~~~~~~~~~~~~~~ok~\\
~17:~POINTER:~display~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
{\#}{\#}~Test~results.~{\#}{\#}~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
~\\
All~17~tests~were~successful.~\\
PASS:~./data-rep~\\
~\\
{\#}{\#}~Data~representation~tests~with~-O~option~{\#}{\#}~\\
~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
{\#}{\#}~OpenCOBOL~1.1~test~suite:~Data~Representation.~{\#}{\#}~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
~~1:~BINARY:~2-4-8~big-endian~~~~~~~~~~~~~~~~~~~~~ok~\\
~~2:~BINARY:~2-4-8~native~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~3:~BINARY:~1-2-4-8~big-endian~~~~~~~~~~~~~~~~~~~ok~\\
~~4:~BINARY:~1-2-4-8~native~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~5:~BINARY:~1-{}-8~big-endian~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~6:~BINARY:~1-{}-8~native~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~7:~BINARY:~full-print~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~8:~DISPLAY:~Sign~ASCII~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~~9:~DISPLAY:~Sign~ASCII~(2)~~~~~~~~~~~~~~~~~~~~~~ok~\\
~10:~DISPLAY:~Sign~EBCDIC~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~11:~PACKED-DECIMAL~dump~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~12:~PACKED-DECIMAL~display~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~13:~PACKED-DECIMAL~move~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~14:~PACKED-DECIMAL~arithmetic~(1)~~~~~~~~~~~~~~~~ok~\\
~15:~PACKED-DECIMAL~arithmetic~(2)~~~~~~~~~~~~~~~~ok~\\
~16:~PACKED-DECIMAL~numeric~test~~~~~~~~~~~~~~~~~~ok~\\
~17:~POINTER:~display~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ok~\\
~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
{\#}{\#}~Test~results.~{\#}{\#}~\\
{\#}{\#}~-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-~{\#}{\#}~\\
~\\
All~17~tests~were~successful.~\\
PASS:~./data-rep-O~\\
==================~\\
All~5~tests~passed~\\
==================
}\end{quote}
%___________________________________________________________________________
\hypertarget{authors}{}
\pdfbookmark[0]{7~~~Authors}{authors}
\section*{7~~~Authors}
\label{authors}
\begin{figure}[b]\hypertarget{keisuke}[Keisuke]
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.
\end{figure}
\begin{figure}[b]\hypertarget{roger}[Roger]
Roger While
OpenCOBOL 1.1 is currently \emph{(February 2009)} in development, and Roger is the lead
programmer. From early 2004 up till today, and tomorrow, Roger has been very active on the
\href{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 \href{http://opencobol.org/}{opencobol.org}
OpenCOBOL forum.
\end{figure}
%___________________________________________________________________________
\hypertarget{maintainers-and-contributors}{}
\pdfbookmark[0]{8~~~Maintainers and Contributors}{maintainers-and-contributors}
\section*{8~~~Maintainers and Contributors}
\label{maintainers-and-contributors}
\begin{figure}[b]\hypertarget{btiffin}[btiffin]
Brian Tiffin
Initial FAQ. sample programs for OpenCOBOL 1.1.
\end{figure}
\begin{figure}[b]\hypertarget{aoirthoir}[aoirthoir]
Joseph James Frantz
Hosting, support.
\end{figure}
\begin{figure}[b]\hypertarget{jrls-swla}[jrls{\_}swla]
John Ellis
Samples and how-to's and ...
\end{figure}
\begin{figure}[b]\hypertarget{human}[human]
human
Samples and style
\end{figure}
%___________________________________________________________________________
\hypertarget{changelog}{}
\pdfbookmark[0]{9~~~ChangeLog}{changelog}
\section*{9~~~ChangeLog}
\label{changelog}
\begin{description}
\item[{02-Jul-2008, 06-Jul-2008, 07-Jul-2008, 11-Jul-2008, 13-Jul-2008}] \leavevmode
Experimental version for comment.
First 0.0 pre-alpha release.
Second 0.0 pre-alpha.
Last 0.0 pre-alpha. Checked in for diffs.
Last-last 0.0 pre-alpha. Verify DIFF functionality.
\item[{17-Jul-2008, 20-Jul-2008, 24-Jul-2008, 28-Jul-2008}] \leavevmode
Last-last-last 0.0 pre-alpha. Second DIFF.
Corrections pass.
Expanded the SCREEN SECTION questions.
Another correction pass, with clarifications from Roger While
\item[{10-Aug-2008, 21-Aug-2008, 28-Aug-2008, 29-Aug-2008, 30-Aug-2008}] \leavevmode
Started in on the intrinsic functions. Dropped the pre from the
alpha designation. Still some Look into this entries.
Move to add1tocobol.com
Publish link to 1.0rc
Skeleton of the reserved words list
Let the tweaking begin
\item[{23-Sep-2008}] \leavevmode
Adds and a trial skin
\item[{13-Oct-2008, 15-Oct-2008,19-Oct-2008, 22-Oct-2008, 29-Oct-2008}] \leavevmode
Added a few samples. Added TABLE SORT sample. Added configure
script information.
Added dialect configuration information.
\item[{28-Nov-2008}] \leavevmode
OpenCOBOL passes the NIST test suite.
\item[{12-Dec-2008, 16-Dec-2008, 21-Dec-2008}] \leavevmode
Added new links to OpenCOBOL 1.1 binary builds by Sergey.
Updated header templates.
Added a few keywords.
\item[{28-Dec-2008, 29-Dec-2008, 30-Dec-2008}] \leavevmode
Added info on CobXRef, some debugging tricks and an entry on recursion.
\item[{01-Jan-2009, 10-Jan-2009, 12-Jan-2009, 22-Jan-2009}] \leavevmode
Lame attempt at clarifying (excusing) poor use of Standards references.
Small corrections and additions to SQL entry.
Added a few RESERVED entries and Vincent's STOCK library expansion.
Typos.
\item[{02-Feb-2009, 06-Feb-2009, 09-Feb-2009, 11-Feb-2009}] \leavevmode
Coloured Source codes.
Added info on COB{\_}PRE{\_}LOAD, added LINAGE sample, fixed colours (kinda).
Added Haiku, disclaimer about no claim to Standards conformance.
Updated look.
\item[{16-Feb-2009, 18-Feb-2009}] \leavevmode
Added JavaScript, Lua, Guile embedding samples and mention Tcl/Tk, GTK.
Added CBL{\_}OC{\_}DUMP sample by Asger Kjelstrup and human
\item[{09-Mar-2009, 31-Mar-2009}] \leavevmode
Added Vala and a few more RESERVED word entries.
Added -ext clarification.
\item[{17-Apr-2009, 18-Apr-2009, 19-Apr-2009}] \leavevmode
Clarified -fsource-location option. Added a production use posting.
Added START and ISAM sample.
\item[{01-May-2009, 09-May-2009, 28-May-2009, 31-May-2009}] \leavevmode
Started a structural and TOC reorg. Mention S-Lang. Continue re-org.
Added some FUNCTION samples. Getting close to a complete Intrinsic list.
\item[{01-Jun-2009, 03-Jun-2009, 05-Jun-2009, 28-Jun-2009}] \leavevmode
Added errno, makefile, a few samples and some reserved word explanations.
Added filter.cob the stdin stdout sample.
Added some reserved word blurbs and the message queue sample.
human assisted corrections. Many thanks to human.
\item[{29-Jul-2009}] \leavevmode
more human assisted corrections.
\item[{13-Sep-2009}] \leavevmode
Some printing information.
\item[{12-Oct-2009}] \leavevmode
Added some links, credits.
\end{description}
% These are the external link substitutions.
% This section holds replacements and special symbols.
\end{document}