mIRC Home    About    Download    Register    News    Help

Print Thread
#216015 21/10/09 12:47 AM
Joined: Oct 2009
Posts: 12
C
Corey_ Offline OP
Pikka bird
OP Offline
Pikka bird
C
Joined: Oct 2009
Posts: 12
Hi

I'm trying to find a more efficient way to build this menu.

Code:
menu channel {
  .Title
  ..%m1_name:{ pop %m1_name %m1_size }
  ..%m2_name:{ pop %m2_name %m2_size }
  ..%m3_name:{ pop %m3_name %m3_size }
  ..%m4_name:{ pop %m4_name %m4_size }
  ..%m5_name:{ pop %m5_name %m5_size }
}


I would like to extend the menu out to the range of 100+ entries, but don't wish to fill my script with line after line of nearly-identical code. Does mIRC have a way to do this?

Thanks for reading!

Corey_ #216016 21/10/09 12:49 AM
Joined: Jul 2006
Posts: 3,944
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,944
Look at /help $submenu smile


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Corey_ #216017 21/10/09 01:01 AM
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Submenu help section can be a little cryptic so I will try to help you a little here.

It acts like a while loop, where $1 starts at 1 and keeps going until it is null.


This is just a general example.
Code:
%var = data1,data2,data3

menu channel {
Test
.$submenu($test($1))
}

alias test {
if ($gettok(%var,$1,44)) return $ifmatch :msg # $ifmatch
}

Corey_ #216018 21/10/09 01:29 AM
Joined: Oct 2009
Posts: 12
C
Corey_ Offline OP
Pikka bird
OP Offline
Pikka bird
C
Joined: Oct 2009
Posts: 12
Alright, that was pretty cool.

Just in case anybody (for some strange reason) has the same question in the future:
Code:
menu channel {
  .Title
  ..$submenu($titlealias($1))
}

alias titlealias { 
  if (% [ $+ m $+ [ $1 ] $+ _release ]) return $ifmatch : pop % [ $+ m $+ [ $1 ] $+ _name ] % [ $+ m $+ [ $1 ] $+ _size ]
}


Wims, DJ_Sol: Thank you both for the help!

Corey_ #216019 21/10/09 01:54 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Here's a little re-write of your alias
Code:
alias titlealias { 
  if $($+(%,m,$1,_release),2) return $ifmatch : pop $($+(%,m,$1,_name),2) $($+(%,m,$1,_size),2)
}


Joined: Oct 2009
Posts: 12
C
Corey_ Offline OP
Pikka bird
OP Offline
Pikka bird
C
Joined: Oct 2009
Posts: 12
I'm a little embarrassed about how much better that looks. Thanks!

Corey_ #216021 21/10/09 02:39 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Don't be. The help file doesn't show this method of evaluating a variable, or at least, not that I've been able to find.

The method you used, however, is shown in the help file.


Link Copied to Clipboard