Skip to content

Environment Variables

Daniel Long edited this page Sep 29, 2026 · 3 revisions

Environment Variables

Read environment variables at runtime with %GETENV. It is an OpenRPG extension: IBM i has no such built-in, so source using it compiles only here.

DCL-S home VARCHAR(200);
DCL-S dbUrl VARCHAR(300);
DCL-S dspLine VARCHAR(52);   // DSPLY shows at most 52 characters

home = %GETENV('HOME');
dspLine = 'Home directory: ' + home;
DSPLY dspLine;

dbUrl = %GETENV('DATABASE_URL');
IF dbUrl = '';
  DSPLY 'No database configured';
ENDIF;

%GETENV returns an empty string if the variable is not set.

Clone this wiki locally