mIRC Home    About    Download    Register    News    Help

Print Thread
Return parameter $3 to parameter %var #237786 03/06/12 03:23 AM
Joined: Jun 2012
Posts: 5
D
dreadofmondays Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Jun 2012
Posts: 5
Hello!
Just for fun, I'm trying to do an <x> is <y> detecting script, like with the XKCD bot. I can return which token the 'is' is, as a variable. So then I want to return the parameters between $3 and the 'is' - if IS is parameter 4, I want to return $3-4. If IS is parameter 7, I want to return $3-7.
I don't how to do this. :C I tried using a variable: $3-%var but that doesn't seem to work. Does anyone know a method for doing this? shocked
Thanks in advance!

Re: Return parameter $3 to parameter %var [Re: dreadofmondays] #237789 03/06/12 05:44 AM
Joined: Jan 2004
Posts: 1,273
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,273
It's probably easier/cleaner to use a regex. The following will isolate <x> and <y> for you.

Code:
on $*:text:/(.+) is (.+)/iS:#:{
  echo -ag <x> = $regml(1)
  echo -ag <y> = $regml(2)
}

Re: Return parameter $3 to parameter %var [Re: Loki12583] #237790 03/06/12 06:34 AM
Joined: Jun 2012
Posts: 5
D
dreadofmondays Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Jun 2012
Posts: 5
I tried it, and it works fine, thanks smile
Regexes are new to me so I did a bit of reading on them, but I'm still confused as to what the / and the /iS is doing. smirk

Last edited by dreadofmondays; 03/06/12 09:09 AM.
Re: Return parameter $3 to parameter %var [Re: dreadofmondays] #237791 03/06/12 08:06 AM
Joined: Jan 2004
Posts: 1,273
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,273
/ is used to surround the actual regex, i and S are modifiers for case insensitivity and to strip out control codes (color, bold, etc.)

Re: Return parameter $3 to parameter %var [Re: dreadofmondays] #237796 03/06/12 02:49 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Just so you are aware, you can use a variable the way you were trying, but you have to include a space before the variable and use $gettok()...

$gettok($1-,3- %var,32)


Invision Support
#Invision on irc.irchighway.net
Re: Return parameter $3 to parameter %var [Re: Riamus2] #237797 03/06/12 10:22 PM
Joined: Jun 2012
Posts: 5
D
dreadofmondays Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Jun 2012
Posts: 5
Ah, thanks, that's what I wanted to know. smile