Project

General

Profile

Variables

/var

Added in 1.8.8

/var [-gns] <%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.

Switches

-s - Display variable assignment value.
-g - Creates a global variable instead.
-n - Treat the value as plain text, even if arithmetic operators are used.

Parameters

<%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 [-eklnsuNz] <%var> [value]

Sets the value of %var to the specified value.

Switches

-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 - TODO

Parameters

<%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 [-s] <%var> [%var..]

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

Wildcards is allowed.

Switches

-s - Prints unset information.

Parameters

<%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.

Parameters

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

Properties

.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).

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 8 months ago · 3 revisions

Also available in: PDF HTML TXT