-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_returns.pli
More file actions
52 lines (42 loc) · 1.06 KB
/
test_returns.pli
File metadata and controls
52 lines (42 loc) · 1.06 KB
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
/* Test program for RETURNS clause */
testret: proc options(main);
dcl x fixed bin(15);
dcl y fixed bin(15);
dcl z fixed bin(31);
dcl a char(5);
dcl b char(5);
dcl c char(10);
x = 5;
y = 10;
/* Call the function and capture return value */
z = myfunc(x);
put skip list('Result of myfunc(5):', z);
z = adder(x, y);
put skip list('Result of adder(5, 10):', z);
a = 'alfa ';
b = 'beta';
c = concater(a, b);
put skip list('Result of concater a + b :', c);
/* Function that doubles a number */
myfunc: proc(n) returns(fixed bin(31));
dcl n fixed bin(15);
dcl result fixed bin(31);
result = n * 2;
return(result);
end;
/* Function that adds two numbers */
adder: proc(a, b) returns(fixed bin(31));
dcl a fixed bin(15);
dcl b fixed bin(15);
dcl sum fixed bin(31);
sum = a + b;
return(sum);
end;
concater: proc(x, y) returns(char(10));
dcl x char(5);
dcl y char(5);
dcl z char(10);
z = x || y;
return(z);
end;
end testret;