Difference between revisions of "Set"

From Scriptwiki
Jump to: navigation, search
(add example about dynamic variables)
m (added variables category)
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 [-snzuN] <%variable> [value]
 
<table>
 
<table>
 
<tr><td><b>Switch</b></td><td><b>Meaning</b></td></tr>
 
<tr><td><b>Switch</b></td><td><b>Meaning</b></td></tr>
Line 10: Line 10:
  
 
== 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.
+
 
  /set -s %fuu 3
+
  set -u3 %fuu bar
This will set %fuu to 3 and give an output to the active window: * Set %fuu to 3
+
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 ==
Line 23: Line 27:
 
[[Unsetall|/unsetall]] unsets all variable from the variable list.
 
[[Unsetall|/unsetall]] unsets all variable from the variable list.
  
[[Category:Commands]]
+
[[Category:Commands]][[Category:Variables]]

Revision as of 17:22, 22 November 2005

Sets the value of %variable to the specified value.

/set [-snzuN] <%variable> [value]
SwitchMeaning
sGives an output: * Set %var to value.
nTreats value as plain text.
zDecreases %var until it reaches zero and then unsets it.
uNUnsets %var after N seconds, as long as %var isn't set again. If N is 0, it is unset when script finishes.

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.


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

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