-
Notifications
You must be signed in to change notification settings - Fork 1
/
unstring.cbl
79 lines (58 loc) · 2.63 KB
/
unstring.cbl
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
identification division.
program-id. unstring-example.
data division.
working-storage section.
77 random-string pic x(15) value "123ABCDEFGHIJKL".
77 ch1 pic x(10).
77 ch2 pic x(10).
77 ch3 pic x(10).
77 delich1 pic x(3).
77 delich2 pic x(3).
77 delich3 pic x(3).
77 countch1 pic 9.
77 countch2 pic 9.
77 countch3 pic 9.
77 ptr pic 9 value 4.
77 countsplit pic 9.
77 today-date pic 9(8).
77 today-year pic 9(4).
77 today-month pic 99.
77 today-day pic 99.
procedure division.
*>******************************************
*> unstring using different delimiters *
*>******************************************
unstring
random-string delimited by all "ABC" or "GHI"
into ch1 delimiter in delich1 count in countch1
ch2 delimiter in delich2 count in countch2
ch3 delimiter in delich3 count in countch3
with pointer ptr
tallying in countsplit
on overflow display "Pointer too low/high"
"or not enough variables :("
end-unstring
display "Content 1 : " ch1 " (delimiter : " delich1
", size : " countch1 ")"
display "Content 2 : " ch2 " (delimiter : " delich2
", size : " countch2 ")"
display "Content 3 : " ch3 " (delimiter : " delich3
", size : " countch3 ")"
display "Split number : " countsplit
*> Content 1 : (delimiter : ABC, size : 0)
*> Content 2 : DEF (delimiter : GHI, size : 3)
*> Content 3 : JKL (delimiter : , size : 3)
*> Split number : 3
*>******************************************
*> unstring using recepting variables size *
*>******************************************
move function current-date(1:8) to today-date
unstring
today-date
into today-year
today-month
today-day
end-unstring
display "Today: " today-day "/" today-month "/" today-year
*> Today: 18/12/2014
goback.