test.txt:
nick1
nick2
nick3
Need to send message to theese all nicks..
var %i 1
var %all $+(dzd/,$nick,_viesi.txt)
while (%i <= %all) {
/msg %i Message for you!
inc %i
im not sure i follow what your doing
anyways try $read and $lines
hopefully this helps
perhaps it would be easier if you showed the entire script
hmm
well /msg nick1,nick2nick3
as you have the text file, try this
alias msglist {
var %lines = $lines(nicks.txt)
var %i = 1
while (%i <= %lines) {
var %list = %list $+ $chr(44) $+ $read(nicks.txt,%i)
inc %i
}
msg %list $$1-
}
much easier to have all on the one line
nicks.txt :
nick1,nick2,nick3
then:
alias msglist $read(nicks.txt,1) $$1-
I'd recommend using
var %list = $addtok(%list,$read(nicks.txt,%i),44)
in place of
var %list = %list $+ $chr(44) $+ $read(nicks.txt,%i)
yes the addtok is nice and slick
and in this example there is no difference in functionality and makes following the logic a little easier IMO to use the $+
Thank You Russel for bringing it up.
One other advantage to using $addtok, in this case, is if you happen to have the same name more than once in the file, with your original code, that person would be messaged multiple times (once for each time their nick was in the variable), with mine, they only get messaged once, since $addtok won't add a token that already exists.
That will also prevent a leading
, that mike's code made
msg nick1,nick1,nick1 blah well actually only message nick1 once.
heres a non looping solution to the original request
alias example {
bread TEST.TXT 0 400 &binvar
breplace &binvar 13 44 10 44
msg $gettok($bvar(&binvar,1,400).text,1-,44) Message for you!
}
* 400 i choose since messages i beleive cant exceed 512 byes including the raw message info.