🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Reference Macro Value (from constructed macro name)

NoelUser: "Noel"
New Altair Community Member
Updated by Jocelyn
Hi All (@lionelderkrikor )-

There's a 'Set Macros from Example set' operator. Like in the attached process (with excel source file), I'd like to feed macro names and values into the process and then, in a 'Loop Until' operator, access the value of a macro whose name I construct (from another macro).

So, as in the example below, I have a 'train_start_date1' attribute with a value. In the loop, I want to take the string 'train_start_date', stick the iteration number on the end (%{iteration}), form a macro name 'train_start_date1' and then have access to the value of that macro (namely 5/31/2016).



Any help appreciated! Thanks.

-Noel

Find more posts tagged with

Sort by:
1 - 1 of 11
    sgenzerUser: "sgenzer"
    Altair Employee
    Accepted Answer
    hi @Noel ok been scratching my head for 5 min trying to figure out what the problem is. 😀Is this what you're looking for?

    <?xml version="1.0" encoding="UTF-8"?><process version="9.4.001">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.4.000" expanded="true" name="Process">
        <parameter key="logverbosity" value="init"/>
        <parameter key="random_seed" value="2001"/>
        <parameter key="send_mail" value="never"/>
        <parameter key="notification_email" value=""/>
        <parameter key="process_duration_for_mail" value="30"/>
        <parameter key="encoding" value="SYSTEM"/>
        <process expanded="true">
          <operator activated="true" class="read_excel" compatibility="9.4.001" expanded="true" height="68" name="Read Excel" width="90" x="45" y="34">
            <parameter key="excel_file" value="/Users/genzerconsulting/Desktop/DateConstructionTest.v2.xlsx"/>
            <parameter key="sheet_selection" value="sheet number"/>
            <parameter key="sheet_number" value="1"/>
            <parameter key="imported_cell_range" value="A1"/>
            <parameter key="encoding" value="SYSTEM"/>
            <parameter key="first_row_as_names" value="true"/>
            <list key="annotations"/>
            <parameter key="date_format" value=""/>
            <parameter key="time_zone" value="SYSTEM"/>
            <parameter key="locale" value="English (United States)"/>
            <parameter key="read_all_values_as_polynominal" value="false"/>
            <list key="data_set_meta_data_information">
              <parameter key="0" value="macro.true.polynominal.attribute"/>
              <parameter key="1" value="value.true.date.attribute"/>
            </list>
            <parameter key="read_not_matching_values_as_missings" value="false"/>
            <parameter key="datamanagement" value="double_array"/>
            <parameter key="data_management" value="auto"/>
          </operator>
          <operator activated="true" class="concurrency:loop" compatibility="9.4.001" expanded="true" height="82" name="Loop" width="90" x="179" y="34">
            <parameter key="number_of_iterations" value="5"/>
            <parameter key="iteration_macro" value="iteration"/>
            <parameter key="reuse_results" value="false"/>
            <parameter key="enable_parallel_execution" value="false"/>
            <process expanded="true">
              <operator activated="true" breakpoints="after" class="generate_macro" compatibility="9.4.001" expanded="true" height="82" name="Generate Macro (2)" width="90" x="45" y="34">
                <list key="function_descriptions">
                  <parameter key="foo" value="concat(&quot;train_start_date&quot;,%{iteration})"/>
                </list>
              </operator>
              <operator activated="true" breakpoints="after" class="extract_macro" compatibility="9.4.001" expanded="true" height="68" name="Extract Macro (3)" width="90" x="179" y="34">
                <parameter key="macro" value="%{foo}"/>
                <parameter key="macro_type" value="data_value"/>
                <parameter key="statistics" value="average"/>
                <parameter key="attribute_name" value="value"/>
                <parameter key="example_index" value="%{iteration}"/>
                <list key="additional_macros"/>
              </operator>
              <connect from_port="input 1" to_op="Generate Macro (2)" to_port="through 1"/>
              <connect from_op="Generate Macro (2)" from_port="through 1" to_op="Extract Macro (3)" to_port="example set"/>
              <portSpacing port="source_input 1" spacing="0"/>
              <portSpacing port="source_input 2" spacing="0"/>
              <portSpacing port="sink_output 1" spacing="0"/>
              <portSpacing port="sink_output 2" spacing="0"/>
            </process>
          </operator>
          <connect from_op="Read Excel" from_port="output" to_op="Loop" to_port="input 1"/>
          <connect from_op="Loop" from_port="output 1" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>
    



    Scott