I'm having trouble understanding what it is that you want.
If you're doing a for loop and want to know how many times the loop was ran, just do this.
function doLoop()
{
for(%a = 0; getRandom(0, 50) > 0; %a++) { }
echo("%a = " @ %a);
}
In this example, the loop will run forever, or until the getRandom() function returns a 0.
After the loop terminates (assuming it ever does), it echos %a. If I wanted to report how many times the for loop actually ran, I can either echo %a + 1 or start the for loop with %a = 1;.