Problem
How to convert cobol-mb (MicroBase) showing accessing copy books and using display at 01 01 syntax.
Resolution
Put the 01 01 into a variable.
01 display-cursor.
03 dc-line pic 99.
03 dc-column pic 99.
Then just use this in the procedure division.
move "0101" to display-prompt-line
display "my text" at display-cursor
Here is a example of the above display method and others combined with the usage of copy books showing COBCPY and COPYEXT
This has been tested with Oracle unix using bash.
For all programs and scripts needed for this example,
click the link and save as <2679886copy-001.tar>
Copy this onto a test area on your unix machine and untar it, see below. Change setup.sh to point at your cobol environment cobsetenv
This will compile and run the same program three times.
Program1.cbl
program-id. Program1 as "Program1".
environment division.
configuration section.
data division.
working-storage section.
01 display-cursor.
03 dc-line pic 99.
03 dc-column pic 99.
78 display-begin-line value 1.
78 display-header-line value display-begin-line.
78 display-header-column value display-begin-line.
77 display-prompt-line pic x(4) value "2301".
01 ans pic x.
01 i pic 999.
01 j pic 999.
01 k pic 999.
copy "displaystring".
78 display-string-length value length of display-string.
procedure division.
main section.
main-010.
*
* one way to control cursor position
*
move display-header-line to dc-line
move display-header-column to dc-column
display " In COB Program1:main"
line dc-line column dc-column
erase screen
perform init
perform work
perform fini
.
main-090.
copy "acceptanswer".
goback.
init section.
init-010.
display " In COB Program1:init"
line 1 col 1
.
init-090.
exit.
work section.
work-010.
move "0101" to display-prompt-line
display " In COB Program1:work"
at display-prompt-line
*
* Just show a bit of a loop
* 12 times table
*
move 6 to dc-line
move 10 to dc-column
copy "numberofiterations".
perform varying i from 1 by 1 until i > j
perform varying k from 1 by 1 until k > j
compute display-string = i * k
display display-string at display-cursor
compute dc-column =
dc-column display-string-length 1
end-perform
add 1 to dc-line
move 10 to dc-column
end-perform
.
work-090.
exit.
fini section.
fini-010.
display " In COB Program1:fini"
line 22 - 21 col 2 - 1
.
fini-090.
exit.
end program Program1.
This program will use different copy books from different locations each time it is compiled and run, changing the program behaviour.
Basically produces 6, 12 and 16 times table and prompt for user input on the last run of the test script.
testbuildandrun.sh. uses copy book numberofiterations that defines the times table to produce and the field width using the copy book displaystring.
It sets COBCPY to point to the copy book locations.
Sets a compiler directive to define the copy book extensions COPYEXT.
simply by setting this to NO or YES.
Sets which copy book acceptanswer to use see testbuildandrun.sh below.
Output
[tonyt@nwb-ora62sup ~]$ cd /home/tonyt/testtar
[tonyt@nwb-ora62sup testtar]$ ls
2679886copy-001.tar
[tonyt@nwb-ora62sup testtar]$ tar -xvf 2679886copy-001.tar
2679886copy/
2679886copy/bin/
2679886copy/bin/time6
2679886copy/bin/time12
2679886copy/bin/time16
2679886copy/source/
2679886copy/source/Program1.cbl
2679886copy/time6/
2679886copy/time6/displaystring
2679886copy/time6/numberofiterations
2679886copy/scripts/
2679886copy/scripts/testbuildandrun.sh
2679886copy/scripts/setup.sh
2679886copy/time12/
2679886copy/time12/numberofiterations.CPY
2679886copy/time12/displaystring.CPY
2679886copy/stop/
2679886copy/stop/acceptanswer.YES
2679886copy/stop/acceptanswer.NO
2679886copy/time16/
2679886copy/time16/numberofiterations.cpy
2679886copy/time16/displaystring.cpy
[tonyt@nwb-ora62sup testtar]$ ls
2679886copy 2679886copy-001.tar
[tonyt@nwb-ora62sup testtar]$ cd 2679886copy
[tonyt@nwb-ora62sup 2679886copy]$ ls
bin scripts source stop time12 time16 time6
[tonyt@nwb-ora62sup 2679886copy]$ cd scripts
[tonyt@nwb-ora62sup scripts]$ ls
setup.sh testbuildandrun.sh
[tonyt@nwb-ora62sup scripts]$ cat setup.sh
#!/bin/bash
#
java -version
#
# set up cobol environment variables
#
. /home/products/vcdevhub22/bin/cobsetenv
#
# save COBCPY
#
echo " COBCPY < $COBCPY >"
export SAVEDCOBCPY=$COBCPY
#
# end
#
[tonyt@nwb-ora62sup scripts]$ . ./setup.sh
java version "1.7.0_13"
Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot(TM) Server VM (build 23.7-b01, mixed mode)
COBDIR set to /home/products/vcdevhub22
COBCPY < /home/products/vcdevhub22/cpylib >
[tonyt@nwb-ora62sup scripts]$ cat testbuildandrun.sh
#!/bin/bash
#
export COBCPY="$SAVEDCOBCPY:../stop:../time6:"
echo "COBCPY < $COBCPY >"
rm ../bin/time6
cob -xvV -C "copyext(NO,,) sourceformat=variable list() showdir settings=col" ../source/Program1.cbl -o ../bin/time6
#
../bin/time6
#
export COBCPY="$SAVEDCOBCPY:../stop:../time12:"
echo "COBCPY < $COBCPY >"
rm ../bin/time12
cob -xvV -C "copyext(NO,CPY,) sourceformat=variable list() showdir settings=col" ../source/Program1.cbl -o ../bin/time12
#
../bin/time12
#
export COBCPY="$SAVEDCOBCPY:../stop:../time16:"
echo "COBCPY < $COBCPY >"
rm ../bin/time16
cob -xvV -C "copyext(YES,cpy,) sourceformat=variable list() showdir settings=col" ../source/Program1.cbl -o ../bin/time16
#
../bin/time16
#
# end
#[tonyt@nwb-ora62sup scripts]$ . ./testbuildandrun.sh
COBCPY < /home/products/vcdevhub22/cpylib:../stop:../time6: >
cob64 -C nolist -xvV -C copyext(NO,,) sourceformat=variable list() showdir settings=col ../source/Program1.cbl -o ../bin/time6
version @(#)cob.c 2.2.0.93
PRN=KXCRH/AAD:Ao.U4.13.04
PTI=32/64 bit
PTI=Micro Focus Visual COBOL Development Hub 2.2
PTI=pkg_77569
PTI=ES
PTI=SOA Configured
* Micro Focus COBOL V2.2 revision 000 Compiler
* Copyright (C) Micro Focus 1984-2013. All rights reserved.
* Accepted - verbose
* Accepted - nolist
* Accepted - copyext(NO,,)
* Accepted - sourceformat(variable)
* Accepted - list()
* Accepted - showdir
* Accepted - settings(col)
* Compiling ../source/Program1.cbl
* Total Messages: 0
* Data: 352 Code: 540
* Micro Focus COBOL Code Generator
* Copyright (C) Micro Focus 1984-2013. All rights reserved.
* Accepted - verbose
* Generating Program1
* Data: 120 Code: 1226 Literals: 112
Entry points defined in module: Program1.o
*Program1
In COB Program1:fini
1 2 3 4 5 6
2 4 6 8 10 12
3 6 9 12 15 18
4 8 12 16 20 24
5 10 15 20 25 30
6 12 18 24 30 36
COBCPY < /home/products/vcdevhub22/cpylib:../stop:../time12: >
cob64 -C nolist -xvV -C copyext(NO,CPY,) sourceformat=variable list() showdir settings=col ../source/Program1.cbl -o ../bin/time12
version @(#)cob.c 2.2.0.93
PRN=KXCRH/AAD:Ao.U4.13.04
PTI=32/64 bit
PTI=Micro Focus Visual COBOL Development Hub 2.2
PTI=pkg_77569
PTI=ES
PTI=SOA Configured
* Micro Focus COBOL V2.2 revision 000 Compiler
* Copyright (C) Micro Focus 1984-2013. All rights reserved.
* Accepted - verbose
* Accepted - nolist
* Accepted - copyext(NO,CPY,)
* Accepted - sourceformat(variable)
* Accepted - list()
* Accepted - showdir
* Accepted - settings(col)
* Compiling ../source/Program1.cbl
* Total Messages: 0
* Data: 352 Code: 541
* Micro Focus COBOL Code Generator
* Copyright (C) Micro Focus 1984-2013. All rights reserved.
* Accepted - verbose
* Generating Program1
* Data: 120 Code: 1237 Literals: 112
Entry points defined in module: Program1.o
*Program1
In COB Program1:fini
1 2 3 4 5 6 7 8 9 10 11 12
2 4 6 8 10 12 14 16 18 20 22 24
3 6 9 12 15 18 21 24 27 30 33 36
4 8 12 16 20 24 28 32 36 40 44 48
5 10 15 20 25 30 35 40 45 50 55 60
6 12 18 24 30 36 42 48 54 60 66 72
7 14 21 28 35 42 49 56 63 70 77 84
8 16 24 32 40 48 56 64 72 80 88 96
9 18 27 36 45 54 63 72 81 90 99 108
10 20 30 40 50 60 70 80 90 100 110 120
11 22 33 44 55 66 77 88 99 110 121 132
12 24 36 48 60 72 84 96 108 120 132 144
COBCPY < /home/products/vcdevhub22/cpylib:../stop:../time16: >
cob64 -C nolist -xvV -C copyext(YES,cpy,) sourceformat=variable list() showdir settings=col ../source/Program1.cbl -o ../bin/time16
version @(#)cob.c 2.2.0.93
PRN=KXCRH/AAD:Ao.U4.13.04
PTI=32/64 bit
PTI=Micro Focus Visual COBOL Development Hub 2.2
PTI=pkg_77569
PTI=ES
PTI=SOA Configured
* Micro Focus COBOL V2.2 revision 000 Compiler
* Copyright (C) Micro Focus 1984-2013. All rights reserved.
* Accepted - verbose
* Accepted - nolist
* Accepted - copyext(YES,cpy,)
* Accepted - sourceformat(variable)
* Accepted - list()
* Accepted - showdir
* Accepted - settings(col)
* Compiling ../source/Program1.cbl
* Total Messages: 0
* Data: 352 Code: 616
* Micro Focus COBOL Code Generator
* Copyright (C) Micro Focus 1984-2013. All rights reserved.
* Accepted - verbose
* Generating Program1
* Data: 120 Code: 1323 Literals: 160
Entry points defined in module: Program1.o
*Program1
In COB Program1:fini
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32
3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48
4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80
6 12 18 24 30 36 42 48 54 60 66 72 78 84 90 96
7 14 21 28 35 42 49 56 63 70 77 84 91 98 105 112
8 16 24 32 40 48 56 64 72 80 88 96 104 112 120 128
9 18 27 36 45 54 63 72 81 90 99 108 117 126 135 144
10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160
11 22 33 44 55 66 77 88 99 110 121 132 143 154 165 176
12 24 36 48 60 72 84 96 108 120 132 144 156 168 180 192
13 26 39 52 65 78 91 104 117 130 143 156 169 182 195 208
14 28 42 56 70 84 98 112 126 140 154 168 182 196 210 224
15 30 45 60 75 90 105 120 135 150 165 180 195 210 225 240
16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 256
press enter to continue...[ ]
COPYEXT is a directive not a environment variable.



