I hope you have all had a good summer break / holiday.
It is going to be a user error!
I have found a different node (Math Formula (Variable)) to do the job I want. This is not a request to help me solve a problem. This is a request to help me understand why the Java Snippet node is doing what it is doing.
Details
I am on KNIME AP 5.3.2.
Here is a sample of my flow:
As you can see, I have a Counting Loop Start node and I have configured it to three loops. In the Java Snippet I created a flow variable that took the currentIteration flow variable and added 12 and created a new flow variable.
If I change the Java Snippet code to out_SheetIndex = 120000 + v_currentIteration;
I also get an output of -1. I have tried these code snippets too: out_SheetIndex = (int)12 + v_currentIteration; out_SheetIndex = v_currentIteration + (int)12;
@FrankColumbo a better way I think would be to use Flow Variables and do some calculations there if you must. If your rows are empty there might not be anything to process at all.
And you might have noticed that your example is lacking a proper alternative route and close but I assume you just wanted to show the thing with the Java Snippet.
I am using flow variables to do this.
I just uploaded the smallest flow I could to demonstrate the behaviour I have seen.
I just want to know why the Java Snippet node didn’t do what I expected it too.
To rephrase @mlauber71 - the code in the Java Snippet node (which outputs a Table) will not get executed at all if there’s not at least one input row. The code which you put there gets executed once per table row, and never if there’s no rows.
Hence the Java Edit Variable makes more sense here. It executes independently of data tables. (note that there’s two execution modes in the configuration where you can determine at which phase to execute)