Set: Difference between revisions

From Scriptwiki
Jump to navigation Jump to search
Doomie (talk | contribs)
add example about dynamic variables
m better explanation of -z
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Sets the value of %var to the specified value.
Sets the value of %variable to the specified value.
  /set [-snzuN] <%var> [value]
  /set [-lsnzuN] <%variable> [value]
<table>
{| style="width:100%"
<tr><td><b>Switch</b></td><td><b>Meaning</b></td></tr>
|-
<tr><td>s</td><td>Gives an output: * Set %var to value.</td></tr>
| style="width:10%" | '''''Switch''''' || Style="width:90%" | '''''Meaning'''''
<tr><td>n</td><td>Treats value as plain text.</td></tr>
|-
<tr><td>z</td><td>Decreases %var until it reaches zero and then unsets it.</td></tr>
| uN     || Unsets %var after N seconds, as long as %var isn't set again. If N is 0, it is unset when script finishes.
<tr><td>uN</td><td>Unsets %var after N seconds, as long as %var isn't set again. If N is 0, it is unset when script finishes.</td></tr>
|-
</table>
| k    || Keeps the current -uN setting for a variable.
|-
| n      || Treats value as plain text.
|-
| z      || Decreases %var by 1 per second until it reaches zero, and then unsets it.
|-
| e      || Unsets the variable when mIRC exits.
|-
| l      || Sets %var as a local variable, same as using /[[var]] (Deprecated, use /var)
|-
| s      || Gives an output: * Set %var to value.
|}


== Example ==
== Example ==
  /set %fuu bar
  set %fuu bar
  /set %moo [ $+ [ %fuu ] ] 42
  set %moo $+ %fuu 42
This will set %fuu to bar and then set %moobar to 42, as the variable %fuu will first be evaluated to bar.  
This will set ''%fuu'' to ''bar'' and then set ''%moobar'' to ''42'', as the variable ''%fuu'' will first be evaluated to ''bar''.  
  /set -u3 %fuu bar
 
This will set %fuu to bar and unset it after 3 seconds.
  echo -a This is fuu: %fuu
  /set -s %fuu 3
 
This will set %fuu to 3 and give an output to the active window: * Set %fuu to 3
Will echo ''This is fuu: bar''
 
'''Note:''' The variable %fuu is automatically evaluated in a /set or /var command when it is part of the variable name, however elsewhere the variable must be evaluated using either $eval or evaluation brackets, e.g.
if (%moo [ $+ [ %fuu ] ] == 42)
if ($($+(%,moo,%fuu),2) == 42)
 
set -u3 %fuu bar
This will set ''%fuu'' to ''bar'' and unset it after ''3'' seconds.
 
  set -s %fuu 3
This will set ''%fuu'' to ''3'' and give an output to the active window: ''* Set %fuu to 3''


== See Also ==
== See Also ==
[[Unset|/unset]] unsets a variable.<br />
* [[Var|/var]] sets a local variable.<br />
[[Var|/var]] sets a local variable.<br />
* [[Unset|/unset]] unsets a variable.<br />
[[Unsetall|/unsetall]] unsets all variable from the variable list.
* [[Unsetall|/unsetall]] unsets all variable from the variable list.


[[Category:Commands]]
[[Category:Commands]][[Category:Variables]]

Latest revision as of 19:10, 25 October 2013

Sets the value of %variable to the specified value.

/set [-lsnzuN] <%variable> [value]
Switch Meaning
uN Unsets %var after N seconds, as long as %var isn't set again. If N is 0, it is unset when script finishes.
k Keeps the current -uN setting for a variable.
n Treats value as plain text.
z Decreases %var by 1 per second until it reaches zero, and then unsets it.
e Unsets the variable when mIRC exits.
l Sets %var as a local variable, same as using /var (Deprecated, use /var)
s Gives an output: * Set %var to value.

Example

set %fuu bar
set %moo $+ %fuu 42

This will set %fuu to bar and then set %moobar to 42, as the variable %fuu will first be evaluated to bar.

echo -a This is fuu: %fuu

Will echo This is fuu: bar

Note: The variable %fuu is automatically evaluated in a /set or /var command when it is part of the variable name, however elsewhere the variable must be evaluated using either $eval or evaluation brackets, e.g.

if (%moo [ $+ [ %fuu ] ] == 42)
if ($($+(%,moo,%fuu),2) == 42)
set -u3 %fuu bar

This will set %fuu to bar and unset it after 3 seconds.

set -s %fuu 3

This will set %fuu to 3 and give an output to the active window: * Set %fuu to 3

See Also

  • /var sets a local variable.
  • /unset unsets a variable.
  • /unsetall unsets all variable from the variable list.