1.00 |
********START OF PGM : HELLO **************************************** |
2.00 |
*================================================================ |
3.00 |
* |
4.00 |
* After compiling this module, create the program as follow: |
5.00 |
* |
6.00 |
* CRTPGM PGM(CGICBLDEV2/HELLO) MODULE(CGICBLDEV2/HELLO) |
7.00 |
* BNDDIR(CGICBLDEV2/CGICBLDEV2) ACTGRP(HELLO) |
8.00 |
* |
9.00 |
*================================================================ |
10.00 |
PROCESS NOXREF APOST |
11.00 |
ID DIVISION. |
12.00 |
PROGRAM-ID. HELLO. |
13.00 |
ENVIRONMENT DIVISION. |
14.00 |
CONFIGURATION SECTION. |
15.00 |
SPECIAL-NAMES. |
16.00 |
copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC. |
17.00 |
INPUT-OUTPUT SECTION. |
18.00 |
FILE-CONTROL. |
19.00 |
*================================================================= |
20.00 |
DATA DIVISION. |
21.00 |
FILE SECTION. |
22.00 |
*================================================================= |
23.00 |
WORKING-STORAGE SECTION. |
24.00 |
*================================================================= |
25.00 |
01 HTML-DATA. |
26.00 |
* Variables to execute a command |
27.00 |
05 rc PIC S9(9) comp-4. |
28.00 |
05 cmd PIC X(2000). |
29.00 |
* Variables to parse the input string |
30.00 |
05 varnamein PIC X(50). |
31.00 |
05 request PIC X(1000). |
32.00 |
05 firstname PIC X(1000). |
33.00 |
05 lastname PIC X(1000). |
34.00 |
* Variables to load external HTML |
35.00 |
05 fn PIC X(10) VALUE 'HTMLEXAMPL'. |
36.00 |
05 lib PIC X(10) VALUE 'CGICBLDEV2'. |
37.00 |
05 mbr PIC X(10) VALUE 'HELLO'. |
38.00 |
* Variable for QWrtSection procedure |
39.00 |
05 HtmlSects PIC X(1000). |
40.00 |
* Variables for QUpdHtmlVar procedure |
41.00 |
05 varnameout PIC X(30). |
42.00 |
05 varvalout PIC X(1000). |
43.00 |
*================================================================= |
44.00 |
* M A I N - L I N E |
45.00 |
*================================================================= |
46.00 |
PROCEDURE DIVISION. |
47.00 |
A-start-pgm. |
48.00 |
* Load the external HTML |
49.00 |
call 'QGETHTML' using fn lib mbr. |
50.00 |
* Write section "top" |
51.00 |
move 'top' to HtmlSects |
52.00 |
call 'QWRTSECTION' using HtmlSects. |
53.00 |
* Get input data from POST or GET |
54.00 |
call 'QZHBGETINPUT'. |
55.00 |
* Get input variable 'request' |
56.00 |
move 'request' to varnamein. |
57.00 |
call 'QZHBGETVARUPPER' using |
58.00 |
by content varnamein |
59.00 |
returning into request. |
60.00 |
* Two different processes, depending on the value of 'request' |
61.00 |
if request = ' ' |
62.00 |
perform Case1 thru z-Case1 |
63.00 |
else |
64.00 |
perform Case2 thru z-Case2 |
65.00 |
end-if. |
66.00 |
* Write section "end" and send the HTML buffer |
67.00 |
move 'end *fini' to HtmlSects |
68.00 |
call 'QWRTSECTION' using HtmlSects. |
69.00 |
*---------------------------------- |
70.00 |
B-end-pgm. |
71.00 |
exit program and continue run unit. |
72.00 |
*================================================================= |
73.00 |
* 'request' is blank. In this case the program asks the user |
74.00 |
* to enter his first and last names. |
75.00 |
* This is done by sending section /$case1 . |
76.00 |
Case1. |
77.00 |
move 'case1' to HtmlSects |
78.00 |
call 'QWRTSECTION' using HtmlSects. |
79.00 |
*---------------------------------- |
80.00 |
z-Case1. |
81.00 |
EXIT. |
82.00 |
*================================================================= |
83.00 |
* 'request' is not blank. In this case the program is receiving |
84.00 |
* the user input (first and last names). |
85.00 |
* The program must receive these input variables, |
86.00 |
* then substitute the output variables |
87.00 |
* and send section /$case2 . |
88.00 |
Case2. |
89.00 |
* Receive the input variable 'firstname' |
90.00 |
move 'firstname' to varnamein. |
91.00 |
call 'QZHBGETVAR' using |
92.00 |
by content varnamein |
93.00 |
returning into firstname. |
94.00 |
* Receive the input variable 'lastname' |
95.00 |
move 'lastname' to varnamein. |
96.00 |
call 'QZHBGETVAR' using |
97.00 |
by content varnamein |
98.00 |
returning into lastname. |
99.00 |
* Substitute the output variable /%firstname%/ |
100.00 |
move 'firstname' to varnameout |
101.00 |
move firstname to varvalout |
102.00 |
call 'QUPDHTMLVAR' using varnameout varvalout. |
103.00 |
* Substitute the output variable /%lastname%/ |
104.00 |
move 'lastname' to varnameout |
105.00 |
move lastname to varvalout |
106.00 |
call 'QUPDHTMLVAR' using varnameout varvalout. |
107.00 |
* Send section /$case2 . |
108.00 |
move 'case2' to HtmlSects |
109.00 |
call 'QWRTSECTION' using HtmlSects. |
110.00 |
*---------------------------------- |
111.00 |
z-Case2. |
112.00 |
EXIT. |
113.00 |
********* END OF PGM : HELLO **************************************** |