*=====================================================================
* RPG ILE MODULE CGIDEV2/MUSHROOMS
*
* CRTBNDRPG PGM(CGIDEV2/MUSHROOMS) SRCFILE(CGIDEV2/QRPGLESRC) DFTACTGRP(*NO)
* ACTGRP(MUSHROOMS) DBGVIEW(*SOURCE)
* To execute this program,
* enter the following in your WEB browser command line:
* http://.../cgidev2p/mushrooms.pgm
*
*=====================================================================
/copy CGIDEV2/qrpglesrc,hspecs
/copy CGIDEV2/qrpglesrc,hspecsbnd
FFUNGI if e k disk extfile('CGIDEV2/FUNGI')
*=====================================================================
* Includes to be used in all CGIs
*=====================================================================
/copy CGIDEV2/qrpglesrc,prototypeb
/copy CGIDEV2/qrpglesrc,usec
/copy CGIDEV2/qrpglesrc,variables3
*--------------------------------------------------------------------
* Variables to receive input string parameters
*--------------------------------------------------------------------
D xdiv1 s like(FNGDIV1)
D xdiv2 s like(FNGDIV2)
*--------------------------------------------------------------------
* Other program variables and constants
*--------------------------------------------------------------------
* External HTML
D extHtml s 2000 inz('/cgidev/html/mushrooms.txt')
* Indicators for GetHtmlIfsMult subprocedure
D IfsMultIndicators...
d ds
D NoErrors n
D NameTooLong n
D NotAccessible n
D NoFilesUsable n
D DupSections n
D FileIsEmpty n
*
D nbrRows s 10i 0
*=====================================================================
* Main line
*=====================================================================
/free
// Load external HTML
IfsMultIndicators=getHtmlIfsMult(%trim(exthtml):'«as400»');
// Get browser input
nbrVars=zhbgetinput(savedquerystring:qusec);
// Parse input variables
xdiv1=zhbGetVar('xdiv1');
xdiv2=zhbGetVar('xdiv2');
// Start output HTML
wrtsection('top');
// Select process
select;
when xdiv1=' ';
exsr Div1;
when xdiv1«»' ' and xdiv2=' ';
exsr Div2;
when xdiv1«»' ' and xdiv2«»' ';
exsr Div3;
other;
exsr Div1;
endsl;
wrtsection('divend');
// End HTML
wrtsection('Bottom');
// Send out the HTML buffer
wrtsection('*fini');
// End program
*inlr=*on;
return;
/end-free
*=====================================================================
* List mushroom main division
*=====================================================================
/free
Begsr Div1;
wrtsection('div1');
nbrRows=0;
fngdiv1=*loval;
setll fngdiv1 fngrcd;
read fngrcd;
dow not %eof;
if fngdiv1«»' ';
nbrRows+=1;
if nbrRows=1;
wrtsection('select1');
if xdiv2=' ';
wrtsection('selectoneof');
endif;
endif;
updhtmlvar('rownbr':%editc(nbrRows:'J'));
updhtmlvar('fngdiv1':FNGDIV1);
if xdiv1=FNGDIV1;
updhtmlvar('selected1':'selected');
else;
updhtmlvar('selected1':' ');
endif;
wrtsection('div1opt');
endif;
setgt fngdiv1 fngrcd;
read fngrcd;
enddo;
if nbrRows»0;
wrtsection('eoselect');
else;
wrtsection('nodata');
endif;
wrtsection('divxEnd');
Endsr;
/end-free
*=====================================================================
* List mushroom subdivision
*=====================================================================
/free
Begsr Div2;
exsr Div1;
updhtmlvar('xdiv1':xdiv1); //selected division
wrtsection('div2');
nbrRows=0;
fngdiv1=xdiv1;
fngdiv2=*loval;
setll fngdiv1 fngrcd;
reade fngdiv1 fngrcd;
dow not %eof;
if fngdiv1«»' ' and fngdiv2«»' ' and fngdiv3=' ';
nbrRows+=1;
if nbrRows=1;
wrtsection('select2');
if xdiv2=' ';
wrtsection('selectoneof');
endif;
endif;
updhtmlvar('rownbr':%editc(nbrRows:'J'));
updhtmlvar('fngdiv2':FNGDIV2);
if xdiv2=FNGDIV2;
updhtmlvar('selected2':'selected');
else;
updhtmlvar('selected2':' ');
endif;
wrtsection('div2opt');
endif;
reade fngdiv1 fngrcd;
enddo;
if nbrRows»0;
wrtsection('eoselect');
else;
wrtsection('nodata');
endif;
wrtsection('divxEnd');
Endsr;
/end-free
*=====================================================================
* List mushroom subdivision 3
*=====================================================================
/free
Begsr Div3;
exsr Div2;
updhtmlvar('xdiv1':xdiv1); //selected division
updhtmlvar('xdiv2':xdiv2); //selected subdivision
wrtsection('div3');
nbrRows=0;
fngdiv1=xdiv1;
fngdiv2=xdiv2;
setll (fngdiv1:fngdiv2) fngrcd;
reade (fngdiv1:fngdiv2) fngrcd;
dow not %eof;
if fngdiv1«»' ' and fngdiv2«»' ' and fngdiv3«»' ';
nbrRows+=1;
if nbrRows=1;
wrtsection('select3');
endif;
updhtmlvar('fngdiv3':FNGDIV3);
wrtsection('row3');
endif;
reade (fngdiv1:fngdiv2) fngrcd;
enddo;
if nbrRows=0;
wrtsection('row3None');
wrtsection('div3End');
endif;
wrtsection('div3End');
Endsr;
/end-free
|