The additional .s prop is to strip any color from the string
Examples:
$p.bar(40%).s
would return > [||||......]
$p.bar(1/2)
would return > [|.] (in color)
Update
You can now add extra paramaters to change the values using the identifier. $p.bar(N,X,-) would return the [X---------]
Or use $p.bar(N,{,X,-,}) and it will return {X---------} etc. :)
alias p.bar {
; --------------------
; Usage: $p.bar([N]%|[X]/[C])[.s]
; Either N%, where N is a percentage (out of 100)
; Or X/C where X is a number out of C
; --------------------
; The additional .s prop is to strip any color from the string
; Examples: $p.bar(40%).s would return [||||......]
; : $p.bar(1/2) would return [|.] (in color)
; edit paramaters here
; --------------------
var %open.char = 0,1[
var %clos.char = 0,1]
var %pbar.fill = 4|
var %pbar.empt = 0,1.
if ($3) { var %pbar.fill = $2, %pbar.empt = $3 }
if ($5) { var %open.char = $2, %pbar.fill = $3, %pbar.empt = $4, %clos.char = $5 }
; -----------------
; stop editing here
; -----------------
if ($regex($1,^\d*/\d*$)) { var %p1 = $gettok($1,1,47)), %p2 = $calc($gettok($1,2,47) - %p1) }
elseif ($regex($1,^\d*%$)) { var %p1 = $calc($remove($1,%) / 10)), %p2 = $calc(10 - %p1)) }
if (%p1) {
var %r = $+(%open.char,$str(%pbar.fill,%p1),$str(%pbar.empt,%p2),%clos.char,$iif($right(%clos.char,-1) != ,))
return $iif($prop == s,$strip(%r),%r)
}
else { return 2* $!pbar: error }
}
Nice, not quite as good to look at as one I found trawling the net but the extra options are a great addition.
7/10
note:-
I found one that used pure colour and added the percentage inside the bar but was restricted to $percentbar(total/percent) format EG: $percentbar(1300,487) or $percentbar(100/25)