Oh, wow.. The sheer amount of issues with this code..
Lets see if we can break them down.
First run through goes up in 10% increments, before hitting 100%, then starting at 11%.
It continually loops due to the incredibly stupid $iif() which reset's %p every time it gets near 100.
It uses a halt combined with an $iif() when a simple if structure will suffice.
%switch is defined, but never used or parsed, so what's it's point?
But the root cause is this line:
var %3 . $+ $3 | var %h2 $5 | var %c2 $2 | while (%h2 < $calc($5 + $7)) {
To simplify the issue:
var %3 . $+ $3
-> var %3 = . $+ 1
-> var %3 = 0.1
-> 0.1 = 10%
If you had have used the correct syntax for the
/var to begin with, you would have seen that much earlier.
So, we clean up the code, get rid of most of the abiguities, remove the constant re-calulation of fixed numbers, remove the global un-needed variable, and see what becomes of it:
;Progress Bar By Foshizzle
;Syntax: /drawpbar -lpt @Window Color Percent X Y W H Text
alias drawpbar {
var %y = $5, %c = 15790320, %width = $calc($4 + $6), %top = $calc($5 + $7)
while (%y < %top) {
drawline -nr $1 %c 1 $4 %y %width %y
inc %y
dec %c 5
}
var %perc = $3 / 100, %y = $5, %c = $2, %width = $calc($4 + ($6 * %perc))
while (%y < %top) {
drawline -nr $1 %c 1 $4 %y %width %y
inc %y
dec %c 5
}
drawrect -rn $1 $rgb(140,140,140) 1 $4 $5 $6 $7
drawdot $1
}
alias pbarex {
window -pkodCfB +t @Picwin -1 -1 220 40
clear @Picwin
progcontin
}
alias progcontin {
if ($window(@Picwin)) {
var %p = $iif($1 isnum, $1, 0)
drawpbar @Picwin 1333221 %p 10 10 200 20
if (%p < 100) {
inc %p
.timer -m 1 100 progcontin %p
}
}
}