(mIRC) /disks

By raccoon on Apr 23, 2015

Disks is a simple alias for displaying system disk usage. It also demonstrates a bit of 'spaghetti code' with a /goto label jump.

Output

* disks: C:\ | used:  234GB ( 79%) | free: 63.6GB ( 21%) | size:  297GB | (no label) (fixed)
* disks: E:\ | used: 1.81TB (100%) | free: 9.22GB (  0%) | size: 1.82TB | 2TB External (fixed)
* disks: G:\ | used:  917GB ( 99%) | free: 13.7GB (  1%) | size:  931GB | Toshiba Ext HDD (fixed)
* disks: H:\ | used: 4.00GB ( 27%) | free: 10.9GB ( 73%) | size: 14.9GB | READYBOOST (removable)
* disks: ----+---------------------+---------------------+--------------+------------------------
* disks: (4) | used: 2.94TB ( 97%) | free: 97.5GB (  3%) | size: 3.03TB | System Total

mIRC Script (Aliases section)

; Usage: /disks (or) /disks all
disks { ; by Raccoon 2015
  linesep
  var %i = 1, %usedt, %freet, %sizet, %disks, %all, %jump
  if ($1 == all) var %all = $true
  while ($disk(%i).type) {
    var %type = $v1, %path = $disk(%i).path, %unc = $disk(%i).unc
    var %label = $iif($disk(%i).label,$v1,(no label))
    var %free = $disk(%i).free, %size = $disk(%i).size, %used = $calc(%size - %free)
    :disksjump
    var %freeb = $padr($bytes(%free,3).suf,6)
    var %sizeb = $padr($bytes(%size,3).suf,6)
    var %usedb = $padr($bytes(%used,3).suf,6)
    var %freep = $padr($round($calc(%free / %size * 100),0) $+ %,4)
    var %usedp = $padr($round($calc(%used / %size * 100),0) $+ %,4)
    if ($disk(%i)) || (%all) || (%jump) {
      inc %usedt %used | inc %freet %free | inc %sizet %size | inc %disks
      echo -atic info * disks: %path $(|) $&
        used: %usedb ( $+ %usedp $+ ) $(|) $&
        free: %freeb ( $+ %freep $+ ) $(|) $&
        size: %sizeb $(|) $&
        $iif(%jump, System Total, %label ( $+ %type $+ ) %unc)
    }
    inc %i
  }
  if (%disks) && (!%jump) {
    echo -atic info * disks: $+($str(-,4),+,$str(-,21),+,$str(-,21),+,$str(-,14),+,$str(-,24))
    var %free = %freet, %used = %usedt, %size = %sizet, %path = ( $+ %disks $+ )
    var %jump = $true
    goto disksjump
  }
  linesep
}

padr { return $str($iif($3 != $null,$3,$chr(160)),$calc($2 - $len($1))) $+ $1 } ; by Raccoon 2015

(Update) Expanding a little further, I decided to add a column showing the percentage of the relative size of each disk. This required advanced knowledge of the total bytes of every disk prior to main iteration loop, so a second loop is added and %sizet is quickly tallied. Sure, it'd be possible to collect all disk vitals before echoing the output, but that would mean creating arrays to save each parcel of information... maybe not worth it.

* disks: C:\ | used:  231GB ( 78%) | free: 66.4GB ( 22%) | size:  297GB ( 10%) | (no label) (fixed)
* disks: E:\ | used: 1.81TB (100%) | free: 9.22GB (  0%) | size: 1.82TB ( 60%) | 2TB External (fixed)
* disks: G:\ | used:  920GB ( 99%) | free: 10.6GB (  1%) | size:  931GB ( 30%) | Toshiba Ext HDD (fixed)
* disks: H:\ | used: 4.00GB ( 27%) | free: 10.9GB ( 73%) | size: 14.9GB (  0%) | READYBOOST (removable)
* disks: ----+---------------------+---------------------+---------------------+------------------------
* disks: (4) | used: 2.94TB ( 97%) | free: 97.3GB (  3%) | size: 3.03TB (100%) | System Total
; Usage: /disks (or) /disks all
disks { ; by Raccoon 2015
  linesep
  var %i = 1, %sizet
  while ($disk(%i).type) { if ($disk(%i)) inc %sizet $disk(%i).size | inc %i }
  var %i = 1, %usedt, %freet, %disks, %all, %jump
  if ($1 == all) var %all = $true
  while ($disk(%i).type) {
    var %type = $v1, %path = $disk(%i).path, %unc = $disk(%i).unc
    var %label = $iif($disk(%i).label,$v1,(no label))
    var %free = $disk(%i).free, %size = $disk(%i).size, %used = $calc(%size - %free)
    :disksjump
    var %freeb = $padr($bytes(%free,3).suf,6)
    var %usedb = $padr($bytes(%used,3).suf,6)
    var %sizeb = $padr($bytes(%size,3).suf,6)
    var %freep = $padr($round($calc(%free / %size * 100),0) $+ %,4)
    var %usedp = $padr($round($calc(%used / %size * 100),0) $+ %,4)
    var %sizep = $padr($round($calc(%size / %sizet * 100),0) $+ %,4)
    if ($disk(%i)) || (%all) || (%jump) {
      inc %usedt %used | inc %freet %free | inc %disks
      echo -atic info * disks: %path $(|) $&
        used: %usedb ( $+ %usedp $+ ) $(|) $&
        free: %freeb ( $+ %freep $+ ) $(|) $&
        size: %sizeb ( $+ %sizep $+ ) $(|) $&
        $iif(%jump, System Total, %label ( $+ %type $+ ) %unc)
    }
    inc %i
  }
  if (%disks) && (!%jump) {
    echo -atic info * disks: $+($str(-,4),+,$str(-,21),+,$str(-,21),+,$str(-,21),+,$str(-,24))
    var %free = %freet, %used = %usedt, %size = %sizet, %path = ( $+ %disks $+ )
    var %jump = $true
    goto disksjump
  }
  linesep
}

padr { return $str($iif($3 != $null,$3,$chr(160)),$calc($2 - $len($1))) $+ $1 } ; by Raccoon 2015

Comments

Sign in to comment.
ovelayer   -  Apr 24, 2015

i have a toshiba satellite running windows 8.1
when i use this i get
(7:26 pm) <~xXBERTOXx> info disks: C:\ | used: () | free: () | size: () | TI10653400C (fixed)
(7:26 pm) <~xXBERTOXx> info
disks: D:\ | used: () | free: () | size: () | Audio CD (cdrom)
(7:26 pm) <~xXBERTOXx> info disks: E:\ | used: () | free: () | size: () | (no label) (cdrom)
(7:26 pm) <~xXBERTOXx> info
disks: ----+---------------------+---------------------+---------------------+------------------------
(7:26 pm) <~xXBERTOXx> info * disks: (3) | used: () | free: () | size: () | System Total

doesn't seem to show my hd info =(

raccoon  -  Apr 25, 2015

Wow, that's really big :) Huh, I don't know why it's not working for you. mIRC 7.41?

Sign in to comment

raccoon   -  Apr 23, 2015

@Hawkee : What can you do about a Plain Text 'code' or 'pre' box that doesn't include syntax highlighting, and optionally no line numbers?

Hawkee  -  Apr 24, 2015

What would you like to do?

raccoon  -  Apr 24, 2015

See the 'Output' code section. I tried to use <.pre> tags or markdown indentation, but no dice ... every other line gets italicized for some reason. It'd be cool if there was a code type "Plain Text" which didn't highlight anything.

Hawkee  -  Apr 25, 2015

You can use the Markdown equivalent of a quote by starting the first line with a > and ending with a double line break. No need to use the code boxes.

raccoon  -  Apr 26, 2015

Do these also use monospace?
+---------+
| testing |-+
+---------+ |
'---------+

like so?

+---------+
| testing |-+
+---------+ |
  '---------+

What are the coloring rules being used if no code-type is specified?

Hawkee  -  Apr 28, 2015

No monospace in blockquotes. I believe the code boxes default to C-like which supports things like Java, C++, etc.

Sign in to comment

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.