Retrieving Environment Variables



The following is an RPG example of how to retrieve environment variables:

Fixed Format
     D getenv          PR              *   ExtProc('getenv')      D   name                          *   Value Options(*String) D varptr s *      D ipaddress       s             25A       /Free varptr = getenv('REMOTE_ADDR'); if varptr = *null; // no REMOTE_ADDR was set else;             ipaddress = %str(varptr); endif;



**FREE
DCL-PR GETENV POINTER EXTPROC('getenv'); NAME POINTER VALUE OPTIONS(*STRING); END-PR; DCL-S IPADDRESS CHAR(25); DCL-S VARPTR POINTER;  VARPTR = GETENV('REMOTE_ADDR'); IF (VARPTR = *NULL); // No REMOTE_ADDR was set. ELSE; IPADDRESS = %STR(VARPTR); ENDIF;



Environment variables set by Profound UI include:

PROFOUNDUI = Always set to '1' if running in the Profound UI session controller.
PUI_LANG = language ID that Profound UI is using (see International Language Support (Translations) for details)

Environment variables set in the HTTP server configuration using the SetEnv directive are also available, as are the environment variables set by the HTTP server. See documentation here.

If you are using Genie, you must run the PUISETENV utility to set the environment variables in the job.