mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
$submenu #185194 06/09/07 08:50 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I using this code:
Code:
$submenu($disks($1))

alias disks {
  if ($1 == 1) && ($disk(c)) return Disk &C $chr(187) Size $+ $chr(58) $hd1 :{ diskziz 99 }
  if ($1 == 2) && ($disk(d)) return Disk &D $chr(187) Size $+ $chr(58) $hd2 :{ diskziz 100 }
  if ($1 == 3) && ($disk(e)) return Disk &E $chr(187) Size $+ $chr(58) $hd3 :{ diskziz 101 }
}

and it working ok, but i have one problem, that's the $hd1 - $hd2 - $hd3 .. it wont return the size of the disk, how ever if i echo it to me, then it return the size, any ideas why it's not shown in popups? smirk


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: $submenu [Re: sparta] #185197 06/09/07 09:53 AM
Joined: Feb 2006
Posts: 546
J
jaytea Offline
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
it should be working, it's just part of the command. the first : indicates the end of the item name, even if you escape it with $chr(58). there's no way around this unfortunately ;( choose a different character to use after 'Size'



"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Re: $submenu [Re: jaytea] #185198 06/09/07 10:04 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Ty, that solved the problem smile

a new problem tho crazy

Now my code looks like:
Code:
alias disks {
  var %id = 1
  var %dz = 99
  while (%dz <= 122) {
    if ($1 == %id) && ($disk($chr(%dz))) return Disk $upper($+(&,$chr(%dz))) Size $chr(149) $hd :/
    inc %id
    inc %dz
  }
}
alias hd {
  if ($disk($chr(%dz)).type == cdrom) { return CD-Rom }
  return $calc(%HDD_total + $bytes($disk($chr(%dz)).size,g))
}

But it return the same size for all the disks, and i can't get it to return if the disk/drive is a CD or a hard drive, someone that can point me in the right direction here?

Last edited by sparta; 06/09/07 10:50 AM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: $submenu [Re: sparta] #185204 06/09/07 01:09 PM
Joined: Dec 2002
Posts: 503
B
Bekar Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
pass %dz to $hd (i.e. $hd(%dz)), and use $1 in the 'alias hd' instead. Just make sure it's not some weird sort of scope issue.

Also, what's this %HDD_total thing?

Re: $submenu [Re: Bekar] #185218 06/09/07 06:45 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 cant get it to work, and the %HDD_total is something i used befor, i trying to change all my alias for something faster.
Code:
alias hd {
  var %x = 99
  while (%x <= 122) {
    if ($disk($chr(%_zd)).type == cdrom) { return CD-Rom }
    return $calc($bytes($disk($chr(%x)).size,g))
    inc %x
  }
}

the code wont loop true all disk's, it send me the size of C no mather what.. smirk


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: $submenu [Re: sparta] #185219 06/09/07 07:32 PM
Joined: Jul 2006
Posts: 107
L
LonDart Offline
Vogon poet
Offline
Vogon poet
L
Joined: Jul 2006
Posts: 107
using echo rather than return, the following worked well in my status window
Code:
alias hd {
  var %dz = 99
  var %dcnt = $disk(0) + %dz
  while ( %dz < %dcnt ) {
    if ($disk($chr(%dz)).type == cdrom) { echo 3 -s Disk $upper($chr(%dz)) - CD-Rom }
    else echo -s Disk $upper($chr(%dz)) - $bytes($disk($chr(%dz)).size,g) GB
    inc %dz
  }
}


When I had %dz <= 122, I got an 'insufficient parameters' error for non-existent drives.
Don't need $calc with $bytes.
It appears size for CDrom drives is always 0.

In your last post you didn't have all your variables changed to %x (typo?)

hth


LonDart
Re: $submenu [Re: LonDart] #185220 06/09/07 07:49 PM
Joined: Jul 2006
Posts: 3,741
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,741
If he used return, it's maybe because he wants return all infos about disks at the same moment :
Code:
alias dinfo return $regsubex($str(t $chr(32),$calc($disk(0))),/t/g,$iif($disk($calc(\n +1)) || $disk($calc(\n +1)).type == cdrom,$disk($calc(\n + 1)).path -> $iif($disk($calc(\n +1)).type == cdrom,Cd-rom,$bytes($disk($calc(\n +1)).size,g).suf) -))


It's much cleaner with a while but I just post this for fun smile

Last edited by Wims; 06/09/07 08:02 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $submenu [Re: LonDart] #185221 06/09/07 07:57 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
No typo, i tested to rewrite it, and i changed the %var since it was a new code.


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: $submenu [Re: Wims] #185222 06/09/07 08:00 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Nope, that code didnt do the trick ether, so dunno why it wont work. crazy


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: $submenu [Re: sparta] #185223 06/09/07 08:02 PM
Joined: Jul 2006
Posts: 3,741
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,741
I make a typo lol. i use "alias $dinfos" instead of "alias dinfos"
I've edited...
If it still doesn't works, can you detail ?

Last edited by Wims; 06/09/07 08:06 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $submenu [Re: Wims] #185225 06/09/07 08:22 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 noticed you named it wrong wink and if i use //echo your code , then it working as it should, but when i try use it in my submenu, then it return nothing to the menu smirk
Code:
alias disks {
  var %id = 1
  var %dz = 99
  while (%dz <= 122) {
    if ($1 == %id) && ($disk($chr(%dz))) return Disk $upper($+(&,$chr(%dz))) Size $chr(149) $hd :/
    inc %id
    inc %dz
  }
}

this is the submenu i try to return the info to..


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: $submenu [Re: sparta] #185230 06/09/07 09:17 PM
Joined: Jul 2006
Posts: 3,741
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,741
Hum, use this :

Code:
alias disks {
  var %a = $disk(0)
  while (%a) {
    if ($1 == %a) { return $left($disk(%a).path,1) : echo -a $iif($disk(%a).type == cdrom,Cd-rom,$bytes($disk(%a).size,g).suf) }
    dec %a
  }
}


I use $left for the path because if not, mirc parse the ":" (of C:\ for exemple) like a command and said : "\ Unknown command"
I've tried a lot of thing to prevent this but without success.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $submenu [Re: Wims] #185231 06/09/07 09:24 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
hmm, tested your code, the result was that it takes around 3 sec to open up popups, so nothing i can use, sorry confused


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: $submenu [Re: sparta] #185232 06/09/07 09:39 PM
Joined: Dec 2002
Posts: 503
B
Bekar Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Ok, lets look at this in a step-by-step process:

$submenu($disks($1)) will call 'disks' with arguments 1, 2, 3, etc..

As you were permenantly setting %id to 1, you'll be looping pointlessly many many times.

If you have any breaks in your drive letter sequence, it won't get the latter drive references.

Now, all that aside, you want something that looks like this:

Code:
alias -l disks {
  if ($1 == begin) {
    var %dz = 99
    while (%dz <= 122) {
      if ($disk($chr(%dz))) {
        %drivelist = $addtok(%drivelist, $chr(%dz), 124)
      }
      inc %dz
    }
  }
  elseif ($1 == end) {
    unset %drivelist
  }
  elseif ($1 isnum && $1 <= $numtok(%drivelist, 124)) {
    return Disk $upper($+(&,$gettok(%drivelist, $1, 124))) Size $chr(149) $hd($gettok(%drivelist, $1, 124)) :/
  }
}
alias -l hd {
  if ($disk($$1).type == cdrom) { return CD-Rom }
  return $calc($bytes($disk($$1).size,g))
}
menu status {
  Disk state:
  .$submenu($disks($1))
}

This is tested. To explain it out a bit..

In the 'begin', we generate a list of drive devices, and then store it in %drivelist.

In the 'end', we clear out the no-longer needed variable.

In the 'isnum' section, we see if our $submenu() call has exceeded the number of tokens in our %drivelist. If not, we return the details for the drive we're up to in our $submenu() automated loop.

Hope this helps

Re: $submenu [Re: sparta] #185234 06/09/07 09:57 PM
Joined: Jul 2006
Posts: 3,741
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,741
Originally Posted By: Sparta
hmm, tested your code, the result was that it takes around 3 sec to open up popups, so nothing i can use, sorry


This is normal, and i can't change this behavior, the while loop will try to return a value for each disk, and especially for A:\.
Look into A:\ take so long time, so the pop up just show after the execution of the while, but you can avoid the problem by not returning something for A:\ :

Code:
alias dinfos1 {
  var %a 1 ,%b = $disk(0)
  while (%a <= %b) {
    if ($1 == 1) return -
    elseif ($1 == %a) { return $left($disk(%a).path,1) : echo -a $iif($disk(%a).type == cdrom,Cd-rom,$bytes($disk(%a).size,g).suf) }
    inc %a
  }
}


on my computer, $disk(1) represent A:\, don't know if it's the case on any computer so maybe you have to change the "1" in this line :
Code:
if ($1 == 1) return -


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $submenu [Re: Wims] #185235 06/09/07 09:59 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
What's the point in looping %a when you can just use $disk($1) ? confused

Re: $submenu [Re: hixxy] #185237 06/09/07 10:06 PM
Joined: Jul 2006
Posts: 3,741
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,741
Yes you're right lol, after some test and some /echo, it seems that $submenu already doing a while itself so the alias can be simplified :

alias dinfos1 {
if ($1 == 1) return -
else { return $left($disk($1).path,1) : echo -a $iif($disk($1).type == cdrom,Cd-rom,$bytes($disk($1).size,g).suf) }
}

Edit : I did not see Bekar's answer

Last edited by Wims; 06/09/07 10:10 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $submenu [Re: Wims] #185238 06/09/07 10:12 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Submenu loops until you don't return a value, and then it will send "end" as $1

If you do this for example:

Code:
alias infinite_loop { return $1: noop }

menu menubar {
  $submenu($infinite_loop($1))
}


You'll see that it adds hundreds of items to the menu.

Re: $submenu [Re: hixxy] #185240 06/09/07 10:27 PM
Joined: Jul 2006
Posts: 3,741
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,741
Ok thx, $submenu isn't something i often use (i'm sure i'm not only wink )


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $submenu [Re: sparta] #185271 07/09/07 12:53 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
I like this one, should be fast enough (tested with some HDDs, USBremovable and 1 optical drive (I have no floppy drive).
Code:
alias -l sub.drives {
  ; cycle drives
  if ($1 == begin) {
    var %asc = 99
    while (%asc <= 122) {
      if ($disk($chr(%asc))) {
        var %d = $upper($chr(%asc))
        ; store sums of fixed/removable drives
        if ($istok(fixed removable,$disk(%d).type,32)) {
          set -u %sub.drive.list $addtok(%sub.drive.list,%d 1 $disk(%d).size $disk(%d).free,124)
          inc -u %sub.drive.total $disk(%d).size
          inc -u %sub.drive.free $disk(%d).free
        }
        ; other drives: store only type
        else { set -u %sub.drive.list $addtok(%sub.drive.list,%d $disk(%d).type 0 0,124) }
      }
      inc %asc
    }
  }
  ; return drive info
  elseif (($1 isnum) && ($gettok(%sub.drive.list,$1,124))) {
    var %d = $gettok($v1,1,32),%ty = $gettok($v1,2,32), %t = $gettok($v1,3,32), %f = $gettok($v1,4,32)
    return Drive %d $chr(149) $iif((%ty != 1),$upper($v1) $qt($disk(%d).label),$qt($disk(%d).label) $chr(149) $&
      $bytes(%t,g) GB $+([,free $bytes(%f,g) GB = $round($calc(%f / %t *100),1),$chr(37),])) : run $disk($1).path
  }
  ; return totals
  elseif ($1 == end) {
    return --TOTAL-- $bytes(%sub.drive.total,g) GB $+([,free $bytes(%sub.drive.free,g) GB = $&
      $round($calc(%sub.drive.free / %sub.drive.total *100),1),$chr(37),]) : noop
  }
}

menu status {
  Drive Info
  .$submenu($sub.drives($1))
}

Atm it's looking up "C:" to "Z:".
To start with "A:", change this line's value to "97":
var %asc = 99

Last edited by Horstl; 07/09/07 01:56 PM.
Page 1 of 2 1 2