"Accessing the current loop value in 'RepeatUntilOperaterChain'."

ShubhaShubha Member Posts: 139 Maven
edited May 2019 in Help
Hi,

I want to perform a certain number of operations(a combination of operator chains) for say 5 times. And so, I use the operator, 'RepeatUntilOperatorChain'. Now, I need to access the loop value (1,2,3,4,5) in each of the iteration. Can this be done by storing the current loop value in a macro variable or any other similar technique? How can I do this?

Thanks for your help,
Shubha

Answers

  • ShubhaShubha Member Posts: 139 Maven
    Hi,

    The above problem was solved as the way below:

    Just before the 'RepeatUntilOperaterChain', I created a dataset which has a single attribute with values from 1 to 5. (Since I know the no. of iterations to run). Then inside the loop, I kept reading the first value of the so created exampleset into a macro variable. And once the value is read into the macro variable, the first example will be deleted off from the dataset, so that in the next iteration, the second value is read and so on....

    But, please let me know, if there are any better ways of handling this...

    Thanks,
    Shubha Karanth
  • haddockhaddock Member Posts: 849 Maven
    Hi Shubha,

    Glad to see you've solved it, you could have used macros as you suggested, you can can even use the process log! Ah, choices, choices...
    <operator name="Root" class="Process" expanded="yes">
        <operator name="IteratingOperatorChain" class="IteratingOperatorChain" expanded="yes">
            <parameter key="iterations" value="10"/>
            <operator name="SingleMacroDefinition" class="SingleMacroDefinition">
                <parameter key="macro" value="Count"/>
                <parameter key="value" value="%{a}"/>
            </operator>
            <operator name="ProcessLog" class="ProcessLog">
                <list key="log">
                  <parameter key="Iterations" value="operator.IteratingOperatorChain.value.iteration"/>
                  <parameter key="Counter" value="operator.SingleMacroDefinition.value.macro_value"/>
                </list>
            </operator>
            <operator name="ProcessLog2ExampleSet" class="ProcessLog2ExampleSet">
            </operator>
        </operator>
    </operator>
Sign In or Register to comment.