The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

"[SOLVED] looping with a loop macro through a user-defined list"

tennenrishintennenrishin Member Posts: 177 Contributor II
edited June 2019 in Help
I often encounter situations where I would like to loop, with a loop-macro taking on each item in a user-defined list of strings. There doesn't seem to be an operator for this, but Is there some other simple way to accomplish this?

Thanks in advance
Isak

Answers

  • haddockhaddock Member Posts: 849 Maven
    Hi there,

    I resort to using a parameter loop, like this.
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.2.003">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.2.003" expanded="true" name="Process">
        <process expanded="true" height="230" width="870">
          <operator activated="true" class="loop_parameters" compatibility="5.2.003" expanded="true" height="76" name="Loop Parameters" width="90" x="179" y="30">
            <list key="parameters">
              <parameter key="Set Macro.value" value="hello,world,again"/>
            </list>
            <process expanded="true" height="230" width="888">
              <operator activated="true" class="set_macro" compatibility="5.2.003" expanded="true" height="76" name="Set Macro" width="90" x="179" y="30">
                <parameter key="macro" value="macro"/>
                <parameter key="value" value="again"/>
              </operator>
              <operator activated="true" class="provide_macro_as_log_value" compatibility="5.2.003" expanded="true" height="76" name="Provide Macro as Log Value" width="90" x="313" y="30">
                <parameter key="macro_name" value="macro"/>
              </operator>
              <operator activated="true" class="log" compatibility="5.2.003" expanded="true" height="76" name="Log" width="90" x="447" y="30">
                <list key="log">
                  <parameter key="macro value" value="operator.Provide Macro as Log Value.value.macro_value"/>
                </list>
              </operator>
              <connect from_port="input 1" to_op="Set Macro" to_port="through 1"/>
              <connect from_op="Set Macro" from_port="through 1" to_op="Provide Macro as Log Value" to_port="through 1"/>
              <connect from_op="Provide Macro as Log Value" from_port="through 1" to_op="Log" to_port="through 1"/>
              <connect from_op="Log" from_port="through 1" to_port="result 1"/>
              <portSpacing port="source_input 1" spacing="0"/>
              <portSpacing port="source_input 2" spacing="0"/>
              <portSpacing port="sink_performance" spacing="0"/>
              <portSpacing port="sink_result 1" spacing="0"/>
              <portSpacing port="sink_result 2" spacing="0"/>
            </process>
          </operator>
          <connect from_port="input 1" to_op="Loop Parameters" to_port="input 1"/>
          <connect from_op="Loop Parameters" from_port="result 1" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="source_input 2" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>
    It should log 'hello world again' - hope so!

  • tennenrishintennenrishin Member Posts: 177 Contributor II
    Exactly what I needed! Thanks!
Sign In or Register to comment.