Learn from sources
       Member CAPITALS in CGIDEV2 / QRPGLESRC

       *=====================================================================
       *  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)
       *--------------------------------------------------------------------
       *  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
       *=====================================================================
       * Main line
       *=====================================================================
       /free
 
            // Load external HTML
            IfsMultIndicators=getHtmlIfsMult(%trim(exthtml):'«as400»');
 
            // Get browser input
            nbrVars=zhbgetinput(savedquerystring:qusec);
            // Parse input variables
            xcountry=zhbGetVar('xcountry');
 
            // If needed, open database file
            if not %open(CAPITALS);
               open CAPITALS;
            endif;
 
            // If latitude and longitude available for the capital cirty 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()'); // «body» onLoad to run google map function
            else;
               updhtmlvar('onload':' ');                  // no body onLoad
            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;
               wrtsection('googleMap');
            endif;
 
            // End HTML
            wrtsection('bottom');
 
            // Send out the HTML buffer
            wrtsection('*fini');
 
            // End program
            return;
0.023 sec.s