I can't understand why this function enter into a infinite loop as show in the Logs screenshot below ?!!!!
This only happens in run mode. In record mode everything working as expected !!!
You can use "Result" variables that are predefined in BAS. There are 9 of them.
If you need more you can use filesystem actions and create TXT or CSV files
to store any number you need. Similar to that you can use database for such
tasks too.