mIRC Home    About    Download    Register    News    Help

Print Thread
#177929 03/06/07 10:38 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Someone that have a smart idea on how to calc how long it have been since a given date as folow: Thursday, April 5 2007 . Someone that know how to solve that? the day, month date, year can be diffrent from time to time.

;------

I add this here too, this is from the help file:

$disk(path|N)

Returns information about the specified hard disk, where N = 0 for total available drives, and N > 0 to access each drive.

Properties: type, free, label, size, unc, path
;--------

how would i use that if i want to return the label from a disk? cant solve it frown

Last edited by sparta; 03/06/07 12:03 PM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Code:
$duration($calc($ctime - $ctime(05/04/07 00:00)))

Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
  • //echo -ag $disk(1).label

This will return the label of the 1st hard disk.

  • //echo -ag $disk(D).label
    //echo -ag $disk(D:).label
    //echo -ag $disk(D:\).label

These will all return the label of disk "D".

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
As an alternative to SladeKraven's answer for the date question, you could use
Code:
on *:text:!date*:#:{
  if !$2 { .notice $nick Date not provided }
  elseif !$ctime($2-) {
    .msg $nick Invalid format for date detected
    .msg $nick Please use one of the following formats
    .msg $nick January 1 1970
    .msg $nick 3rd August 1987 3:46pm
    .msg $nick 21/4/72 1:30:37
    .msg $nick Wed 1998-3-27 21:16
  }
  else {
    .msg $chan $duration($abs($calc($ctime - $ctime($2-))))
  }
}

P.S.: I have a Count Down Timer on Hawkee that you might be interested in.

Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Extending that to use /play in place of /msg.
Also matches the first word exactly. smile
Code:
on $*:text:/^!date\b/Si:#:{
  if !$ctime($2-) { .play -m1t!Date $nick $qt($script) }
  else msg # Time since/until $2-: $duration($abs($calc($ctime - $ctime($2-))))
}
/*
This section is the topic for the play command above.
It can be in the scriptfile, commented out like this.
[!Date]
Invalid format for date detected
Please use one of the following formats
!Date January 1 1970
!Date 3rd August 1987 3:46pm
!Date 21/4/72 1:30:37
!Date Wed 1998-3-27 21:16
[Endof!datetopic]
*/


Last edited by deegee; 03/06/07 06:15 PM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The reason I included $abs is in case someone wanted to be a smart alec and use a date that's in the future, which would return a negative number in the $calc and an error for $duration.

Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
True if they did that it would return a minus seconds value (-NNNNsecs) without $abs(). Good point. wink

Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
didnt reply to anyone special, but 1 more question, if i want to return the disk size to popups, how the h*ll do i do that? $hdisk should return it, but have been trying a while, and i cant get it to return the value. and i use:
Code:
alias hdisk {
  return {
    var %ddisk = $chr(%disk)
    var %HDD_total = $calc(%HDD_total + $bytes($disk(%ddisk).size,g))
    $calc(%HDD_total + $bytes($disk(%ddisk).size,g))
  }
}

i do something wrong, but dunno what smirk


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
This will return the total size of all of your fixed hard drives.
Code:
menu {
  Disk Size : echo -a $hdisk
}
alias -l hdisk {
  var %a = 1, %b = $disk(0), %disk
  while %a <= %b {
    if $disk(%a).type == fixed {
      inc %disk $disk(%a).size
    }
    inc %a
  }
  return $bytes(%disk,g)
}

Last edited by RusselB; 03/06/07 08:40 PM.
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Code:
menu channel {
  Disks
  .$submenu($disks($1))
}

alias disks {
  if ($1 == begin) return -
  if (($1 > 0) && ($1 <= $disk(0))) { return $remove($disk($1).path ,:\) : { echo -a $bytes($disk($1).size,g).suf } }
  if ($1 == end) return -
}


Do you mean like this?

Right click in channel or type //echo -a $hdisk(N).

RusselB beat me to it.

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Hey Russel, you aren't specifying anywhere for the menu to popup. smile

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
oops -- will edit & correct my code.

I see you and I have a slight disagreement as to what the OP was actually looking for..a list of the disk sizes in the menu portion (as your code would do) or returning the total size of all hard drives (which mine would do).

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Once the disks are clicked, the sizes are returned.

Last edited by SladeKraven; 03/06/07 08:47 PM.
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
i dont need the whole code, i only need to return the disk size to the popup by use $hdisk. by the way, didnt get the code for the disk size to work, the others worked tho, thnx.. smile

Last edited by sparta; 03/06/07 09:03 PM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
By disk size, are you referring to the size of each disk on a disk by disk basis, or the total size for all of the disks?

Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I wanted it for every drive "C to Z", but i solved it. smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Wasn't that what my one did?


Link Copied to Clipboard