Popups
Popups are the menu's in your script. Right click
pulldown menu's, and menu's accessible from the
menubar. You create a popup in much the same format as an alias, with a few
additional 'tweaks' to make a
popup look like you want. The basic look of a popup is like this:
Title/menu option: { commands to run }
Popups1
In this example, the title/menu is 'Connect
til nettverk', and rather than triggering a
program/command to
run, it is branching to so-called sub-menu's, and usually, popups will have
sub-menu's, to create a more
logical and easy-to-use interface to the user. To create the menu above (which
is located in the status
window);
menu status {
Connect til
nettverk
.Undernet
..server 1: {
.server someserver.org }
..server 2: {
server someserver2.org }
.DALnet
..server 1: {
.server yet.another.server.org }
etc
}
As you see, you create the branching by adding one dot
' . ' to each sub-level you want to create, otherwise
the way you add the commands to be run is exactly the same as for aliases. To
create the divider (line), for
instance between 'Andre' and 'Om IRC nett', you add a hyphen ' - ' to the menu
level...that is, on the
'upmost (root)' level of the popups, you do like this;
Choice #1: { some
commands }
-
Choice #2: { More commands }
If you want to create the divider as above, it's like
this;
menu
status {
Connect
til nettverk
. (
.... )
.Andre
.. (
... )
.-
.Om IRC
nett: { command to run }
}
Brackets :
Pay attention that when you 'open' a menu (start a
menu section of a script) (or a command) with a {
bracket, that you also close it, using a } bracket. If you don't, you will get
all messed up popups, like..
Popups2
so, if you see alot of garble in your popups when you
test your new, to-be-world-famous script, then you
should most likely scan your popups for a } that isn't there..;).
Using identifiers and variables within
your popups:
You can also use identifiers and
variables inside the popups, to make them easier to use or provide
information about what will happen when you activate the menu, such as
Disconnect from $server: {
.set %lastserv $server
.set %lastport $port
.quit Leaving
}
-
Connect to
last - %lastserv: { .server %lastserv %lastport }
In which case the servername would show
up in the popup, so if you were connected to
dallas.tx.us.undernet.org, the menu would show:
Disconnect from Kuwait.ArabChat.Org
and the Connect to last, would likewise
show the same. The 'connect to last' menu option is rather useless
though, as this is what happens if you press the 'connect' button, but...;)
Dynamic Popups:
A final note (for now) on popups; making dynamic
popups enables the end-user to only see features that is
relevant for the use he will put them to, and hide irrelevant features. Dynamic
popups are GOOD. :)
Ok, so what do I mean exactly? Well, something like
this:
Popups3
Popups 4
On the first picture, I'm the lucky operator of a
channel, and has access to a few commands that are usable
only if you are a channel op (invite, set ban). On the second picture, I have
been deop'ed, and the popup
access to the menu's that require op have been removed, to avoid problems, and
provide a cleaner look to
the popups.
More specifically, you create dynamic popups by using
identifiers/creating conditionals that will be either on
or off, $true or $false etc etc. This adds the 'show/hide' feature of popups,
and may simplify the everyday
use of the script you're making :). An easy way to do the above popups would be
like;
.......
$iif($me isop
#,Opkontroller)
.Inviter til $chan{
invite $$?="Who should we invite to $chan $+ ?" $chan }
.Sett ban { ...... }
.Sett ban alle kan {
..... }
Send til $chan
......
The above popup definition is using the identifier $iif
which will return one out of two things, depending on
the expression you make. In this case, the $iif
checks to see if you're an op on the current channel, in which
case it returns 'Opkontroller'.
The submenu's belonging to 'Opkontroller'
will then be enabled. If you're not
an op, it returns nothing (which is also a state), and hides the submenu's from
the user. You can use most
(all?) of the evaluators available in regular if comparisions, which enable you
to do constructions such as
$iif($me isop # &&
$1 !isop #,Kick): {
.kick $chan $1 kickmsg }
Which would result in a popup that will
ONLY show if you are an op in a channel, AND (because of the
&&) the
selected nickname in that channel is not another op :) (by using the
! prefix to the condition
expression).