From WikiChip
Difference between revisions of "mirc/commands/var"
< mirc‎ | commands

m (PatrolBot moved page /var command - mIRC to mirc/commands/var: per new naming convention)
Line 10: Line 10:
 
Internally, the var command simply breaks down the line (by commas) and passes the arguments to /set. The set command has its own evaluation routine which lets you dynamically concatenate additional values onto the variable name before the assignment takes place.
 
Internally, the var command simply breaks down the line (by commas) and passes the arguments to /set. The set command has its own evaluation routine which lets you dynamically concatenate additional values onto the variable name before the assignment takes place.
  
<syntaxhighlight lang="mIRC">//var -ls % $+ $ctime ABC</syntaxhighlight>
+
<syntaxhighlight lang="mIRC">//var -s % $+ $ctime ABC</syntaxhighlight>
  
 
Will create a variable like %1209425041 with the value of 'ABC'; Similarly this can be used with $nick and $chan in on events.
 
Will create a variable like %1209425041 with the value of 'ABC'; Similarly this can be used with $nick and $chan in on events.

Revision as of 21:32, 26 October 2014

Template:mIRC menu The /var command can be used to replace the value of existing variables or create a new variables and assign them values. By default /var creates local variable, this can be changed via the -g switch (/set command can be used to set global variables by default).

The var command can perform one math operation via one of the arithmetic operators: addition (+), subtraction (-), multiplication (*), division (/), and modulo (%). They must be space delimited with both operands being a number. If any of the operands are not a number or if a space is missing, it will be treated as plain text.


Note: Unlike the /set command, var can assign a value to multiple variables at once.

Set Evaluation Routine: Internally, the var command simply breaks down the line (by commas) and passes the arguments to /set. The set command has its own evaluation routine which lets you dynamically concatenate additional values onto the variable name before the assignment takes place.

//var -s % $+ $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.

Synopsis

/var [-sg] <%var> [[= ]value]
/var [-sg] <%var> <number> <+ | - | * | / | %> <number>
/var [-sg] <%var> [= ]<number> <+ | - | * | / | %> <number>
/var [-sg] <%var> [[= ]value][, <%var> [[= ]value]][, ...]
/var [-sg] <%var> [= ]<number> <+ | - | * | / | %> <number>[, ...]

Switches

  • -s - Display variable assignment value
  • -g - Creates a global variable instead
  • -n - Treats value as plain text

Parameters

  • <%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 five possible arithmetic operations
  • <number> - Any arbitrary numerical value, can be a floating point number

Example

; Factorial
; 10! = $factorial(10) = 3628800
alias factorial {
  var %result = 1, %x = $1
  while (%x) {
    var %result = %result * $v1
    dec %x
  }
  return %result
}

Compatibility

Added: mIRC v5.6
Added on: 03 Jun 1999
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See also

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