mIRC ScriptBox
Intro To Dynamic Popups

Written by pai

Table of Content

  1. Introduction
  2. Show And Hide Popups
  3. Changing Popups
  4. Conclusion


1. Introduction

Dynamic popups are, in a nutshell, popups that change. Dynamic popups generally fall into two categories:

  1. Popups that appear or hide depending on status (opped or not connected, etc.)
  2. Popups that change depending on settings or other states

Dynamic popups are possible because you can insert %variables, $identifiers, and other such items into popup titles.

Prerequisites: This article assumes you know how to create basic popups and use /if already.


2. Show And Hide Popups  Back to Top

To make a popup show or hide, usually $iif() is used. ($iif() is an inline /if statement.) For example, popups that would show only if you are connected, (and therefore $server is not $null)

  $iif($server != $null,Quit): { quit Bye! }
  $iif($server != $null,Join): { join $$?="channel to join?" }
These popups work by comparing $server to $null. If it isn't $null, the text is shown. If it is, nothing is shown, therefore hiding the popup.

Note that this could be changed to $iif($server,Quit) as $iif (like /if) evaluates a non-null string as true.

A similar thing can be done for being opped in channels-

  $iif($me isop $chan,Op commands) 
  .Op:{ do stuff } 
  .Deop:{ do stuff } 

This whole submenu will only be shown if you are opped on the current channel. It should work in any channel or nicklist popup menu.


3. Changing Popups  Back to Top

To make a popup change based on state, $iif() again is often used, but a second option is given to show:

$iif($away == $true,Set Back,Set Away):{ awayroutine }

In this case, if the user is away, $away will be $true. In this case, the first option, Set back, is shown. Otherwise, Set away is shown. (awayroutine is just a dummy routine that would be replaced by real scripting for a real script.)

You can also use this to show the state of a routine:

Protection $iif(%protect == 1,[On],[Off]):{ do stuff } 

If %protect is 1, then [On] is shown. If %protect is anything else, [Off] is shown.

If you use #groups for your routines, you can easily show their status like so:

Protection - $group(#protect):{ do stuff } 

Since $group() already returns on and off, you don't have to even use an $iif() if you don't want to. (if you do use an $iif, remember to compare it to on and off)


4. Conclusion  Back to Top

These demonstrate some basic examples of dynamic popups. You can use any identifier or variable in a popup- we mostly used $iif here because it tends to work best for dynamic popups.

One tip to remember is that if a popup's text evaluates to nothing ($null) the popup won't show; otherwise, it will.

You can look up /if and $iif in the mIRC help file for more info on conditions that can be used. Don't be afraid to experiment :)