|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
I using this 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? 
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Feb 2006
Posts: 546
Fjord artisan
|
Fjord artisan
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
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
Ty, that solved the problem  a new problem tho  Now my code looks like:
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,.) }
|
|
|
|
Joined: Dec 2002
Posts: 503
Fjord artisan
|
Fjord artisan
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?
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
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.
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.. 
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Jul 2006
Posts: 107
Vogon poet
|
Vogon poet
Joined: Jul 2006
Posts: 107 |
using echo rather than return, the following worked well in my status window 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
|
|
|
|
Joined: Jul 2006
Posts: 4,212
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,212 |
If he used return, it's maybe because he wants return all infos about disks at the same moment :
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 
Last edited by Wims; 06/09/07 08:02 PM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
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,.) }
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
Nope, that code didnt do the trick ether, so dunno why it wont work.
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Jul 2006
Posts: 4,212
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,212 |
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.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
I noticed you named it wrong  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 
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,.) }
|
|
|
|
Joined: Jul 2006
Posts: 4,212
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,212 |
Hum, use this : 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.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
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
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Dec 2002
Posts: 503
Fjord artisan
|
Fjord artisan
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:
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
|
|
|
|
Joined: Jul 2006
Posts: 4,212
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,212 |
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:\ : 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 :
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
What's the point in looping %a when you can just use $disk($1) ?
|
|
|
|
Joined: Jul 2006
Posts: 4,212
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,212 |
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.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
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: alias infinite_loop { return $1: noop }
menu menubar {
$submenu($infinite_loop($1))
} You'll see that it adds hundreds of items to the menu.
|
|
|
|
Joined: Jul 2006
Posts: 4,212
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,212 |
Ok thx, $submenu isn't something i often use (i'm sure i'm not only  )
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
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). 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.
|
|
|
|
|