$percent
mIRC Code
+ 0 likes
Please Register to submit score.
| Average Score | 0.0 (of 0 scores) |
| Date Added | Aug 24, 2008 |
| Last Updated | Aug 24, 2008 |
| Tags | alias custom mirc percent |
Introduction
| 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. |
mIRC Snippet:
$percent
Posted on Aug 24, 2008 3:25 pm
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() :-)
Hope this helps you! :-)
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! :-)










