-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-prettyprint.cob
84 lines (71 loc) · 3.41 KB
/
02-prettyprint.cob
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
IDENTIFICATION DIVISION.
PROGRAM-ID. Pretty_Print.
****************************
DATA DIVISION.
WORKING-STORAGE SECTION.
01 personnel-record.
05 first-name PIC X(20) VALUE "Homer".
05 last-name PIC X(20) VALUE "Simpson".
05 street PIC X(20) VALUE "742 Evergreen Tce".
05 city PIC X(20) VALUE "Springfield".
05 department PIC X(20) VALUE "Safety".
05 salary PIC 9(7)v9(2) VALUE 362.19.
01 pretty-personnel-record.
05 FILLER PIC X VALUE x'0A'.
05 FILLER PIC X(20) VALUE "# Full name :".
05 first-name PIC X(20).
05 last-name PIC X(20).
05 FILLER PIC X VALUE x'0A'.
05 FILLER PIC X(20) VALUE "# Address :".
05 street PIC X(20).
05 FILLER PIC XX VALUE ", ".
05 city PIC X(20).
05 FILLER PIC X VALUE x'0A'.
05 FILLER PIC X(20) VALUE "# Department :".
05 department PIC X(20).
05 FILLER PIC X VALUE x'0A'.
05 FILLER PIC X(20) VALUE "# Salary :".
05 salary PIC Z(6)9.9(2) USAGE DISPLAY.
01 matrix.
02 matrix-row OCCURS 3.
03 matrix-column OCCURS 2.
05 matrix-entry PIC S9999v99 VALUE 0.
01 pretty-matrix.
02 FILLER PIC X VALUE x'0A'.
02 FILLER PIC X(21) VALUE "+- -+".
02 FILLER PIC X VALUE x'0A'.
02 p-matrix-row OCCURS 3.
03 FILLER PIC X VALUE "|".
03 FILLER VALUE SPACE.
03 p-matrix-column OCCURS 2.
05 p-matrix-entry PIC -ZZZ9.99 USAGE DISPLAY.
05 FILLER VALUE SPACE.
03 FILLER PIC X VALUE "|".
03 FILLER PIC X VALUE x'0A'.
02 FILLER PIC X(21) VALUE "+- -+".
****************************
PROCEDURE DIVISION.
MOVE CORRESPONDING personnel-record
TO pretty-personnel-record.
DISPLAY "[+] Shitty print: ".
DISPLAY " Personnel record: " personnel-record.
DISPLAY "[+] Pretty print: ".
DISPLAY " Personnel record: " pretty-personnel-record.
MOVE 1.1 TO matrix-entry(1,1).
MOVE 1.2 TO matrix-entry(1,2).
MOVE 2.1 TO matrix-entry(2,1).
MOVE 2.2 TO matrix-entry(2,2).
MOVE 3.1 TO matrix-entry(3,1).
MOVE 3.2 TO matrix-entry(3,2).
MOVE matrix-entry(1,1) TO p-matrix-entry(1,1).
MOVE matrix-entry(1,2) TO p-matrix-entry(1,2).
MOVE matrix-entry(2,1) TO p-matrix-entry(2,1).
MOVE matrix-entry(2,2) TO p-matrix-entry(2,2).
MOVE matrix-entry(3,1) TO p-matrix-entry(3,1).
MOVE matrix-entry(3,2) TO p-matrix-entry(3,2).
DISPLAY " --- "
DISPLAY "[++] Shitty print: ".
DISPLAY " Matrix: " matrix.
DISPLAY "[++] Pretty print: ".
DISPLAY " Matrix: " pretty-matrix.
STOP RUN.