|
Joined: Aug 2004
Posts: 7,168
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2004
Posts: 7,168 |
In a menu, I want to have a single item as an option if a specific script is loaded, but if it's not loaded, then I want different items listed. Specifically the items are for /whois & /whowas commands
Pseudo-Code: menu * { if $script(who2.mrc) { whois/whowas who2 $iif($menu == nicklist,$snicks) } else { .whois $iif($menu == nicklist,$iif(!$1,$$?="Nick",$1)) .whowas $$?="Nick" } }
Hopefully that's clear enough for someone to show how I can do it as a proper menu item (since that doesn't work as is)
|
|
|
|
Joined: Oct 2005
Posts: 1,671
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,671 |
I think you are looking for the $iif identifier:
menu * {
$iif($script(who2.mrc),whois/whowas):who2 $iif($menu == $nicklist,$snick)
$iif(!$script(who2.mrc),Who)
.$iif(!$script(who2.mrc),whois):whois $iif($menu == nicklist,$iif(!$1,$$?="Nick",$1))
.$iif(!$script(who2.mrc),whowas):whowas $$?="Nick"
}
Notice the . and : go OUTSIDE the $iif statement. -genius_at_work
|
|
|
|
Joined: Aug 2004
Posts: 7,168
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2004
Posts: 7,168 |
Thanks, I knew about the $iif, but wasn't sure if there was a way to use the if/else format rather than multiple $iif's...guess not.
|
|
|
|
Joined: Jun 2006
Posts: 506
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 506 |
You can use less $iif's menu * {
$iif($script(who2.mrc),whois/whowas):who2 $iif($menu == $nicklist,$snick)
$iif(!$script(who2.mrc),Who)
.$iif($menu == nicklist,whois):whois $$?1="Nick"
.whowas:whowas $$?="Nick"
}
|
|
|
|
Joined: Jun 2006
Posts: 506
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 506 |
menu * {
$iif($script(who2.mrc),whois/whowas):who2 $iif($menu == $nicklist,$snick)
$iif(!$script(who2.mrc),Who)
.$iif($menu == nicklist,whois):whois $$?1="Nick"
.whowas:whowas $$?[color:red]1[/color]="Nick"
} Missed the 1 before
|
|
|
|
Joined: Aug 2004
Posts: 7,168
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2004
Posts: 7,168 |
Why have the 1 in $$?1="Nick"
|
|
|
|
Joined: Jun 2006
Posts: 506
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 506 |
$$?1 means '$1' is used if it is supplied, if there is no '$1' you are prompted for input.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
that is very slick, where is that documented?
|
|
|
|
Joined: Jun 2006
Posts: 506
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 506 |
In /help aliases 
|
|
|
|
Joined: Aug 2004
Posts: 7,168
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2004
Posts: 7,168 |
You can also do $$?1 or $?1 which means try to fill this value with parameter one if it exists. If parameter one doesn't exist, ask for it. In the first case the parameter is necessary for the command to be executed, in the second case it isn't. Don't feel bad that you were un-aware of it, took me 5 minutes to find it after being told where to look. LOL
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
Very nice. I didn't know about that either.
|
|
|
|
|