mIRC Homepage
Posted By: SkyD problem - while - 12/12/05 06:31 PM
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
Posted By: NeUtRoN_StaR Re: problem - while - 12/12/05 07:16 PM
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
Posted By: MikeChat Re: problem - while - 12/12/05 07:58 PM
hmm
well /msg nick1,nick2nick3
as you have the text file, try this
Code:
alias msglist {
var %lines = $lines(nicks.txt)
var %i = 1
while (%i &lt;= %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-
Posted By: RusselB Re: problem - while - 13/12/05 12:53 AM
I'd recommend using
Code:
var %list = $addtok(%list,$read(nicks.txt,%i),44)  
in place of
Code:
 var %list = %list $+ $chr(44) $+ $read(nicks.txt,%i) 
Posted By: MikeChat Re: problem - while - 13/12/05 03:53 AM
Quote:
I'd recommend using
Code:
var %list = $addtok(%list,$read(nicks.txt,%i),44)  
in place of
Code:
 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.
Posted By: RusselB Re: problem - while - 13/12/05 04:08 AM
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.
Posted By: hixxy Re: problem - while - 13/12/05 05:39 AM
That will also prevent a leading , that mike's code made smile
Posted By: DaveC Re: problem - while - 13/12/05 09:40 AM
msg nick1,nick1,nick1 blah well actually only message nick1 once.

heres a non looping solution to the original request

Code:
alias example {
  bread TEST.TXT 0 400 &amp;binvar
  breplace &amp;binvar 13 44 10 44
  msg $gettok($bvar(&amp;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.
© mIRC Discussion Forums