Skip to main content


#UNIQUENAME( namevar [ ,pattern]);

namevarThe label of the template variable (without the percent signs) to use in subsequent statements (with the percent signs) that need the generated unique name.
patternOptional. A template for unique name construction. It should contain a dollar sign ($) to indicate the position at which a unique number is generated, and may contain a pound sign (#) to include the namevar. This is useful for situations where #UNIQUENAME is being used to generate field names and the result is meant to be viewed in the ECL IDE program, since by default #UNIQUENAME generates identifiers that begin with a double underscore (__) and the ECL IDE treats them as hidden fields. If omitted, the default pattern is __#__$__.

The #UNIQUENAME statement creates a valid unique ECL identifier within the context of the current scope limit. This is particularly useful in MACRO structures as it allows the macro to be used multiple times in the same scope without creating duplicate attribute name errors from the attribute definitions within the macro. This statement may be used outside an XML scope and does not require a previous LOADXML to instantiate an XML scope.


  IMPORT Training_Compare;
  EXPORT MAC_Compare_Result(module_name, attribute_name) := MACRO
  %compare_file% := Training_Compare.File_Compare_Master;
  #UNIQUENAME(compare_attr, _MyField_$_);
       //the compare_attr fieldname is generated like: _MyField_1_
  %layout_per_attr% := RECORD
       %compare_attr% := module_name.attribute_name;
  %person_attr_out% := TABLE(person, %layout_per_attr%);
  %person_attr_out_dist% := DISTRIBUTE(%person_attr_out%,HASH(per_cid));
  %layout_match_out% := RECORD
       data9 per_cid;
       boolean ValuesMatchFlag;
       TYPEOF(module_name.attribute_name) MyValue;
       TYPEOF(%compare_file%.attribute_name) CompareValue;
  %layout_compare% := RECORD
  %compare_table% := TABLE(%compare_file%, %layout_compare%);
  %compare_table_dist% := DISTRIBUTE(%compare_table%, HASH(per_cid));
  %layout_match_out% %compare_attr_to_field%(%person_attr_out% L,
  %compare_table% R) := TRANSFORM
       SELF.ValuesMatchFlag := (L.%compare_attr% = R.attribute_name);
       SELF.MyValue := L.%compare_attr%;
       SELF.CompareValue := R.attribute_name;
       SELF := L;
  %compare_out% := JOIN(%person_attr_out_dist%,
            LEFT.per_cid = RIGHT.per_cid,
            %compare_attr_to_field%(LEFT, RIGHT),
  %match_out% := %compare_out%(ValuesMatchFlag);
  %nomatch_out% := %compare_out%(~ValuesMatchFlag);
  OUTPUT(CHOOSEN(%match_out%, 50));
  OUTPUT(CHOOSEN(%nomatch_out%, 50));

See Also: MACRO