ECL loop macro control using query results

We are trying to write a loop macro with the break function. Basically, we would like to repeat a specific action until the X value (obtained from the dataset) is true. The compiler does not seem to like this approach (returns "Waiting for a constant"), so we were wondering if there is a known workaround?

The following is a completely artificial example called:

LoopFunction(5);  

from the BWR window.

EXPORT LoopFunction(NMax = 5) := MACRO

  Rec := RECORD
    INTEGER i;
  END;

    #DECLARE(i);


  OUTPUT(DATASET([1], REC), ,'~TEMP::MB::LOOPTEST' + %i%, COMPRESSED, OVERWRITE);

    #SET(i, 2);

  shouldIbreak :=  DATASET('~TEMP::MB::LOOPTEST' + (%i% - 1), Rec, THOR);

  #LOOP

    OUTPUT(shouldIbreak +DATASET([%i%], REC), ,'~TEMP::MB::LOOPTEST' + %i%, COMPRESSED, OVERWRITE);

    #SET (i, %i%+1);    

        #IF (COUNT(shouldIbreak) > Nmax);
       #BREAK
        #END
    #END

ENDMACRO;
+4
source share
2 answers

LOOP(), . ()

+1

(, , ) , ECL.

, (, ).

C. , , STRING , SOAPCALL.

+2

Source: https://habr.com/ru/post/1657998/


All Articles