|
Joined: Oct 2005
Posts: 827
Hoopy frood
|
OP
Hoopy frood
Joined: Oct 2005
Posts: 827 |
menu status {
.rooms
..$submenu($popupmenu($1))
}
alias popupmenu {
var %rooms = #IRC-SHACK,#TEST,#MIRC
var %x = 1
while (%x <= $numtok(%rooms, 44)) {
var %r = $gettok(%rooms, %x, 44)
if ($1 == %x) %r : join %r
inc %x
}
}
how come the menu is disabled?
Last edited by pouncer; 06/02/09 01:49 PM.
|
|
|
|
Joined: Apr 2008
Posts: 43
Ameglian cow
|
Ameglian cow
Joined: Apr 2008
Posts: 43 |
menu status {
.rooms
..$submenu($popupmenu($1))
}
alias popupmenu {
var %rooms = #IRC-SHACK,#TEST,#MIRC
var %x = 1
while (%x <= $numtok(%rooms, 44)) {
var %r = $gettok(%rooms, %x, 44)
if ($1 == %x) return %r : join %r
inc %x
}
} needed a return on this line ; if ($1 == %x) return %r : join %r
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
Your alias popupmenu has to be a custom identifier that returns something. In addition, you don't need to loop for the Nth token using %x - as you already have a N: $N alias popupmenu {
if ($1 isnum) {
var %rooms = #IRC-SHACK,#TEST,#MIRC
if ($gettok(%rooms,$1,44)) { return $v1 : join $v1 }
}
}
|
|
|
|
Joined: Jun 2003
Posts: 994
Hoopy frood
|
Hoopy frood
Joined: Jun 2003
Posts: 994 |
menu status { .rooms ..$submenu($popupmenu($1)) }
how come the menu is disabled?
try this: menu status {
rooms
.$submenu($popupmenu($1))
}
I refuse to engage in a battle of wits with an unarmed person.
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
You're right about the incorrect depth definition - however mIRC does compensate it. The reason for the "disabled" menu item still is/was the called submenu alias.
|
|
|
|
Joined: Jun 2003
Posts: 994
Hoopy frood
|
Hoopy frood
Joined: Jun 2003
Posts: 994 |
I must disagree with you .. the reason the menu itself was disabled was the depth. Add it to your remotes and see for yourself.
I have no doubt that the alias itself was incorrect (though I didn't try it), but the alias working has nothing to do with the menu
I refuse to engage in a battle of wits with an unarmed person.
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
menu * {
..works
....as long as there's a relative...
.....depth. : noop
.and this is still nested,
..because "works" is processed like a zero depth item : noop
} I won't call it proper code, your spot/remark was correct. Yet it is working 
|
|
|
|
Joined: Jun 2003
Posts: 994
Hoopy frood
|
Hoopy frood
Joined: Jun 2003
Posts: 994 |
Then pray tell why is it disabled on this screenshot? [edit] Actually, yours DOES work, but his does not. Go Figure!
Last edited by CtrlAltDel; 06/02/09 06:17 PM.
I refuse to engage in a battle of wits with an unarmed person.
|
|
|
|
Joined: Oct 2005
Posts: 827
Hoopy frood
|
OP
Hoopy frood
Joined: Oct 2005
Posts: 827 |
This works fine..
menu status {
.rooms
..$submenu($popupmenu($1))
}
alias popupmenu {
if ($1 isnum) {
if ($gettok(%rooms,$1,44)) { return $v1 : join $v1 }
}
}
%rooms is a global variable now. i want to extend this further.. how can i make extra menu popups appear for each channel name: .join - will join the room .delete - will remove the room from the %rooms variable any ideas?
|
|
|
|
Joined: Jan 2007
Posts: 1,156
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
I had to write two different submenus. One to join, one to delete.
I have never tried nesting submenu's.
|
|
|
|
Joined: Oct 2003
Posts: 3,918
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,918 |
/help $submenu -> Note: You can't use this to create nested submenus, it will only build one single submenu.
- argv[0] on EFnet #mIRC - "Life is a pointer to an integer without a cast"
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
You may not nest subemenus, but you could use the same submenu definition for different tasks - in this example, the command is passed to the alias as 2nd parameter: menu status {
Favorite rooms $+([,$numtok(%rooms,44),])
.$iif(($status == connected),join)
..$submenu($popupmenu($1,join))
.$iif(($status == connected),part)
..$submenu($popupmenu($1,part))
.-
.delete
..$submenu($popupmenu($1,deleteroom))
}
alias -l popupmenu {
if (($1 isnum) && ($gettok(%rooms,$1,44))) { return $v1 : $2 $v1 }
}
alias -l deleteroom { set %rooms $remtok(%rooms,$1,0,44) } That's handy with simple commands. If you just want to use e.g. different $styles, little to no advantage over separate submenu definitions remains (length of code etc): alias -l popupmenu {
if (($1 isnum) && ($gettok(%rooms,$1,44))) {
var %room = $v1
if ($2 == join) { return $iif(($me ison %room),$style(3)) %room : $2 %room }
elseif ($2 == part) { return $iif(($me !ison %room),$style(2)) %room : $2 %room }
else { return %room : $2 %room }
}
}
|
|
|
|
Joined: Jan 2007
Posts: 1,156
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
That's a cool way of doing it Horstl, thanks. I always had trouble with a second parameter. Guess I was just doing something wrong.  This is the way I do it. menu * {
Add:$submenu($addpp($1))
Fave:$submenu($fpp($1))
}
alias addpp { return $pp_($1,a) }
alias fpp { return $pp_($1,f) }
alias pp_ {
if ($1 isin begin.end) { return }
elseif ($2 == a) && (%addr. [ $+ [ $1 ] ]) { return $iif($ifmatch == %lastadd,$style(1)) $chr(160) $readini(soulfly.ini,accts,$ifmatch) $+ :sf_re $ifmatch }
elseif ($2 == f) && ($gettok(%fav,$1,44)) { return $+($iif($gettok(%fav,$1,44) !isnum,$hcd($ifmatch)),:join) $gettok(%fav,$1,44) }
}
|
|
|
|
Joined: Oct 2005
Posts: 827
Hoopy frood
|
OP
Hoopy frood
Joined: Oct 2005
Posts: 827 |
menu status {
Favorite rooms $+([,$numtok(%rooms,32),])
.join
..$submenu($popupmenu($1,join))
.-
.delete
..$submenu($popupmenu($1,deleteroom))
}
alias -l popupmenu {
if (($1 isnum) && ($gettok(%rooms,$1,32))) {
var %room = $v1
if ($2 == join) { return $iif(($me ison %room),$style(3)) %room : $2 %room }
elseif ($2 == part) { return $iif(($me !ison %room),$style(2)) %room : $2 %room }
else { return %room : $2 %room }
}
}
alias -l deleteroom { set %rooms $remtok(%rooms,$1,0,32) }
im using that as you put and when i try to delete a room nothing seems to happen. any ideas? in my variables i have this: %rooms #mIRC #xyz #chan #USA
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
You don't need the elseif line as you removed the "part" part in the menu definition - but that's not the problem. I tried your current code, and it does what it's supposed to do: set the %rooms variable without the the room picked for deletion (remtok).
Maybe - you have a duplicate menu definition? - you have a duplicate "deleterooms" alias in the same scriptfile?
|
|
|
|
Joined: Oct 2005
Posts: 827
Hoopy frood
|
OP
Hoopy frood
Joined: Oct 2005
Posts: 827 |
menu status {
Favorite rooms $+([,$numtok(%rooms,32),])
.join
..$submenu($popupmenu($1,join))
.-
.delete
..$submenu($popupmenu($1,deleteroom))
}
alias -l popupmenu {
if (($1 isnum) && ($gettok(%rooms,$1,32))) {
var %room = $v1
if ($2 == join) { return %room : $2 %room }
elseif ($2 == deleteroom) return %room : set %rooms $remtok(%rooms,%room,0,32)
}
}
now its giving me * /set: invalid parameters
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
In this case, %room is evaluated two times: in the return command, and in the set command itself that was returned. This would work: elseif ($2 == deleteroom) { return %room : set $eval(% $+ rooms,0) $remtok(%rooms,%room,0,32) } Also note that the actual channel names will be evaluated as well. That's no problem as long as you know which room names you put and they aren't like # $somechan You may use an alias (like in the previous code) to bypass the evaluation thingie in the command part at least. Edit: If you want to play really safe about all evaluations, use the safe alias and: elseif ($2 == deleteroom) { return $safe($replace(%room,&,&&)) : set $safe(% $+ rooms $remtok(%rooms,%room,0,32)) } 
Last edited by Horstl; 16/02/09 10:27 PM.
|
|
|
|
|