mIRC Home    About    Download    Register    News    Help

Print Thread
#194653 09/02/08 02:51 AM
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
Code:
;Progress Bar By Foshizzle
;Syntax: /drawpbar -lpt @Window Color Percent X Y W H Text
alias drawpbar { 
  if (-* iswm $1) { %switch = $remove($1,-) | tokenize 32 $2- }
  var %h $5 | var %c 15790320 | while (%h < $calc($5 + $7)) {
    drawline -nr $1 %c 1 $4 %h $calc($4 + $6) %h
    inc %h | dec %c 5
  }
  var %3 . $+ $3 | var %h2 $5 | var %c2 $2 | while (%h2 < $calc($5 + $7)) {
    drawline -nr $1 %c2 1 $4 %h2 $calc($4 + ($6 * %3)) %h2
    inc %h2 | dec %c2 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 | %p = 0 | clear @Picwin | progcontin }
alias progcontin { $iif($window(@Picwin), , halt)
  drawpbar @Picwin 1333221 %p 10 10 200 20 
  echo 2 -m %p
  $iif(%p < 100, inc %p, %p = 0) | .timer -m 1 100 progcontin
}

why does it draw the progress bar every 25% and then resets and continues like normal.. and loops like that(test it to see)


This is not the signature you are looking for
foshizzle #194654 09/02/08 04:49 AM
Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
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:

Code:
var %3 . $+ $3 | var %h2 $5 | var %c2 $2 | while (%h2 < $calc($5 + $7)) {

To simplify the issue:

Code:
   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:

Code:
;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
    }
  }
}

Bekar #194667 09/02/08 04:51 PM
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
thx... i guess
switch is used for later... im not done with this... and i want it to loop

and does anyone know a formula for transparency / translucency

Last edited by foshizzle; 09/02/08 05:01 PM.

This is not the signature you are looking for
foshizzle #194728 10/02/08 05:09 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
That makes no sense.
You make no sense.

I suggest you stop using these forums until you learn how to form a question, as nobody is going to be able to help you anyway.

hixxy #194741 11/02/08 12:10 AM
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
?


This is not the signature you are looking for

Link Copied to Clipboard