Our Sample Programs
For the purposes of this documentation, we are using a very short hello.cbl
program as a reference.
(The program contains an ACCEPT FROM COMMAND-LINE
statement, to illustrate this functionality in cobcdb
).
To compile:
>cobc –g hello.cbl
>cobc –g subpgm.cbl
To run:
>cobcdb hello
or
To run with parameters:
>cobcdb hello hello-world
hello.cbl
000001 identification division.
000002 program-id. hello.
000003 environment division.
000004 data division.
000005 working-storage section.
000006 77 message-line pic x(11) value spaces.
000007 77 ws-dummy pic x value spaces.
000008 77 ctr pic 9(6) value 0.
000009 procedure division.
000010 main.
000011 accept message-line from command-line.
000012 if message-line not = spaces
000013 display message-line line 10 col 10
000014 else
000015 display "hello world" line 10 col 10
000016 end-if.
000017 perform para-1.
000018 display "returned from para-1" line 14 col 10.
000019 display "next line" line 16 col 10.
000020 accept ws-dummy line 16 col 30.
000021 stop run.
000022 para-1.
000023 move all "X" to message-line.
000024 display "in para-1" line 12 col 10.
000025 call "subpgm".
subpgm.cbl
000001 identification division.
000002 program-id. subpgm.
000003 environment division.
000004 data division.
000005 working-storage section.
000006 procedure division.
000007 main.
000008 display "In Subpgm" line 20 col 10.
000009 goback.