*=====================================================================
* RPG ILE MODULE CGIDEV2/CAPITALS
*
* CRTBNDRPG PGM(CGIDEV2/CAPITALS) SRCFILE(CGIDEV2/QRPGLESRC) DFTACTGRP(*NO)
* ACTGRP(CAPITALS) DBGVIEW(*SOURCE)
* To execute this program,
* enter the following in your WEB browser command line:
* http://.../cgidev2p/capitals.pgm
*
*=====================================================================
/copy CGIDEV2/qrpglesrc,hspecs
/copy CGIDEV2/qrpglesrc,hspecsbnd
FCAPITALS if e k disk usropn
F extfile('CGIDEV2/CAPITALS')
*=====================================================================
* 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 xcountry s like(CAPCTR)
D xavailWidth s 7
D xavailHeigth s 7
D xavailWidthN s 10i 0
D xavailHeigthN s 10i 0
*--------------------------------------------------------------------
* Other program variables and constants
*--------------------------------------------------------------------
* External HTML
D extHtml s 2000 inz('/cgidev/html/capitals.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 googleMapInd s n
D googleMapW s 10i 0
D googleMapH s 10i 0
*=====================================================================
* Main line
*=====================================================================
/free
// Load external HTML
IfsMultIndicators=getHtmlIfsMult(%trim(exthtml):'');
// Get browser input
nbrVars=zhbgetinput(savedquerystring:qusec);
// Parse input variables
xcountry=zhbGetVar('xcountry');
xavailWidth=zhbGetVar('availWidth'); // available screen width
xavailHeigth=zhbGetVar('availHeight'); // available screen size
if xavailWidth<>' ' and xavailHeigth<>' ';
xavailWidthN=c2n2(%trim(xavailWidth)); // convert available screen width to numeric
xavailHeigthN=c2n2(%trim(xavailHeigth)); // convert available screen height to numeric
endif;
// If needed, open database file
if not %open(CAPITALS);
open CAPITALS;
endif;
// If latitude and longitude available for the capital city of country "xcountry",
// set "googleMapInd" *on
googleMapInd=*off;
if xcountry<>' ';
chain xcountry caprcd;
if %found and caplat<>' ' and caplon<>' ';
googleMapInd=*on;
endif;
endif;
// Start output HTML
if googleMapInd=*on;
updhtmlvar('onload':'onLoad=GoogleMap()'); // onLoad to run google map function
else;
updhtmlvar('onload':'onLoad=avSizes()'); // onLoad to retrieve page sizes
endif;
wrtsection('top');
// Send out the dropdown list
capctr=*loval;
setll capctr caprcd;
read caprcd;
dow not %eof;
updhtmlvar('ycountry':capctr);
if capctr=xcountry;
updhtmlvar('selected':'selected'); // position the dropdown list on this entry
updhtmlvar('capctr':capctr);
updhtmlvar('capcity':capcity);
updhtmlvar('caplat':caplat);
updhtmlvar('caplon':caplon);
else;
updhtmlvar('selected':' ');
endif;
wrtsection('selectRow');
read caprcd;
enddo;
wrtsection('selectEnd');
// Send out information about the capital city of the selected country
if xcountry<>' ';
wrtsection('capital');
endif;
// If latitude and longitude available for the capital city of country "xcountry",
// display the google map for this capital city
if googleMapInd=*on;
if xavailWidthN |