Learn from sources
       Member DSPENVVAR in CGIDEV2 / QRPGLESRC

       *=====================================================================
       *  RPG ILE PROGRAM CGIDEV2/DSPENVVAR
       *  Display user-selected environment variables
       *
       * CRTBNDRPG PGM(CGIDEV2/DSPENVVAR) SRCFILE(CGIDEV2/QRPGLESRC)
       *           DFTACTGRP(*NO) ACTGRP(*CALLER) DBGVIEW(*SOURCE)
       *
       *=====================================================================
       /copy cgidev2/qrpglesrc,hspecs
       /copy cgidev2/qrpglesrc,hspecsbnd
       * The records of the following file document the environment variables through 3 fields:
       * - "envtype"  the type of the environment variable
       * - "envvar"   the name of the environment variable
       * - "envdes"   the meaning of the environment variable
      FENVVARS   if   e           k disk    usropn
      F                                     extfile('CGIDEV2/ENVVARS')
       /copy cgidev2/qrpglesrc,prototypeb
       /copy cgidev2/qrpglesrc,variables3
       /copy cgidev2/qrpglesrc,usec
      D extHtml         s            500
      D xinput          s             70
      D xenvtype        s                   like(envtype)
      D xenvvar         s                   like(envvar)
      D r               s             10i 0
      D value           s            500
       * 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
 
       /free
 
            // Get browser input
            QUSBPRV=%size(QUSEC);
            nbrVars=zhbgetinput(savedquerystring:qusec);
            xenvtype=zhbgetvar('xenvtype');  //the type of the selected environment variable
            xenvvar =zhbgetvar('xenvvar');   //the name of the selected environment variable
 
            // Load IFS html script
            extHtml='/cgidev/html/dspenvvar.txt';
            IfsMultIndicators=getHtmlIfsMult(%trim(exthtml):'«as400»');
            ClrHtmlBuffer();
 
            updhtmlvar('Thisjob':psdsJobNbr+'/'+%trim(psdsUsrNam)+'/'+
                       %trim(psdsJobNam));  //display the qualified name of the current HTTP job
 
            // position cursor on the appropriate row of the first drop-down list
            updhtmlvar('selected1':' ');
            updhtmlvar('selected2':' ');
            updhtmlvar('selected3':' ');
            select;
            when xenvtype='HTTP';
                 updhtmlvar('selected1':'selected');
            when xenvtype='HTTP SSL';
                 updhtmlvar('selected2':'selected');
            when xenvtype='JAVA';
                 updhtmlvar('selected3':'selected');
            endsl;
 
            wrtsection('top');  //start html
 
            // If the type of environment variables not yet selected, end html
            if xenvtype=' ';
               wrtsection('varRowEnd formEnd bottom *fini');
               return;
            endif;
 
            //The type of environment variables was selected, therefore
            // - fill the second drop-down list (environment variables of the selected type)
            // - if a specific environment variable selected
            //   -- position the cursor on the appropriate row of the drop-down list
            //   -- display the meaning of this environment variable
            //   -- retrieve this environment variable if available in the current job
            //      and display its value
 
            if not %open(ENVVARS);
               open ENVVARS;
            endif;
 
            updhtmlvar('xenvtype':xenvtype);
            wrtsection('varRowStr');           //start the seond drop-down list
            setll xenvtype envrcd;
            reade xenvtype envrcd;
            dow not %eof;
                updhtmlvar('envvar':envvar);
                if envvar=xenvvar;
                   updhtmlvar('selected':'selected');
                else;
                   updhtmlvar('selected':' ');
                endif;
                wrtsection('varRow');          //write a row of the second drop-down list
                reade xenvtype envrcd;
            enddo;
            wrtsection('varRowEnd formEnd');   //end the second drop-down list
 
            if xenvtype«»' ' and xenvvar«»' ';    //if asked to display an environment variable, ...
               chain (xenvtype:xenvvar) envrcd;
               if %found;
                  updhtmlvar('myenvvar':envvar);     //display the name of the environment variable
                  updhtmlvar('myenvdes':envdes);     //display the meaning of the environment var.
                  value=getenv(%trim(envvar):qusec); //retrieve the value of the environment variable
                  updhtmlvar('myenvval':value);      //display its value
                  wrtsection('response');
               endif;
            endif;
 
            close ENVVARS;
 
            wrtsection('bottom *fini');
 
            return;
0.019 sec.s