mIRC Home    About    Download    Register    News    Help

Print Thread
#241536 02/05/13 04:53 AM
Joined: Apr 2013
Posts: 27
R
RuLerZ Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Apr 2013
Posts: 27
Hello I am currently creating a polling system and it is working fine right now using !poll option1 option2 option3 creating 3 different poll options but if I mess up and do something like !poll option 1 option 2 option 3 it will create 6 poll options.
I have been trying to make it so you can include spaces and between every comma is a different option
EX: !poll option 1, option 2, option 3
which should return 3.

I am currently doing this: $regex($2-,/\b\w+\b/g)
Thank you for any help you can provide.

RuLerZ #241539 02/05/13 10:20 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Although you can use regex, it may be easier to just tokenize it.

Code:
on *:text:!poll *:#:{
  tokenize 44 $2-
  var %option1 = $1
  var %option2 = $2
  var %option3 = $3
}


Of course, you can shorten that and adjust it as needed. That's just an example with everything spread out so it's easy to see and understand. Also, if you are typing it on the same client as the script, you'd want to make that an on INPUT event instead, but the rest is the same.


Invision Support
#Invision on irc.irchighway.net
Riamus2 #241542 02/05/13 03:10 PM
Joined: Apr 2013
Posts: 27
R
RuLerZ Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Apr 2013
Posts: 27
Thank you very much for the quick response. That will do exactly what I needed to do to get the different poll options just needed to make a bunch of if statements to find the total poll options lol. Thank you so much!!

RuLerZ #241548 02/05/13 11:55 PM
Joined: Oct 2012
Posts: 164
D
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
Originally Posted By: RuLerZ
just needed to make a bunch of if statements to find the total poll options lol. Thank you so much!!

$0 will give you the number of options.
Code:
on *:text:!poll *:#:{
  tokenize 44 $2-
  var %options = $0
  var %option1 = $1
  var %option2 = $2
  var %option3 = $3
}

RuLerZ #241565 03/05/13 10:14 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
As Deega mentioned, you can use $0. Just to expand on that, 0 is used in many places in mIRC to get the total number of something. So anytime you are looking for a count for a given identifier, try replacing the item number with 0 and in most cases it will give you the total.


Invision Support
#Invision on irc.irchighway.net
Riamus2 #241658 10/05/13 11:57 PM
Joined: Apr 2013
Posts: 27
R
RuLerZ Offline OP
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Apr 2013
Posts: 27
Aww sweet!!! Ty so much made the code so much cleaner! you guys rock!!


Link Copied to Clipboard