I'm trying to count how many times a condition is true inside a FOR loop. I declared an additional variable for the template (FOUND : Integer), and I'm trying to increment it every time the [IF] condition is "true", but the variable increments only the first time, then it gets back to its original value. Basically, if FOUND = 1 at the beginning, at every loop I get 2 in output.
This is the code I'm trying to use:
[template public genPartnerLinkJavaFile(aProcess : Process, varNameList : Sequence{String} .... etc)
{FOUND : Integer = 1;}]
[file ('PL'+aPartnerLink.name.toUpperFirst()+'.java', false, 'UTF-8')]
public class ['PL'+aPartnerLink.name.toUpperFirst()/] {
[for (aVariable : Variable | aProcess.eAllContents(Variable))]
[if (varNameList->includes(aVariable.name.toString() ) )]
[FOUND+1/]
[i/]
[/if]
[/for]
Do you know how could I achieve this or something similar? Thanks