RPGIV @ Work

A unique site for RPG and System i Lovers

Welcome!

Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

Environment variables Print E-mail
User Rating: / 0
PoorBest 
Written by Chamara Withanachchi   
 H NOMAIN DATFMT(*USA)                                    
 H OPTION(*NOXREF)                                        
 H CVTOPT(*DATETIME) ALWNULL(*USRCTL)                     
 H ENBPFRCOL(*FULL) BNDDIR('QC2LE')                       
  *                                                       
  *-- begin copy book                                     
  * * * * * * * * * * * * * * * * * * * * * * * * * * *   
  *  Standard type definitions.                           
  * * * * * * * * * * * * * * * * * * * * * * * * * * *   
 D StdNulPtr       S               *                      
 D StdInd          S              1n   Based( StdNulPtr ) 
 D StdInt          S             10i 0 Based( StdNulPtr ) 
 D StdPtr          S               *   Based( StdNulPtr ) 
 D StdStr          S            256    Based( StdNulPtr ) 
  *                                                                
  *-- begin copy book                                              
  * * * * * * * * * * * * * * * * * * * * * * * * * * *            
  *  Environment prototypes.                                       
  * * * * * * * * * * * * * * * * * * * * * * * * * * *            
  * ---------------------------------------------------------      
  *                                                                
  *  Put environment variable.                                     
  *                                                                
 D putenv          PR                  extproc('Qp0zPutEnvNoCCSID')
 D                                     like(StdInt)                
 D  i_envVar                           like(StdPtr) value          
 D                                     options(*string)            
  * ---------------------------------------------------------      
  *                                                                
  *  Get environment variable.                                     
  *                                                                
 D getenv          PR                  extproc('Qp0zGetEnvNoCCSID')
 D                                     like(StdPtr)                
 D  i_envVar                           like(StdPtr) value          
 D                                     options(*string)      
  * ---------------------------------------------------------
  *                                                          
  *  Get environment variable.                               
  *                                                          
 D GetEnvVar       PR         32767    varying               
 D  EnvVarNam                    64    varying const         
 D                                     options(*varsize)     
  * ---------------------------------------------------------
  *                                                          
  *  Get environment variable as indicator.                  
  *                                                          
 D GetEnvVarInd    PR                  like(StdInd)          
 D  EnvVarNam                    64    varying const         
 D                                     options(*varsize)     
  * ---------------------------------------------------------
  *                                                          
  *  Delete environment variable.                            
  *                                                          
 D dltenv          PR                  extproc('Qp0zDltEnv') 
 D                                     like(StdPtr)          
 D  i_envVar                           like(StdPtr) value             
 D                                     options(*string)               
  * ---------------------------------------------------------         
  *                                                                   
  *  Environment variable workfields.                                 
  *                                                                   
 D EnvVarNam       s             64                   inz             
 D pEnvVar         s                   like(StdPtr)   inz             
 D EnvVar          s          32767    based(pEnvVar)                 
  *                                                                   
  *-- end copy book                                                   
  * **********************************************************        
  * Get environment variable.                                         
  * **********************************************************        
 P GetEnvVar       B                   Export                         
  *                                                                   
 D GetEnvVar       PI         32767    varying                        
 D  EnvVarNam                    64    options(*varsize) varying const
  *                                                                   
 D  RtnVar         s          32767    varying inz                    
  * ---------------------------------------------------------         
  *                                                              
  *    Test for no input.                                        
  *                                                              
 C                   if        EnvVarNam = *blanks               
 C                   return    *blanks                           
 C                   endif                                       
  * ---------------------------------------------------------    
  *                                                              
  *    Get environment variable.                                 
  *                                                              
 C                   eval      pEnvVar = getenv(%trim(EnvVarNam))
  *                                                              
 C                   if        pEnvVar <> *null                  
 C                   eval      RtnVar   = %str(pEnvVar)          
 C                   else                                        
 C                   eval      RtnVar   = *blanks                
 C                   endif                                       
  *                                                              
 C                   return    RtnVar                            
  *                                                              
 P GetEnvVar       E                            *
 **********************************************************        
  * Get environment variable as indcator.                             
  * **********************************************************        
 P GetEnvVarInd    B                   Export                         
  *                                                                   
 D GetEnvVarInd    PI                  like(StdInd)                   
 D  EnvVarNam                    64    options(*varsize) varying const
  *                                                                   
 D  RtnInd         s                   like(StdInd) inz               
  * ---------------------------------------------------------         
  *                                                                   
  *    Test for no input.                                             
  *                                                                   
 C                   if        EnvVarNam = *blanks                    
 C                   return    *off                                   
 C                   endif                                            
  * ---------------------------------------------------------         
  *                                                                   
  *    Get environment variable.                                      
  *                                                                   
 C                   eval      pEnvVar = getenv(%trim(EnvVarNam))     
                   
  *                                                    
 C                   if        pEnvVar <> *null        
 C                   eval      RtnInd   = %str(pEnvVar)
 C                   else                              
 C                   eval      RtnInd   = *off         
 C                   endif                             
  *                                                    
 C                   return    RtnInd                  
  *                                                    
 P GetEnvVarInd    E

User Comments

Please login or register to add comments

<Previous   Next>