Setting and getting variables for logic in an iterator workflow, not working

Hi all

I have an Evernote note with attachments. I retrieve this note, initialise a couple of variables to -1, then in the iterator loop, set and get these variable to build my logic.

Basically, each of the attachments in an Evernote note is an image file called “Notebook - page 1.png” or similar. I want to find the highest “page number” in all the attachments. So I iterate through the attachments, if the page number is greater than the highest found so far then I replace the variable, etc.

This logic is not working. I am parsing the filename and getting the page number OK. I am using parseNumber() to make sure these strings are number. Have I missed something in my logic.

I’ll paste some screen shots:

… the second to last image shows how I get the page number from the filename. This works.

The last image is where I test to see if the the page number in this iteration is greater than or equal to the highest page number found so far. If it is greater set the highestPageNumberValue to be the new page number found this iteration. If not, set it to the same value it currently is.
I also use the same logic to set the index (iteration number) where the highest page number is found.

What actually happens is that the loop completes and both the highestPageNumberValue and the index of this are set to the last values found in the last iteration. It’s like the value of highestPageNumberValue which is set to -1 at the start is never updated within the iteration, and the logic is always comparing whatever page number is found to -1, every iteration.