mIRC Home    About    Download    Register    News    Help

Print Thread
#192421 01/01/08 02:16 AM
Joined: Jul 2007
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jul 2007
Posts: 8
hay was wondering if anyone could help me out, i'm trying to work out how i could work out the percentage of entrys in a file..

say if i've got 14 entrys stored in an ini file and i scan the file and find 7 matchs i want it to echo the percentage of it, obviously it would be 50% but i cant figure out how to go about getting it to echo?

any help would be great thanks. =D

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
How are you checking the number of matches? Whatever script you already have would be helpful to see as it would let us just make a few minor changes to it for you.

EDIT: Btw, it would also help to show the format of whatever file you're checking.

Last edited by Riamus2; 01/01/08 02:54 AM.

Invision Support
#Invision on irc.irchighway.net
Joined: Jul 2007
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jul 2007
Posts: 8
Code:
alias Scan {
  var %x = 1, %y = 0
  echo # 01A.Ban Scanning...
  while (%x < $nick(#,0)) {
    if ($hget(A.Ban,$+(*!,$ial($nick(#,%x)).addr))) {
      tokenize 32 $hget(A.Ban,$+(*!,$ial($nick(#,%x)).addr))
      echo # 01Found: $ial($nick(#,%x)).nick / $1  $+([,$2-,])
    }
    inc %x
  }
  echo # 01A.Ban End. 
}


i want it to show the percentage of matchs next to the "A.Ban End" message hope this helps more thanks.

Joined: Jul 2007
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jul 2007
Posts: 8
any help anyone? pls ? =(

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Be patient. People do sleep, you know. Especially after New Years Eve.

Code:
  echo # 01A.Ban End. $calc((%x - 1) / $hget(A.Ban,0).item * 100) $+ $chr(37)


That would assume you're checking % of matches in comparison the total names in table. If you're checking vs. total names in channel, use:

Code:
  echo # 01A.Ban End. $calc((%x - 1) / $nick($chan,0) * 100) $+ $chr(37)


Note that you


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2005
Posts: 827
P
Hoopy frood
Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Originally Posted By: Riamus2
Be patient. People do sleep, you know. Especially after New Years Eve.

Code:
  echo # 01A.Ban End. $calc((%x - 1) / $hget(A.Ban,0).item * 100) $+ $chr(37)


That would assume you're checking % of matches in comparison the total names in table. If you're checking vs. total names in channel, use:

Code:
  echo # 01A.Ban End. $calc((%x - 1) / $nick($chan,0) * 100) $+ $chr(37)


Note that you


wont %x always be 1 less than $nick(#,0) in that?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Look at his script and you'll understand. He's doing the /inc at the end of the while loop so that %x will always be 1 more than it should be by the time the loop ends.


Invision Support
#Invision on irc.irchighway.net
Joined: Jul 2007
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jul 2007
Posts: 8
hi thanks for the reply's, you were almost right but in the end i got it. just switched a few things around =D

Code:
$+($calc(%y / $hget(A.Ban,0).item * 100),$chr(37))


thanks for the help though. =)

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
$+() is completely unnecessary there. It does absolutely nothing they way you have it. And your script that you displayed used %x, not %y, so if you needed %y instead of %x, you displayed the wrong script.


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
.. it's putting the % symbol on the end ..

$+(..., $chr(37))

or
... $+ $chr(37)

*shrug*

Bekar #192491 02/01/08 12:41 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Heh, missed that.


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2005
Posts: 827
P
Hoopy frood
Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Originally Posted By: Riamus2
Look at his script and you'll understand. He's doing the /inc at the end of the while loop so that %x will always be 1 more than it should be by the time the loop ends.


sorry you confused me

the %x is incremented outside the if statement, so what has %x got to do with the end result? %x is just used to loop through the channel and pick each user via $nick(#,%x)

shouldn't there be an 'inc %y' inside the if statement (so at the end, we can use %y to return total number of banned users, divide this by total users in channel and * 100)

Last edited by pouncer; 02/01/08 09:00 PM.
Joined: Jul 2007
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jul 2007
Posts: 8
ok to stop all the confusion here is the finished code

Code:
alias Scan {
  var %x = 1, %y = 0
  msg # 01A.Ban Scanning...
  while (%x < $nick(#,0)) {
    if ($hget(A.Ban,$+(*!,$ial($nick(#,%x)).addr))) {
      tokenize 32 $hget(A.Ban,$+(*!,$ial($nick(#,%x)).addr))
      msg # 01Found: $ial($nick(#,%x)).nick / $1  $+([,$2-,]) | inc %y
    }
    inc %x
  }
  msg # $+(01,$calc(%y / $hget(A.Ban,0).item * 100),$+(,$chr(37),)) Of A.Ban Listed.
}


and i used $+(..) cos it saves using alot of $+ to add colour and boldness to the text, and to add the chr at the end.

Last edited by synedyne; 02/01/08 10:51 PM.
Joined: Oct 2005
Posts: 827
P
Hoopy frood
Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Exactly as I pointed out in my msg, incrementing %y inside the if statement .. then using %y in the last echo to calculate the percentage.

The %x variable has nothing to do with it, which is what riamus is saying, which is why I was getting confused.


Link Copied to Clipboard