How to dynamically set variable names in mIRC script

mIRCWikipedia: mIRC is an Internet Relay Chat (IRC) client for Microsoft Windows, created in 1995 and developed by Khaled Mardam-Bey. Although it is a fully functional chat utility, its integrated scripting language... does not have arrays. The nearest and best alternative to arrays in mIRC, is dynamicly named variables. For example, %var1, %var2, %var3, %var4 etc.

To set a dynamically named variable, you simply join two variables together, using square brackets, as follows:

  1. set %var [ $+ [ %i ] ] MY VALUE

This code shows you how to emulate an array, using this method:

  1. set %i 1
  2.  
  3. while (%1 <= 10) {
  4. set %var [ $+ [ %i ] ] %stuff_variable
  5. }

 

One comment

  1. Boris Johnson

    Square brackets are redundant there. Use “set %var $+ %i”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>