Depends if you want a delay between loops.
If not:
function loop(%times)
{
for(%i = 0; %i < %times; %i++)
{
echo(%i);
}
}
In the console this would work like so:
>loop(10);
0
1
2
3
4
5
6
7
8
9
10
However if you want to have a delay between loops, you can loop a function by calling itself with a schedule, like so:
function loop(%delay)
{
cancel($schedule); //Prevent multiple loops from happening if the function is called more that once
echo("Loop");
$schedule = schedule(%delay, 0, loop, %delay); //Calls the function loop after %delay seconds
}
cancel($schedule); [color=green]//Prevent multiple loops from happening if the function is called more that once[/color]
Why are you cancelling a variable that does never get set?
EDIT: Fixed
A perfect reason not to lock coding help topics!