mIRC Homepage

Need help with reading a text file start to finish

Posted By: MDA

Need help with reading a text file start to finish - 26/12/02 09:37 AM

Greetings mIRC Forum members,

I'm stuck on trying to read a text file from start to finish via a remote command to our script into the active channel, whispered back to someone. Here are the two examples we are trying to get working. None are working and I'm also concerned about flooding out my script without any timers set for the line by line whispered output.

#test1 on
on *:text:visitors:#:{ if ($nick isop $active) var %z = 1 while (%z <= $lines(nameslist.txt)) { /privmsg $nick $read(nameslist.txt) | inc %z }}
#test1 end

#test2 on
on *:text:bmbos*:#:{ var %y = 1 while (%y <= $lines($2.txt)) { /privmsg $nick $read($2.txt) | inc %y }}
#test2 end

We've tried substituing $read(nameslist.txt,%z) for
$read(nameslist.txt) and the same with
$read($2.txt,%y) for $read($2.txt) both of those failed also.


Thanks for your time and consideration,
MDA

Posted By: Nimue

Re: Need help with reading a text file start to finish - 26/12/02 11:55 AM

/help /play smile
Code:
#test1 on
on *:text:visitors:#:if ($nick isop #) { .play -m1 $nick nameslist.txt 1000 }
#test1 end
 
#test2 on
on *:text:bmbos*:#:{ .play -m1 $nick $2.txt 1000 }
#test2 end
Posted By: Dana

Re: Need help with reading a text file start to finish - 26/12/02 05:13 PM

As Nimue said, /play would probably be easier.

However, as to the problem with your script .. privmsg is a raw server command. And as such, it needs to be sent in the format of privmsg nick :message I believe. If you used just msg $nick then it should probably work.

Oh and I'm not quite sure about this, but instead of using $2.txt, you might want to try $2 $+ .txt or $+($2,.txt).
Posted By: Nimue

Re: Need help with reading a text file start to finish - 26/12/02 10:08 PM

A couple of little pieces of mIRC magic smile

mIRC will add the colon if you use "/privmsg nick text to send"
However, using '/play' also addresses the concern over flooding. smile

'$2.txt' works fine, you can tack things onto the back of $N's
//tokenize 32 bla versions blah bleh | run $2.txt
wink
Posted By: MDA

Re: Need help with reading a text file start to finish - 27/12/02 07:41 AM

Greetings and much apprecation Nimue, Dana

The reworked code worked well Nimue. I've tried to adjust the code you posted to read the file from a directory in the $mircdir\text folder. But without success trying these

{ .play -m1 $nick $mircdir\text ($2.txt) 1000 }

and

{ .play -m1 $nick $mircdir\text $2.txt 1000 }


Thanks again for your time and consideration,

MDA
Posted By: Cobra

Re: Need help with reading a text file start to finish - 27/12/02 08:01 AM

in regards to: { .play -m1 $nick $mircdir\text $2.txt 1000 }

the identifer $mircdir returns the current mirc directory with the apending \ already, so adding \text is redundant .. if u do //echo -a * $mircdir\text .. you will see path\\text with 2 \ 's

also note that $2.txt is seperated from your path by a space and therefore mirc trys to read it in as a seperate argument

we need to use $+() to atatch it to the string

as a result we end up with:

Code:
 
.play -m1 $nick $+($mircdir,text\,$2.txt) 1000 
 


will do: play -m1 nickname path\text\2ndarg.txt 1000

hope this was helpful

note $+(), its used to alow you to take bits of data that need to be self evaluated and collect them together into a single string ..

for example: a $+ b $+ c is the same as doing $+(a,b,c) both return the string abc

Cobra^
Posted By: MDA

Re: Need help with reading a text file start to finish - 27/12/02 08:19 AM

Thanks Cobra for the help and the explaination on that function for me.,




Best Regards to each,

MDA
© 2022 mIRC Discussion Forums