Pages: [1]
  Print  
Author Topic: [SOLVED] catch the attribute name to a macro  (Read 238 times)
sfmorais
Newbie
*
Posts: 13


« on: February 05, 2012, 12:33:40 AM »

Hi everybody!

Is there any way to get the 'attribute name' of a example set (to put for example in a macro) to use later in a 'set data' operator ?  

In middle of my process I have one example set with only 1 example and 1 attribute (1 cell), but the attribute is not the same. I need to catch the name of that attribute to use later as parameter in the 'set data' operator.

Thanks for the help

Regards
Sérgio Morais
« Last Edit: February 14, 2012, 11:01:58 AM by Marius » Logged
haddock
Hero Member
*****
Posts: 759



WWW
« Reply #1 on: February 05, 2012, 10:55:21 AM »

Hi there,

There may well be other ways, but you can loop through the attributes, like this..

Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.1.013">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="5.1.013" expanded="true" name="Process">
    <process expanded="true" height="457" width="839">
      <operator activated="true" class="generate_data" compatibility="5.1.013" expanded="true" height="60" name="Generate Data" width="90" x="45" y="75"/>
      <operator activated="true" class="loop_attributes" compatibility="5.1.013" expanded="true" height="60" name="Loop Attributes" width="90" x="183" y="73">
        <process expanded="true" height="457" width="839">
          <operator activated="true" class="set_macro" compatibility="5.1.013" expanded="true" height="76" name="Set Macro" width="90" x="179" y="75">
            <parameter key="macro" value="%{MYMACRO}"/>
            <parameter key="value" value="%{loop_attribute}"/>
          </operator>
          <operator activated="true" class="provide_macro_as_log_value" compatibility="5.1.013" expanded="true" height="76" name="Provide Macro as Log Value" width="90" x="368" y="21">
            <parameter key="macro_name" value="%{MYMACRO}"/>
          </operator>
          <operator activated="true" class="log" compatibility="5.1.013" expanded="true" height="76" name="Log" width="90" x="514" y="18">
            <list key="log">
              <parameter key="MYMACRO" value="operator.Set Macro.value.macro_value"/>
            </list>
          </operator>
          <connect from_port="example set" 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="example set"/>
          <portSpacing port="source_example set" spacing="90"/>
          <portSpacing port="sink_example set" spacing="0"/>
        </process>
      </operator>
      <connect from_op="Generate Data" from_port="output" to_op="Loop Attributes" to_port="example set"/>
      <connect from_op="Loop Attributes" from_port="example set" 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>

Check out the text view of the log to see the results.

Good luck.
Logged

Where is the wisdom we have lost in knowledge?
Where is the knowledge we have lost in information?

T.S.Eliot ~ Choruses from the Rock 1934
sfmorais
Newbie
*
Posts: 13


« Reply #2 on: February 06, 2012, 10:39:33 PM »


Ok! Thanks. The example helped me.
Logged
Pages: [1]
  Print  
 
Jump to: