cancel
Showing results for 
Search instead for 
Did you mean: 

Using a variable in Graphical Mapping

Former Member
0 Kudos

Hi,

I am taking in a value from a file and I need to use it in multiple segments and in each segment it has to be the number in incremental steps...there can be just 2 of 3 segments or up to 50

So I have created a global variable and assigned the number to it.

My problem is how to then increase it.

I created a UDF and added a cntr as a public int. I am also then passing in the global variable...what I would like is to simply and the counter (initially 1) to the variable and pass the result back out....so 500 + 1 becomes 501

I then add 1 to the cntr so the next time it comes into the function it will be 500 plus 2 and counter increased again and so on and so on.

However I am getting mismatches between intergers and arrays and cannot get it to work.

Any help greatly appreciated

B

Accepted Solutions (1)

Accepted Solutions (1)

vinaymittal
Contributor
0 Kudos

<source>

    <value>500</value>

</source>

<Target>

     <node>500 </node>

     <node>501 </node>

     <node> 502</node>

     <node> 503</node>

     <node>504 </node>

     <node> 505</node>

     <node> 506</node>

</Target>

If this is what you want

1)In Attributes and methods declare a int variable cntr = 0;(you have already done that.

int cntr = 0;

2)create udf "initial_value" with the code below to initialize the counter to 500 (value)

(execution type : all values of a context, argument name value, take a result output)

{

cntr = Integer.parseInt(value[0]);

result.addValue("");

}

map the udf from source node to target node

Source--->initial_value--->Target

3)Based on which node(base) /field from source you are generating these multiple nodes on target....

write a udf counter

(all values of context, arguments item, output as result)

i assume that you have as many base nodes

base--->splitbyeachvalue-->udf counter--->remove context-->node

udf code

{

result.addValue(""+cntr);

cntr++;

}

Regards

Vinay

Former Member
0 Kudos

Perfect Vinay...thanks a million

Answers (1)

Answers (1)

iaki_vila
Active Contributor
0 Kudos

Hi Brian,

Have you tried to use the index function? (under statistic  functions):

Regards.

Former Member
0 Kudos

Thanks Inaki,

That wont work though as it is across multiple segments, index of just gives the index of value coming in...i need to take a value into the global and then update it by 1 across numerous other segments