Top

$percent


mIRC Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  0.0 (of 0 scores)
Date Added  Aug 24, 2008
Last Updated  Aug 24, 2008
Tags  alias  custom  mirc  percent 

Introduction

A really really simple custom alias, but this can cut down on a lot of calculations.

Code:

$percent(N,C)
Returns how much percentage N is of C.
 
Properties:
  suf         Appends the percentage sign to the end of the value
 
Examples:
               //echo -a $percent(2,10)
               //echo -a $percent(8,24).suf
 
Tips:
If you're using any number identifiers on the text such as $int or $round, you shouldn't use the .suf property.
 
If you manage to get a recurring percentage number such as 33.3333 recurring, $percent will return a maximum of 6 digits after
the decimal point.


Grab the Code

alias percent {
  if ($isid) {
    if (!$1) && (!$2) { return $null }
    else {
      if (!$prop) { return $calc($1 / $2 * 100) }
      if ($prop == suf) { return $calc($1 / $2 * 100) $+ % }
    }
  }
}

Comments

  (5)  RSS
EL
Comments: 1,125
 
mIRC Snippet:  $percent
Posted on Aug 24, 2008 3:05 pm
;o /me tests;p
Zmodem
Comments: 306
 
mIRC Snippet:  $percent
Posted on Aug 24, 2008 3:25 pm
You don't need your 'else' statement. mIRC will automatically keep going in the case of the 'if' statement being false. You also don't need to 'return $null' as 'return' in general gives an empty (or $null) returned value when no other value is specified.

Another tip I can give you is that if you check that '$prop == suf' before anything, you can deduce that you can return the value with the proper suffix. Otherwise, the very next line is done (returning with no suffix) based on the fact that the 2 proper comparisons have already been made, saving you space and time for coding.

You also do not need the second 'if' statement that makes sure the values are $null then returns. Just compare all of the things you want 'true'.

Note: Appending extra braces when comparing multiple operands at a time, ie: if ((!$1) && (!$2)), makes the parser run quicker.

NEW: I forgot to mention the power of $iif() :-)

Code:

alias percent $iif(($isid) && ($1) && ($2),return $calc($1 / $2 * 100) $+ $iif($prop == suf,%))



Hope this helps you! :-)
EL
Comments: 1,125
 
mIRC Snippet:  $percent
Posted on Aug 24, 2008 6:13 pm
Rofl Typo? ;o cant be...maybe napa? nah couldnt be! oh oh its zmodem?!?!?! rofl wtf.Nice tatt btw ;p
Eugenio
Comments: 1,193
 
mIRC Snippet:  $percent
Posted on Aug 24, 2008 6:17 pm
lmaoooo
^Neptune
Comments: 599
 
mIRC Snippet:  $percent
Posted on Aug 27, 2008 5:46 pm
Woah, that's certainly been shortened there D:

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom