$pct - percentage calculator

By Sight on Nov 01, 2007

; $pct - Sight
; ;; What this is ;;
; $pct calculates the percentage of a specified property in a string
; ;; Why make this ;;
; This can be useful for many things. (Such as kickers) The nice thing about this is that it factors in regex so you can use simple regex properties for the most part. ;)
; ;; Syntax ;;
; $pct(sting,n/.cs,n/.cs).property (n and .cs aren't needed)
; ;; Examples ;;
; $pct(aAAA).a would return 25
; $pct(aAAA,n).a would still return 25 but just removes spaces when calculating
; $pct(aAAA,.cs).a would return 100 because it specifies case incensitivity
; $pct(aAAA,n,.cs).a would return 100 and would not factor in spaces

; $pct - Sight
; ;; What this is ;;
; $pct calculates the percentage of a specified property in a string
; ;; Why make this ;;
; This can be useful for many things. (Such as kickers) The nice thing about this is that it factors in regex so you can use simple regex properties for the most part. ;)
; ;; Syntax ;;
; $pct(sting,n/.cs,n/.cs).property (n and .cs aren't needed)
; ;; Examples ;; 
; $pct(aAAA).a would return 25
; $pct(aAAA,n).a would still return 25 but just removes spaces when calculating
; $pct(aAAA,.cs).a would return 100 because it specifies case insensitivity
; $pct(aAAA,n,.cs).a would return 100 and would not factor in spaces

alias pct { if ($$1) { return $calc($regex($$1,/[ $+ $prop $+ ]/g $+ $iif($2 = .cs || $3 = .cs,i)) / $len($iif($2 = n || $3 = n,$remove($$1,$chr(32)),$1)) * 100) } }

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.