Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Removed hard coded themes for code blocks to match doc page style guide

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

Code Block
themeEclipse
titleFixed 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;


Code Block
themeEclipse
title**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; 

...