#FOR( tag [ ( filter ) ] )



tagAn XML tag.
filterA logical expression indicating which specific tag instances to process.
statementsThe Template statements to execute.
#ENDThe #FOR structure terminator.

The #FOR structure loops through the XML, searching for each instance of the tag that meets the filter expression and executes the statements on the data contained within that tag.


  // This script processes XML and generates ECL COUNT statements
  // which run against the datasets and filters specified in the XML.
  XMLstuff :=
           '<filter>firstname = \'RICHARD\'</filter>'+
           '<filter>firstname = \'JOHN\'</filter>'+
           '<filter>firstname = \'HENRY\'</filter>'+
  #DECLARE(CountStr); // Declare CountStr
  #SET(CountStr, '' ); // Initialize it to an empty string
     #APPEND(CountStr,'COUNT(' + %'dataset'% + '(' + %'filter'% + ' ));\n');
  OUTPUT(%'CountStr'%); // output the string just built
  %CountStr% // then execute the generated "COUNT" actions
  // Note that the "CountStr" will have 3 COUNT actions in it:
  //   COUNT(person(person.firstname = 'RICHARD'));
  //   COUNT(person(person.firstname = 'JOHN'));
  //   COUNT(person(person.firstname = 'HENRY'));