mIRC Home    About    Download    Register    News    Help

Print Thread
#3396 25/12/02 12:52 AM
Joined: Dec 2002
Posts: 40
L
Lucifer Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Dec 2002
Posts: 40
I was wondering if anyone knew a faster way to accomplish this.
Code:
aw.away {
  var %i = $did(aw,10)
  hadd -m away msg $puttok($hget(away,msg),$did(aw,10),2,9)
  var %i $aw.eval(%i) 
  window -Bhp @away -1 -1 600 60
  if (%i == $null) { drawfill -h @away 1 1 1 15 | goto 1  }  
  drawtext -pbh @away 0 1 tahoma 30 0 0 %i
  :1  
  drawsave @away system\away.bmp
  did -g aw 9 system\away.bmp
  window -c @away
}

Thanks

#3397 25/12/02 05:53 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
On line 4 of your alias, use %i = $aw.eval(%i) since you've already declared %i as a local variable. Also, for most intents and purposes, (!%i) means the same thing as (%i == $null) if %i can only be some sort of away message, and not 0 or $false. That being said, you've not told us what is contained in ID 10, nor what will be returned from $aw.eval(%i). ID 9 is an icon control that will hold the .bmp that you're creating (over and over).

It looks like ID 10 might be an editbox and should hold an away message with something contained within it that needs to be resolved with $aw.eval(%i), but what that might be or what will be returned from the eval, we cannot guess. It looks like it formats the text in ID 10 with bold, underline, foreground and background control codes, or perhaps uses the value in ID 10 to come up with its own formatted string.

We do not know what all is contained in $hget(away,msg), but we do know, from the code posted, that the second tab-separated token will be the away message. You could check to see if ($did(aw,10) != $gettok($hget(away,msg),2,9)) before continuing on with rebuilding the .bmp each time. If the away message is the same, there'd be no reason to rebuild the .bmp with the same message; you'd only need to rebuild the .bmp if the message has changed.

Since you are creating @away to be a borderless, hidden picture window, why would you use the -h parameter on your drawfill and drawtext commands? The user will never see that window's taskbar button.

So, assuming that the assumptions I've made are correct, your revised code might look like this:
Code:

aw.away {
  if ($did(aw,10) != $gettok($hget(away,msg),2,9)) {
    hadd -m away msg $puttok($hget(away,msg),$did(aw,10),2,9)
    window -Bhp @away -1 -1 600 60
    if ($aw.eval($did(aw,10))) drawtext -pb @away 0 1 tahoma 30 0 0 $ifmatch
    else drawfill @away 1 1 1 15
    drawsave @away system\away.bmp
    did -g aw 9 system\away.bmp
    window -c @away
  }
}

Obviously, if you are just making an icon to show the time they set themselves away, this sort of solution will be fine.

However, if you are going to be constantly updating this icon's picture with the elapsed seconds since they set away, then the only real savings is to stop creating and destroying @away (just create it and keep re-using it). Note that it will be faster to just hadd the value than retrieving it, parsing it for the second token, retrieving the text in ID 10 and then testing the two for inequality before possibly doing the hadd. Thus, the revised code might look like this:
Code:

aw.away {
  hadd -m away msg $puttok($hget(away,msg),$did(aw,10),2,9)
  if (!$window(@away)) window -Bhp @away -1 -1 600 60
  if ($aw.eval($did(aw,10))) drawtext -pb @away 0 1 tahoma 30 0 0 $ifmatch
  else drawfill @away 1 1 1 15
  drawsave @away system\away.bmp
  did -g aw 9 system\away.bmp
}

You would close the @away window when you closed your aw dialog.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C

Link Copied to Clipboard