mIRC Home    About    Download    Register    News    Help

Topic Options
#162049 - 14/10/06 07:26 PM Better script based popup menu support
NaquadaServ Offline
Fjord artisan

Registered: 12/12/02
Posts: 580
First off, I love this suggestion. I have a few more ideas regarding menus...

First, a new identifer $menuselect. It would return the text of the menu item selected. Here is an example of why... My connect event changes a list, I call "recent servers". If a popup menu is created before changing this list, yet my selection occurs after changing this, the menu selection will most likely be invalid. Parsing a $menutext identifer would fix this problem.
Code:
; For the sake of example here, $menuselect equals "irc.irc.net 6667".
; since $svrname and $svrport could change between popup creation,
; and selection of menu item, use $menuselect instead
menu RecentServers {
  $iif($isrecent(1), $svrname(1) $svrport(1)):{ server $menuselect }
}


Second and best shown with code...
Code:
; Get rid of
menu status {
  Animal
  .$submenu($animal($1))
}
alias animal {
  if ($1 == begin) return -
  if ($1 == 1) return Cow:echo Cow
  if ($1 == 2) return Llama:echo Llama
  if ($1 == end) return -
}


Code:
; In favor of
menu status {
  Animal
  .$submenu(animal)
}
menu animal {
  Cow:echo Cow
  Llama:echo Llama
}

Top
#162050 - 14/10/06 07:35 PM Re: Better script based popup menu support
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
Regarding the second suggestion... huh? The whole purpose of $submenu() is dynamic menus (menus with a dynamic number of items), how would your suggestion accomplish that?
_________________________
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Top
#162051 - 14/10/06 08:21 PM Re: Better script based popup menu support
NaquadaServ Offline
Fjord artisan

Registered: 12/12/02
Posts: 580
I see your reasoning, although such abilities already exists using $iif

This example menu item is only added to the menu if connected ($connected just checks $status for a status of connected and returns $true or $false)
Code:
menu test {
$iif($connected == $true, Disconnect):disconnect
}
_________________________
NaquadaBomb
www.mirc-dll.com

Top
#162052 - 14/10/06 09:21 PM Re: Better script based popup menu support
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
$iif() (or any other method) won't help with cases where the total number of menu items is not known. A popular example is this: create a (sub)menu with all log files currently in $logdir, so that the user can click on an item and view the file in an editor:
Code:
menu status {
  Logs
  .$submenu($logsmenu($1))
}
alias logsmenu {
  if $1 == begin {
    close -@ @@ | window -hsl @@
    halt $findfile($logdir,*,0,1,@@)
  }
  if $line(@@,$1) { return $nopath($v1) : run notepad $+(",$v1,") }
  window -c @@
}

There is simply no way of doing this with $iif().
_________________________
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Top
#162053 - 14/10/06 11:48 PM Re: Better script based popup menu support
NaquadaServ Offline
Fjord artisan

Registered: 12/12/02
Posts: 580
I'll conceed keeping existing support... Although, both methods could be supported. If $1 is not an identifer then it's a menu. smile
_________________________
NaquadaBomb
www.mirc-dll.com

Top