mIRC Home    About    Download    Register    News    Help

Print Thread
#209195 06/02/09 01:48 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Code:
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.
pouncer #209196 06/02/09 01:58 PM
Joined: Apr 2008
Posts: 43
Z
Ameglian cow
Offline
Ameglian cow
Z
Joined: Apr 2008
Posts: 43
Code:
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

pouncer #209197 06/02/09 01:58 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
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

Code:
alias popupmenu {
  if ($1 isnum) {
    var %rooms = #IRC-SHACK,#TEST,#MIRC
    if ($gettok(%rooms,$1,44)) { return $v1 : join $v1 }
  }
}


pouncer #209203 06/02/09 04:32 PM
Joined: Jun 2003
Posts: 994
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Jun 2003
Posts: 994
Quote:
menu status {
.rooms
..$submenu($popupmenu($1))
}

how come the menu is disabled?


try this:
Code:
menu status {
  rooms
  .$submenu($popupmenu($1))
} 


I refuse to engage in a battle of wits with an unarmed person. wink
CtrlAltDel #209204 06/02/09 04:54 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
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.

Horstl #209207 06/02/09 05:32 PM
Joined: Jun 2003
Posts: 994
C
Hoopy frood
Offline
Hoopy frood
C
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. wink
CtrlAltDel #209209 06/02/09 05:53 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Code:
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 wink

Horstl #209210 06/02/09 06:09 PM
Joined: Jun 2003
Posts: 994
C
Hoopy frood
Offline
Hoopy frood
C
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. wink
CtrlAltDel #209218 06/02/09 08:54 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
This works fine..

Code:
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?

pouncer #209228 07/02/09 03:26 AM
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
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.


pouncer #209231 07/02/09 04:41 AM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
/help $submenu ->
Originally Posted By: mirc.hlp

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"
DJ_Sol #209232 07/02/09 05:02 AM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
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:
Code:
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):
Code:
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 }
  }
}



Horstl #209246 07/02/09 09:03 PM
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
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. smile

This is the way I do it.

Code:
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) }
}

DJ_Sol #209516 16/02/09 07:57 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Code:
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

pouncer #209526 16/02/09 09:05 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
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?

Horstl #209527 16/02/09 09:14 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Code:
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

pouncer #209529 16/02/09 09:35 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
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:
Code:
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:
Code:
    elseif ($2 == deleteroom) { return $safe($replace(%room,&,&&)) : set $safe(% $+ rooms $remtok(%rooms,%room,0,32)) }
smile

Last edited by Horstl; 16/02/09 10:27 PM.

Link Copied to Clipboard