From WikiChip
/set Command - mIRC
< mirc‎ | commands(Redirected from /set command - mIRC)

The /set command can be used to replace the value of an existing variable or create a new variable and assign it the given value. By default /set creates global variable, this can be changed via the -l switch. Unlike the /var command, set cannot assign a value to multiple variables at once. It support one math operation.

Set evaluation routine[edit]

The set command has its own evaluation routine which lets you dynamically concatenate additional values onto the variable name before the assignment takes place.

//set -ls % $+ $ctime ABC

Will create a variable like %1209425041 with the value of 'ABC'; Similarly this can be used with $nick and $chan in on events.

Note: /set will fail to evaluate your variable if you have dynamic parameters before the name, read more here

Synopsis[edit]

/set [-gisuNzneplk] <%var> [value]
/set [-gisuNznelk] <%var> <number> <+ | - | * | / | % | ^ | &> <number>

Switches[edit]

  • -s - Display variable assignment value
  • -uN - Unsets the variable after N amount of seconds. A special case has been made for -u0 which will make the variable unset at the end of script processing, the same way binary variables do.
  • -z - Decreases the value of the variable by 1/second until zero is reached. At zero the variable will be unset.
  • -n - Treat the value as plain text, even if arithmetic operators are used.
  • -e - Unsets the variable when mIRC exits
  • -l - Creates a local variable instead
  • -k - Keeps the unset time (-u) from a previous command
  • -i - Only set the value to the variable if the variable does not already have a value, good for initialization
  • -g - Since you can have a global variable and a local variable of the same name, this makes sure the global variable is set
  • -p - Permits value to be 2 literal doublequotes and permits value to end with a single $chr(32) space. Also performs -n switch behavior

Parameters[edit]

  • <%var> - The name of the variable
  • [value] - The value to assign to the variable
  • <number> - Any arbitrary numerical value, can be a floating point number
  • <+ | - | * | / | % | ^> - One of the six possible arithmetic operations
  • <number> - Any arbitrary numerical value, can be a floating point number

Example[edit]

; /countDown 
Alias countDown {
  ; set some value
  set %var Countdown:
  ; print the value
  echo -a %var
  ; set the value to 3, decrease once per second
  set -zs %var 3
}

Will output:

Countdown:
-
* Set %var to 3
-
* Set %var to 2
-
* Set %var to 1
-
* Unset %var
-

The -u0 switch can be used to create a variable with global scope that will get unset at the end of the script processing. This can be very helpful at times.

Alias example {
  set -u0 %x A
  bb
  ; will print 'B'
  echo -a %x
}
alias bb {
  ; replace the value of %x with B, keep the unset setting
  set -k %x B
}

A simple !seen script that uses /set special evaluation routine to create dynamic variables:

on *:text:!seen &:#mIRC:{
  ; check if the variable is set
  if ($var(seen. $+ $2)) {
    ; notice the user the value of '%seen.<nick>'
    notice $nick I have seen $2 $var(seen. $+ $2, 1).value
  }
  else notice $nick I have not seen $2 anywhere.
}
on *:text:*:#:{
  ; set the value to '%seen.<nick>'
  set %seen. $+ $nick Talking in $chan < $+ $nick $+ > $1-
}

Compatibility[edit]

Added: mIRC v4.0
Added on: 20 Mar 1996
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See also[edit]

v · d · e mIRC commands list

A /abook, /action, /add, /ajinvite, /alias, /aline, /ame, /amsg, /anick, /aop, /auser, /auto, /autojoin, /avoice, /away

B /background, /ban, /bcopy, /beep, /bindip, /bread, /break, /breplace, /bset, /btrunc, /bunset, /bwrite

C /channel, /clear, /clearall, /clearial, /cline, /clipboard, /close, /closechats, /closedccs, /closefserves, /closemsg, /cnick, /color, /colour, /comclose, /comlist, /commands, /comopen, /comreg, /continue, /copy, /creq, /ctcp, /ctcpreply, /ctcps

D /dcc, /dccserver, /dde, /ddeserver, /debug, /dec, /describe, /dialog, /did, /didtok, /disable, /disconnect, /dlevel, /dline, /dll, Template:mIRC/donotdisturb, /dns, /dqwindow, /drawcopy, /drawdot, /drawfill, /drawline, /drawpic, /drawrect, /drawreplace, /drawrot, /drawsave, /drawscroll, /drawsize /drawtext

E /ebeeps, /echo, /editbox, /else, /elseif, /emailaddr, /enable, /events, /exit

F /fclose, /filter, /findtext, /finger, /firewall, /flash, /flist, /flood, /flush, /flushini, /fnord, /font, /fopen, /fseek, /fsend, /fserve, /fullname, /fupdate, /fwrite

G /ghide, /gload, /gmove, /gopts, /goto, /gplay, /gpoint, /gqreq, /groups, /gshow, /gsize, /gstop, /gtalk, /gunload, /guser

H /hadd, /halt, /haltdef, /hdec, /hdel, /help, /hfree, /hinc, /hload, /hmake, /hotlink, /hop, /hsave

I /ial, /ialclear, /ialmark, /identd, /if, /ignore, /iline, /inc, /iuser

J /join

L /leave, /linesep, /links, /list, /load, /loadbuf, /localinfo, /log, /logview

M /maxdepth, /mdi, /me, /menubar, /mkdir, /mnick, /mode, /msg

N /noop, /notice, /notify

O /onotice, /omsg

P /pareline, /part, /partall, /pdcc, /perform, /play, /playctrl, /pop, /protect, /proxy, /pvoice

Q /qme, /qmsg, /query, /queryrn, /quit, /quote

R /raw, /registration, /reload, /remini, /remote, /remove, /rename, /renwin, /reseterror, /resetidle, /return, /returnex, /rlevel, /rline, /rmdir, /run, /ruser

S /save, /savebuf, /saveini, /say, /scid, /scon, /server, /set, /setlayer, /showmirc, /signal, /sline, /sockaccept, /sockclose, /socklist, /socklisten, /sockmark, /sockopen, /sockpause, /sockread, /sockrename, /sockudp, /sockwrite, /sound, /speak, /splay, /sreq, /strip, /switchbar

T /timer, /timestamp, /tip, /tips, /titlebar, /tnick, /tokenize, /toolbar, /topic /tray, /treebar

U /ulist, /unload, /unset, /unsetall, /updatenl, /url, /username, /uwho

V /var, /vcadd, /vcmd, /vcrem, /vol

W

X /xyzzy