Some Examples...
a) Make a string of all chans separated by $chr(32).
alias allchans {
var %nr = 1
while ($chan(%nr)) {
var %chans = $addtok(%chans,$ifmatch,32)
inc %nr
}
echo -a I made this string: %chans
}
b) Start timers directly out of the loop - this avoids storing any data in a variable.
alias looptimer {
var %nr = 1
while ($chan(%nr)) {
timer 1 %nr echo -t $ifmatch now I trigger here in $ifmatch - thats chan No. %nr
inc %nr
}
}
c) Make a numbered string of all chans (in the format nr1 chan2•nr2 chan2•nr3 chan3...), THEN loop all tokens of that string, and use the 2 parts of each token (nr and channelname) to start timers.
The $calc part was to show that you can manipulate the timer's offset as you like.
alias stringtimer {
var %nr = 1
while ($chan(%nr)) {
var %chans = $addtok(%chans,%nr $ifmatch,149)
inc %nr
}
echo -a now I got this string: %chans
var %nr = 1
while $gettok(%chans,%nr,149) {
var %token = $ifmatch
timer 1 $calc($gettok(%token,1,32) *3) echo -t $gettok(%token,2,32) now I trigger here.
inc %nr
}
}
Instead of "echo" or "echo -t" in the examples, you can trigger every command (or alias) you want. And of course, silence the timers.... with
.timer