I have not tried this, but what if you created a "middle-man" function that serves as a counter (returning simply n+1 ... results.n), and then use an exclusive gateway to either:
1.) End the loop (go to next item in workflow / end workflow) if n = loop_max
2.) Return to original function (before "middle-man" function) if n< loop_max
The condition applied to the gateway would be (for end condition arrow):
Script condition: continue
Advanced Scripting Options:
continue = True
if(workflow.properties.workflow_middle_man_results['n'] = 100):
continue= False
Flip True/False order for other condition.
------------------------------
Jared Fagel
Cyber Security Analyst Intern
Public Utility
------------------------------