Compile Time Constants

The following system constants are available at compile time. These can be useful in creating conditional code.

__ECL_VERSION__A STRING containing the value of the platform version. For example, '6.4.0'
__ECL_VERSION_MAJOR__ An INTEGER containing the value of the major portion of the platform version. For example, '6'
__ECL_VERSION_MINOR__An INTEGER containing the value of the minor portion of the platform version. For example, '4'
__ECL_LEGACY_MODE__A BOOLEAN value indicating if it is being compiled with legacy IMPORT semantics.
__OS__A STRING indicating the operating system to which it is being compiled. Possible values are: 'windows', 'macos', or 'linux'.
__STAND_ALONE__A BOOLEAN value indicating if it is being compiled to a stand-alone executable.
__TARGET_PLATFORM__A STRING containing the value of the target platform (the type of cluster the query was submitted to). Possible values are: 'roxie', 'hthor', or 'thorlcr'.
__CONTAINERIZED__A BOOLEAN value indicating if the platform is a containerized version.

Examples:

// Any modules referenced inside the condition must be declared outside of the condition
// This will avoid syntax errors 
prod_thor_dali := _Control.IPAddress.prod_thor_dali;
  #IF(_TARGET_PLATFORM_ in ['thorlcr'])
    OUTPUT('thor');
    prod_thor_dali;
  #ELSE
    OUTPUT('not thor');
  #END

//Second example
IMPORT STD;
  STRING14 fGetDateTimeString() :=
  #IF(__ECL_VERSION_MAJOR__ > 5) or ((__ECL_VERSION_MAJOR__ = 5) AND (__ECL_VERSION_MINOR__ >= 2))
    STD.Date.SecondsToString(STD.Date.CurrentSeconds(true), '%Y%m%d%H%M%S');
  #ELSE
    FUNCTION
      string14 fGetDimeTime():= // 14 characters returned
      BEGINC++
      #option action
      struct tm localt;         // localtime in "tm" structure
      time_t timeinsecs;        // variable to store time in secs
      time(&timeinsecs);  
      localtime_r(&timeinsecs,&localt);
      char temp[15];
      strftime(temp , 15, "%Y%m%d%H%M%S", &localt); // Formats the localtime to YYYYMMDDhhmmss 
      strncpy(__result, temp, 14);
      ENDC++;
      RETURN fGetDimeTime();
    END;
  #END;

// Example using __CONTAINERIZED__
over := 'overwrite=1 ';
repl := 'replicate=1 ';
action  := 'action=spray ';
srcplane :='srcplane=mydropzone ';
srcfile := 'srcfile=originalperson ';
dstname:='dstname=JD::originalperson ' ;
//dstcluster:= 'dstcluster=data '; // for containerized
//dstcluster:= 'dstcluster=mythor '; // for bare-metal
dstcluster := IF(__CONTAINERIZED__, 'dstcluster=data ','dstcluster=mythor '); 
fmt:= 'format=fixed ';
recsize:='recordsize=124 ';
cmd := over + repl + action + srcplane + srcfile + dstname 
       + dstcluster + fmt + recsize;
STD.File.DfuPlusExec(cmd);

Runtime Expressions

The following system constants are evaluated at runtime. Technically, these are runtime expressions, not constants. Therefore, they cannot be used in conditional code that requires a constant.

__PLATFORM__A STRING that represents the type of engine where the query is executing on. Possible values are: 'roxie', 'hthor', or 'thorlcr'.