Mirc dialoged stopwatch

By [Plornt] on Dec 27, 2009

As im learning how to make dialogs, this morning ive been making lots of little cool things, heres one of them. This dialog is a stop watch that allows you to stop start and reset like a conventional stop watch, you can even copy the time to the clip board. The dialog allows you to start the stop watch then close it, so next time you can re open it aand it will continue counting.

[Size=20]Issues[/size]

Theres one main problem with the mileseconds, and that is there not totally precise, whicch kinda defeats the whole point of them, so if you can tell me why this my be then ill appriciate it :).

[Size=20]Commands[/size]

Because the dialog has all its commands as buttons the only thing you have to do to get the dialog up is right click the whitespace and select Utilitys >> Stopwatch.

dialog stop {
  title "Stopwatch"
  size -1 -1 225 147
  box "Stopwatch", 1, 7 8 210 132
  edit "00:00:00", 2, 42 32 78 20
  edit "00", 3, 126 32 46 20
  text ":", 4, 121 32 4 17
  button "Start", 5, 14 72 65 25
  button "Pause", 6, 144 72 65 25
  button "Reset", 7, 94 72 38 25
  button "Copy to Clipboard", 8, 14 104 195 25
}
menu channel,query {
  .Utilitys
  ..Stop watch:/dialog -m stop stop

}
On *:dialog:stop:SCLICK:8: {
  /clipboard $did(2).text $did(3).text
}
ON *:dialog:stop:close:*: {
  .timert? off
}
ON *:dialog:stop:init:*: {
  if (%stop.on) {
    did -b stop 5,7
    did -e stop 6 
    .timert1 0 1 did -ar stop 2 $!hhnnss
    .timert2 0 0.01 did -ar stop 3 $!mile
    ;Bottom 2 to keep the time

    .timerk2 0 0.0 inc %stop.ms
    did -b stop 2,3    
  }
  else {
    did -b stop 2,3

    did -b stop 6,7
  }
}
alias hhnnss { 
  return  $asctime($calc($ctime - %stop.time),HH:nn:ss)
}
alias mile {

  if (%stop.ms > 99) { set %stop.ms 0 } 
  return %stop.ms
}
On *:dialog:stop:SCLICK:6: {
  .timert? off
  did -e stop 5,7
  did -b stop 6 
}
On *:dialog:stop:SCLICK:7: {
  .timert? off
  .timerk? off
  did -ar stop 2 00:00:00
  did -ar stop 3 00
  unset %stop.*

}

On *:dialog:stop:SCLICK:5: {
  if (!%stop.on) {
    set %stop.time $ctime
    set %stop.ms 0

    set %stop.on 1
  }
  did -b stop 5,7
  did -e stop 6 
  .timert1 0 1 did -ar stop 2 $!hhnnss
  .timert2 0 0.01 did -ar stop 3 $!mile
  ;Bottom 2 to keep the time

  .timerk2 0 0.0 inc %stop.ms
}

Comments

Sign in to comment.
Silo   -  Dec 29, 2009

use the -m flag on you timer for milliseconds.

 Respond  
Atr   -  Dec 27, 2009

Just an idea: change 'Stop' to 'Pause' as that's what it does.

'Utilities' rather than 'Utilitys'.

And LOL @ the milliseconds, I see what you mean! xD

 Respond  
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.