Project

General

Profile

Actions

Scripting Variables » History » Revision 1

Revision 1/3 | Next »
Per Amundsen, 02/26/2017 06:51 PM


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)

/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
}

$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 over 7 years ago · 1 revisions

Also available in: PDF HTML TXT