mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2014
Posts: 11
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Mar 2014
Posts: 11
Hello friends, I am pretty new to mirc. I want to make an on text command that only works on lines that are contained in a specified text file. So for example if i have a text file that looks like this:
apple
orange

I only want it to perform the on text action if someone types "apple" or "orange". If this is possible then can I use wildcards with it so it would also work when someone types "oranges" or "borange".

Thanks!

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
Check this recent thread and look at how $read is used to match a line in a text file with the 'wn' switches.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Probably not the best way of doing it but at the minute its the best I can think of.

Code:
On *:Text:*:#: {
  var %x = $$1-, %i = 1
  while (%i <= $numtok(%x,32)) {
    if ($read(filename.ext,nw,$gettok(%x,%i,32))) msg # $ifmatch was said.
    inc %i
  }
}


Change the filename.ext to the txt file you will be using.

Hopefully that works.

Joined: Mar 2014
Posts: 11
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Mar 2014
Posts: 11
Thanks, that worked, but the wildcarding doesn't seem to work, it only performs the action if $- matches the line in the txt file exactly. I tried adding * around it, $read(File.txt,nw, *$-*) but it doesn't seem to work.(also tried setting $- to a variable and doing $read(File.txt,nw, *%variable*) but that didn't work either)
edit: i realised that this won't work for me, since i need to check if the word entered contains any of the lines in the text file

edit2: I ended up using while loops and tracking the size of the list, thanks for the help

Last edited by Tehpolecat; 31/03/14 02:45 AM.
Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
I originally that you wanted to match the whole sentence ($1-) against lines in a file, in which case $read would be enough (the loop on lines is made by $read when using the 'w' switch), but if you want to check each word in the sentence against lines in a file, you would need $read + a loop like it was shown.
In that code, to add what you want with the wildcard, you would use $+() (or $+, where "a $+ b" is "ab" and is equivalent to $+(a,b) : $+(*,$gettok(...),*), *$gettok(...)* wouldn't get mirc to evaluate the $gettok since there is a * before, it's just a litteral string.

From you first edit in your last post, it looks like you want to check each line in the file against the unique word entered ($1- is only one word), your second edit suggests you're using an inefficient method, if you could clarify with an concrete example what you want to do, we might give you better alternative.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard