Project

General

Profile

Actions

Variables

/var

Added in 1.8.8

/var [-gnspB] <%var> [[= ]value]

Sets the value of local variable %var to the specified value.

Syntax can be either var %var = value or var %var value.

Multiple variables can be set in one line using comma as separator, var %var1 = value, %var2 = value2.

See also /set, /unset, /inc, /dec, $var.

Switches

Switch Description
-s Display variable assignment value.
-g Creates a global variable instead.
-n Treat the value as plain text, even if arithmetic operators are used.
-i Initializes a variable only if it does not already exist as a local or global variable.
-p Permits value to be 2 literal double quotes and permits value to end with a single $chr(32) space. Also enables -n switch behavior.
-B Performs a $calcint calculation instead of regular $calc when arithmetic operators are used. (AdiIRC only)

Parameters

Parameter Description
<%var> The variable to set.
[ [= ]value ] Value to set the variable to. (can be a single arithmetic expression)

Example

alias factorial {
  var %result = 1, %x = $1
  while (%x) {
    var %result = %result * $v1
    dec %x
  }
  return %result
}

;Returns 3628800
//echo -ag $factorial(10)

/vars

Added in 1.9.0

/vars

Shows a list of all global variables and their values.

/set

Added in 1.8.8

/set [-eklnsuNzgpB] <%var> [value]

Sets the value of %var to the specified value.

See also /var, /unset, /inc, /vars, /dec, $var, Edit Variables.

Switches

Switch Description
-e Unset the variable when AdiIRC exits.
-k Keeps the unset time (-u) from a previous command.
-l Creates a local variable instead of global.
-n Treat the value as plain text, even if arithmetic operators are used.
-s Display variable assignment value.
-uN Unsets the variable after N amount of seconds, if N = 0 unset the variable after the script is finished.
-z Decreases the value of the variable by 1/ever second until zero is reached. At zero the variable will be unset.
-i Initializes a variable only if it does not already exist as a local or global variable.
-g Sets a global variable even if a local variable exists.
-p Permits value to be 2 literal double quotes and permits value to end with a single $chr(32) space. Also enables -n switch behavior.
-B Performs a $calcint calculation instead of regular $calc when arithmetic operators are used. (AdiIRC only)

Parameters

Parameter Description
<%var> The variable to set.
[value] Value to set the variable to. (can be a single arithmetic expression)

Example

alias example {
  ; Create a variable and set a value.
  /set %var Countdown:

  ; Print the value
  /echo -a %var

  ; Set the value to 3, decrease once per second
  /set -zs %var 3
}

/unset

Added in 1.9.0

/unset [-slg] <%var> [%var..]

Unset local or global variables, local variables take precedence over a global variable with the same name.

Wildcards is allowed.

See also /var, /set, /inc, /dec, /vars, $var, Edit Variables.

Switches

Switch Description
-s Prints unset information.
-l Unset local variable(s).
-g Unset global variable(s).

Parameters

Parameter Description
<%var> Variable to unset.
[%var..] Additional variables to unset.

Example

alias example {
  ;Create and fill a variable with data.
  /set %var1 Variable test.

  ;Print the variable value.
  /echo -a %var1

  ;Unset the variable.
  unset %var1

  ;Print the variable value after unset.
  echo -a %var1
}

/unsetall

Added in 1.9.3

/unsetall

Unset and removes all variables from the variables list.

$var

Added in 1.9.0

$var(%var,[N])

Returns the Nth matching variable name.

Searches both local and global variables, wildcards can be used.

See also /var, /set, /unset, /inc, /dec.

Parameters

Parameter Description
%var Variable to match.
[N] If N = 0, number of matched variables (default), otherwise the Nth match. (optional)

Properties

Property Description
.value The variable value.
.local $true if the variable is a local variable, otherwise $false.
.secs Number of seconds until the variable is unset (if autounset is on).
.unset Number of seconds until the variable is unset (if autounset is on).

Examples

; Create a variable.
/set %Example Hello World

; Print number of variables matching '%Example*'.
//echo -ag $var(%Example*, 0)

; Print the name and value from the first match.
//echo -ag $var(%Example*, 1) = $var(%Example*, 1).value

; Delete the variable
/unset %Example

Updated by Per Amundsen about 7 years ago · 3 revisions

Also available in: PDF HTML TXT