<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.bci2000.org/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mellinger</id>
	<title>BCI2000 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.bci2000.org/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mellinger"/>
	<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php/Special:Contributions/Mellinger"/>
	<updated>2026-11-15T23:54:17Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:TransmissionFilter&amp;diff=12699</id>
		<title>User Reference:TransmissionFilter</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:TransmissionFilter&amp;diff=12699"/>
		<updated>2026-11-12T16:46:39Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Function==&lt;br /&gt;
The TransmissionFilter forwards a subset of input channels to its output.&lt;br /&gt;
Typically, it is used as the very last stage of the [[Technical Reference:Core Modules#Data Acquisition Module|data acquisition module]] to select a subset of recorded channels for on-line processing, thus reducing data transmission overhead and processing load.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
===TransmitChList===&lt;br /&gt;
A list of input channels to be forwarded to the filter&#039;s output.&lt;br /&gt;
May be defined as a list of channel names, ordinal channel numbers, wildcard patterns, or ranges.&lt;br /&gt;
* Wildcard patterns may contain the usual * and ? wildcards, character sets enclosed in [], and may be negated by prepending an exclamation mark.&lt;br /&gt;
* Ranges are given by begin and end, separated with a colon (:) or minus (-). Either of begin and end may be omitted, resulting in the full available range.&lt;br /&gt;
&lt;br /&gt;
Channel labels are forwarded if present for the input signal.&lt;br /&gt;
&lt;br /&gt;
====Examples====&lt;br /&gt;
* Each of &amp;lt;tt&amp;gt;*  :  -  1:  1-&amp;lt;/tt&amp;gt; will match the full range of available channels.&lt;br /&gt;
* &amp;lt;tt&amp;gt;!EOG*&amp;lt;/tt&amp;gt; matches all channels except those whose names begin with &amp;quot;EOG&amp;quot;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;*z&amp;lt;/tt&amp;gt; will match all central electrodes.&lt;br /&gt;
* &amp;lt;tt&amp;gt;???&amp;lt;/tt&amp;gt; will match all channels whose names consist of exactly three characters.&lt;br /&gt;
&lt;br /&gt;
===SynthesizedChannels===&lt;br /&gt;
A list of [[User_Reference:Expression_Syntax|expressions]] used to create additional channels from existing information, such as [[Technical_Reference:State_Definition|BCI2000 state variables]] and channel data. Synthesized channels will have their expression as a label, and will be appended to transmitted channels at the end.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
When [[User_Reference:Logging_Input|recording mouse position]], the position will be present in the &amp;lt;tt&amp;gt;MousePosX&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;MousePosY&amp;lt;/tt&amp;gt; state variables. To obtain additional channels with this information, set &#039;&#039;SynthesizedChannels&#039;&#039; to&lt;br /&gt;
 MousePosX MousePosY&lt;br /&gt;
&lt;br /&gt;
==States==&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[Technical Reference:Core Modules]], [[BCI2000 Glossary#Source Signal]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Filters]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:TransmissionFilter&amp;diff=12698</id>
		<title>User Reference:TransmissionFilter</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:TransmissionFilter&amp;diff=12698"/>
		<updated>2026-11-12T16:46:15Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Function==&lt;br /&gt;
The TransmissionFilter forwards a subset of input channels to its output.&lt;br /&gt;
Typically, it is used as the very last stage of the [[Technical Reference:Core Modules#Data Acquisition Module|data acquisition module]] to select a subset of recorded channels for on-line processing, thus reducing data transmission overhead and processing load.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
===TransmitChList===&lt;br /&gt;
A list of input channels to be forwarded to the filter&#039;s output.&lt;br /&gt;
May be defined as a list of channel names, ordinal channel numbers, wildcard patterns, or ranges.&lt;br /&gt;
* Wildcard patterns may contain the usual * and ? wildcards, character sets enclosed in [], and may be negated by prepending an exclamation mark.&lt;br /&gt;
* Ranges are given by begin and end, separated with a colon (:) or minus (-). Either of begin and end may be omitted, resulting in the full available range.&lt;br /&gt;
&lt;br /&gt;
Channel labels are forwarded if present for the input signal.&lt;br /&gt;
&lt;br /&gt;
====Examples====&lt;br /&gt;
* Each of &amp;lt;tt&amp;gt;*  :  -  1:  1-&amp;lt;/tt&amp;gt; will match the full range of available channels.&lt;br /&gt;
* &amp;lt;tt&amp;gt;!EOG*&amp;lt;/tt&amp;gt; matches all channels except those whose names begin with &amp;quot;EOG&amp;quot;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;*z&amp;lt;/tt&amp;gt; will match all central electrodes.&lt;br /&gt;
* &amp;lt;tt&amp;gt;???&amp;lt;/tt&amp;gt; will match all channels whose names consist of exactly three characters.&lt;br /&gt;
&lt;br /&gt;
===SynthesizedChannels===&lt;br /&gt;
A list of [[User_Reference:Expression_Syntax|expressions]] used to create additional channels from existing information, such as [[Technical_Reference:State_Definition|BCI2000 state variables]] and channel data. Synthesized channels will have their expression as a label, and will be appended to transmitted channels at the end.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
When [[recording mouse position|User_Reference:Logging_Input]], the position will be present in the &amp;lt;tt&amp;gt;MousePosX&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;MousePosY&amp;lt;/tt&amp;gt; state variables. To obtain additional channels with this information, set &#039;&#039;SynthesizedChannels&#039;&#039; to&lt;br /&gt;
 MousePosX MousePosY&lt;br /&gt;
&lt;br /&gt;
==States==&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[Technical Reference:Core Modules]], [[BCI2000 Glossary#Source Signal]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Filters]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:TransmissionFilter&amp;diff=12697</id>
		<title>User Reference:TransmissionFilter</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:TransmissionFilter&amp;diff=12697"/>
		<updated>2026-11-12T16:36:21Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Function==&lt;br /&gt;
The TransmissionFilter forwards a subset of input channels to its output.&lt;br /&gt;
Typically, it is used as the very last stage of the [[Technical Reference:Core Modules#Data Acquisition Module|data acquisition module]] to select a subset of recorded channels for on-line processing, thus reducing data transmission overhead and processing load.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
===TransmitChList===&lt;br /&gt;
A list of input channels to be forwarded to the filter&#039;s output.&lt;br /&gt;
May be defined as a list of channel names, ordinal channel numbers, wildcard patterns, or ranges.&lt;br /&gt;
* Wildcard patterns may contain the usual * and ? wildcards, character sets enclosed in [], and may be negated by prepending an exclamation mark.&lt;br /&gt;
* Ranges are given by begin and end, separated with a colon (:) or minus (-). Either of begin and end may be omitted, resulting in the full available range.&lt;br /&gt;
&lt;br /&gt;
Channel labels are forwarded if present for the input signal.&lt;br /&gt;
&lt;br /&gt;
====Examples====&lt;br /&gt;
* Each of &amp;lt;tt&amp;gt;*  :  -  1:  1-&amp;lt;/tt&amp;gt; will match the full range of available channels.&lt;br /&gt;
* &amp;lt;tt&amp;gt;!EOG*&amp;lt;/tt&amp;gt; matches all channels except those whose names begin with &amp;quot;EOG&amp;quot;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;*z&amp;lt;/tt&amp;gt; will match all central electrodes.&lt;br /&gt;
* &amp;lt;tt&amp;gt;???&amp;lt;/tt&amp;gt; will match all channels whose names consist of exactly three characters.&lt;br /&gt;
&lt;br /&gt;
==States==&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[Technical Reference:Core Modules]], [[BCI2000 Glossary#Source Signal]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Filters]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12695</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12695"/>
		<updated>2026-11-11T14:22:57Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Associating Scripts with Operator Events */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible system states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a named pipe, telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, and Visualizations (for the visualization and watches dock window).&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the main Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches area, and makes the Visualization dock window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated), but multiple changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window&amp;amp;rarr;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View&amp;amp;rarr;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START PIPE [&amp;lt;name&amp;gt;], STOP PIPE [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Starts or stops a named pipe server listening at the pipe with the given name, located in the global temporary directory. The default name is &amp;lt;tt&amp;gt;bci20000_Operator&amp;lt;/tt&amp;gt;. For named pipes, access control is implemented through file system permissions, so it is a safe way to control the Operator module from local client programs.&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to &#039;&#039;OnStart&#039;&#039; and &#039;&#039;OnResume&#039;&#039;, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, &#039;&#039;OnStartRun&#039;&#039; has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas &#039;&#039;OnStartRun&#039;&#039; is deferred until modules have confirmed to be in &#039;&#039;Running&#039;&#039; state. This makes sure that the &#039;&#039;OnStartRun&#039;&#039; event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches to idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an &#039;&#039;OnShutdown&#039;&#039; and an &#039;&#039;OnExit&#039;&#039; script are defined, the &#039;&#039;OnExit&#039;&#039; script may be executed before the &#039;&#039;OnShutdown&#039;&#039; script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts. Being restricted to a single line, one-line scripts  may still contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12694</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12694"/>
		<updated>2026-11-11T14:21:50Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* OnExit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible system states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a named pipe, telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, and Visualizations (for the visualization and watches dock window).&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the main Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches area, and makes the Visualization dock window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated), but multiple changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window&amp;amp;rarr;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View&amp;amp;rarr;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START PIPE [&amp;lt;name&amp;gt;], STOP PIPE [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Starts or stops a named pipe server listening at the pipe with the given name, located in the global temporary directory. The default name is &amp;lt;tt&amp;gt;bci20000_Operator&amp;lt;/tt&amp;gt;. For named pipes, access control is implemented through file system permissions, so it is a safe way to control the Operator module from local client programs.&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to &#039;&#039;OnStart&#039;&#039; and &#039;&#039;OnResume&#039;&#039;, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, &#039;&#039;OnStartRun&#039;&#039; has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas &#039;&#039;OnStartRun&#039;&#039; is deferred until modules have confirmed to be in &#039;&#039;Running&#039;&#039; state. This makes sure that the &#039;&#039;OnStartRun&#039;&#039; event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches to idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an &#039;&#039;OnShutdown&#039;&#039; and an &#039;&#039;OnExit&#039;&#039; script are defined, the &#039;&#039;OnExit&#039;&#039; script may be executed before the &#039;&#039;OnShutdown&#039;&#039; script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12693</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12693"/>
		<updated>2026-11-11T14:21:01Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* OnShutdown */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible system states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a named pipe, telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, and Visualizations (for the visualization and watches dock window).&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the main Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches area, and makes the Visualization dock window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated), but multiple changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window&amp;amp;rarr;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View&amp;amp;rarr;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START PIPE [&amp;lt;name&amp;gt;], STOP PIPE [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Starts or stops a named pipe server listening at the pipe with the given name, located in the global temporary directory. The default name is &amp;lt;tt&amp;gt;bci20000_Operator&amp;lt;/tt&amp;gt;. For named pipes, access control is implemented through file system permissions, so it is a safe way to control the Operator module from local client programs.&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to &#039;&#039;OnStart&#039;&#039; and &#039;&#039;OnResume&#039;&#039;, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, &#039;&#039;OnStartRun&#039;&#039; has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas &#039;&#039;OnStartRun&#039;&#039; is deferred until modules have confirmed to be in &#039;&#039;Running&#039;&#039; state. This makes sure that the &#039;&#039;OnStartRun&#039;&#039; event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches to idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12692</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12692"/>
		<updated>2026-11-11T14:20:34Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* OnStartRun */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible system states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a named pipe, telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, and Visualizations (for the visualization and watches dock window).&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the main Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches area, and makes the Visualization dock window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated), but multiple changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window&amp;amp;rarr;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View&amp;amp;rarr;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START PIPE [&amp;lt;name&amp;gt;], STOP PIPE [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Starts or stops a named pipe server listening at the pipe with the given name, located in the global temporary directory. The default name is &amp;lt;tt&amp;gt;bci20000_Operator&amp;lt;/tt&amp;gt;. For named pipes, access control is implemented through file system permissions, so it is a safe way to control the Operator module from local client programs.&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to &#039;&#039;OnStart&#039;&#039; and &#039;&#039;OnResume&#039;&#039;, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, &#039;&#039;OnStartRun&#039;&#039; has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas &#039;&#039;OnStartRun&#039;&#039; is deferred until modules have confirmed to be in &#039;&#039;Running&#039;&#039; state. This makes sure that the &#039;&#039;OnStartRun&#039;&#039; event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12691</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12691"/>
		<updated>2026-11-11T14:19:56Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* OnStartRun */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible system states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a named pipe, telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, and Visualizations (for the visualization and watches dock window).&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the main Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches area, and makes the Visualization dock window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated), but multiple changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window&amp;amp;rarr;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View&amp;amp;rarr;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START PIPE [&amp;lt;name&amp;gt;], STOP PIPE [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Starts or stops a named pipe server listening at the pipe with the given name, located in the global temporary directory. The default name is &amp;lt;tt&amp;gt;bci20000_Operator&amp;lt;/tt&amp;gt;. For named pipes, access control is implemented through file system permissions, so it is a safe way to control the Operator module from local client programs.&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to &#039;&#039;OnStart&#039;&#039; and &#039;&#039;OnResume&#039;&#039;, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, &#039;&#039;OnStartRun&#039;&#039; has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas &#039;&#039;OnStartRun&#039;&#039; is deferred until modules have confirmed to be in Running state. This makes sure that the &#039;&#039;OnStartRun&#039;&#039; event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12690</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12690"/>
		<updated>2026-11-11T14:13:42Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* START TELNET [], STOP TELNET [] */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible system states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a named pipe, telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, and Visualizations (for the visualization and watches dock window).&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the main Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches area, and makes the Visualization dock window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated), but multiple changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window&amp;amp;rarr;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View&amp;amp;rarr;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START PIPE [&amp;lt;name&amp;gt;], STOP PIPE [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Starts or stops a named pipe server listening at the pipe with the given name, located in the global temporary directory. The default name is &amp;lt;tt&amp;gt;bci20000_Operator&amp;lt;/tt&amp;gt;. For named pipes, access control is implemented through file system permissions, so it is a safe way to control the Operator module from local client programs.&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12689</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12689"/>
		<updated>2026-11-11T14:06:23Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* RECORD VISUALIZATION  [on|off] */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible system states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a named pipe, telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, and Visualizations (for the visualization and watches dock window).&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the main Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches area, and makes the Visualization dock window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated), but multiple changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window&amp;amp;rarr;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View&amp;amp;rarr;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12688</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12688"/>
		<updated>2026-11-11T14:05:36Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* MOVE VISUALIZATON   , RESIZE VISUALIZATION    */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible system states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a named pipe, telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, and Visualizations (for the visualization and watches dock window).&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the main Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches area, and makes the Visualization dock window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated), but multiple changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window&amp;amp;rarr;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12687</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12687"/>
		<updated>2026-11-11T14:03:24Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* VISUALIZE WATCH [decimate ] [range  ]  ... */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible system states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a named pipe, telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, and Visualizations (for the visualization and watches dock window).&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the main Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches area, and makes the Visualization dock window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated), but multiple changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12686</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12686"/>
		<updated>2026-11-10T14:45:35Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* VISUALIZE WATCH [decimate ] [range  ]  ... */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible system states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a named pipe, telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, and Visualizations (for the visualization and watches dock window).&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the main Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches area, and makes the Visualization dock window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12685</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12685"/>
		<updated>2026-11-10T14:44:22Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* ARRANGE WINDOW      [ ] */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible system states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a named pipe, telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, and Visualizations (for the visualization and watches dock window).&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the main Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12684</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12684"/>
		<updated>2026-11-10T14:43:05Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* HIDE WINDOW [], SHOW WINDOW [] */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible system states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a named pipe, telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, and Visualizations (for the visualization and watches dock window).&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12683</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12683"/>
		<updated>2026-11-10T14:39:21Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* CLOSE CONNECTION, TERMINATE CONNECTION */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible system states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a named pipe, telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, Watches, and Visualizations. When &amp;quot;Watches&amp;quot; is given, the window state refers to visibility of the Watches area in the Visualizations window.&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12682</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12682"/>
		<updated>2026-11-10T14:36:37Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* WAIT FOR  [] */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible system states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, Watches, and Visualizations. When &amp;quot;Watches&amp;quot; is given, the window state refers to visibility of the Watches area in the Visualizations window.&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12681</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12681"/>
		<updated>2026-11-10T14:35:51Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* GET CURRENT RUN FILE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current [[BCI2000_Glossary#Run|run]] file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, Watches, and Visualizations. When &amp;quot;Watches&amp;quot; is given, the window state refers to visibility of the Watches area in the Visualizations window.&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12680</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12680"/>
		<updated>2026-11-10T14:09:30Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Commands operating on Events */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Event States====&lt;br /&gt;
Event States are a special type of state, which are recorded asynchronously, at single-sample resolution. Event States may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event state to the system. Like state variables, event states are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event state to the given value for a single sample duration. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given event states to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event state changes are recorded at exactly the same point in time. Recording event states requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event state. Note that event state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event state&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all event states, or event states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of event states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current run file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, Watches, and Visualizations. When &amp;quot;Watches&amp;quot; is given, the window state refers to visibility of the Watches area in the Visualizations window.&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12679</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12679"/>
		<updated>2026-11-10T14:04:03Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* SET STATE  , SET STATES     ... */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
SET STATES will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Events====&lt;br /&gt;
Events are a special type of state, which are recorded asynchronously, at single-sample resolution. Events may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event to the system. Like state variables, events are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value for a single sample duration. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event. Note that evemt values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all events, or events with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of events in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current run file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, Watches, and Visualizations. When &amp;quot;Watches&amp;quot; is given, the window state refers to visibility of the Watches area in the Visualizations window.&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12678</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12678"/>
		<updated>2026-11-10T14:02:42Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Commands operating on States */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both &#039;&#039;Stream States&#039;&#039;, and normal States.&lt;br /&gt;
For &#039;&#039;Event States&#039;&#039;, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;SET STATES&amp;lt;/tt&amp;gt; will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Events====&lt;br /&gt;
Events are a special type of state, which are recorded asynchronously, at single-sample resolution. Events may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event to the system. Like state variables, events are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value for a single sample duration. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event. Note that evemt values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all events, or events with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of events in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current run file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, Watches, and Visualizations. When &amp;quot;Watches&amp;quot; is given, the window state refers to visibility of the Watches area in the Visualizations window.&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12677</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12677"/>
		<updated>2026-11-10T13:52:12Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* EVALUATE CONDITION  [ []] */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If it entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both Stream States, and normal States.&lt;br /&gt;
For Event States, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;SET STATES&amp;lt;/tt&amp;gt; will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Events====&lt;br /&gt;
Events are a special type of state, which are recorded asynchronously, at single-sample resolution. Events may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event to the system. Like state variables, events are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value for a single sample duration. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event. Note that evemt values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all events, or events with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of events in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current run file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, Watches, and Visualizations. When &amp;quot;Watches&amp;quot; is given, the window state refers to visibility of the Watches area in the Visualizations window.&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12676</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12676"/>
		<updated>2026-11-10T13:51:03Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* EVALUATE CONDITION  [ []] */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality or inequality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the remaining tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both Stream States, and normal States.&lt;br /&gt;
For Event States, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;SET STATES&amp;lt;/tt&amp;gt; will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Events====&lt;br /&gt;
Events are a special type of state, which are recorded asynchronously, at single-sample resolution. Events may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event to the system. Like state variables, events are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value for a single sample duration. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event. Note that evemt values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all events, or events with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of events in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current run file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, Watches, and Visualizations. When &amp;quot;Watches&amp;quot; is given, the window state refers to visibility of the Watches area in the Visualizations window.&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12675</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12675"/>
		<updated>2026-11-10T13:41:52Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET ENVIRONMENT PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the inequality tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both Stream States, and normal States.&lt;br /&gt;
For Event States, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;SET STATES&amp;lt;/tt&amp;gt; will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Events====&lt;br /&gt;
Events are a special type of state, which are recorded asynchronously, at single-sample resolution. Events may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event to the system. Like state variables, events are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value for a single sample duration. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event. Note that evemt values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all events, or events with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of events in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current run file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, Watches, and Visualizations. When &amp;quot;Watches&amp;quot; is given, the window state refers to visibility of the Watches area in the Visualizations window.&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12674</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12674"/>
		<updated>2026-11-10T13:38:09Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the second example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET VARIABLE PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the inequality tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both Stream States, and normal States.&lt;br /&gt;
For Event States, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;SET STATES&amp;lt;/tt&amp;gt; will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Events====&lt;br /&gt;
Events are a special type of state, which are recorded asynchronously, at single-sample resolution. Events may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event to the system. Like state variables, events are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value for a single sample duration. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event. Note that evemt values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all events, or events with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of events in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current run file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, Watches, and Visualizations. When &amp;quot;Watches&amp;quot; is given, the window state refers to visibility of the Watches area in the Visualizations window.&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12673</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12673"/>
		<updated>2026-11-10T13:36:17Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), both lines will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables by the operating system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the last example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET VARIABLE PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the inequality tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both Stream States, and normal States.&lt;br /&gt;
For Event States, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;SET STATES&amp;lt;/tt&amp;gt; will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Events====&lt;br /&gt;
Events are a special type of state, which are recorded asynchronously, at single-sample resolution. Events may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event to the system. Like state variables, events are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value for a single sample duration. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event. Note that evemt values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all events, or events with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of events in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current run file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, Watches, and Visualizations. When &amp;quot;Watches&amp;quot; is given, the window state refers to visibility of the Watches area in the Visualizations window.&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12672</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12672"/>
		<updated>2026-11-10T13:34:51Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variable names are case sensitive, and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), it will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the last example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET VARIABLE PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the inequality tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both Stream States, and normal States.&lt;br /&gt;
For Event States, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;SET STATES&amp;lt;/tt&amp;gt; will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Events====&lt;br /&gt;
Events are a special type of state, which are recorded asynchronously, at single-sample resolution. Events may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event to the system. Like state variables, events are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value for a single sample duration. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event. Note that evemt values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all events, or events with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of events in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current run file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, Watches, and Visualizations. When &amp;quot;Watches&amp;quot; is given, the window state refers to visibility of the Watches area in the Visualizations window.&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12671</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12671"/>
		<updated>2026-11-10T13:33:48Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named pipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variables and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), it will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the last example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET VARIABLE PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the inequality tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both Stream States, and normal States.&lt;br /&gt;
For Event States, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;SET STATES&amp;lt;/tt&amp;gt; will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Events====&lt;br /&gt;
Events are a special type of state, which are recorded asynchronously, at single-sample resolution. Events may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event to the system. Like state variables, events are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value for a single sample duration. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event. Note that evemt values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all events, or events with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of events in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current run file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, Watches, and Visualizations. When &amp;quot;Watches&amp;quot; is given, the window state refers to visibility of the Watches area in the Visualizations window.&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12670</id>
		<title>User Reference:Operator Module Scripting</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:Operator_Module_Scripting&amp;diff=12670"/>
		<updated>2026-11-10T13:33:32Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Operator scripts automate actions that the otherwise would be performed by the user, e.g. starting or suspending system operation.&lt;br /&gt;
Scripts may be contained in script files, or given immediately in the operator module&#039;s preferences dialog.&lt;br /&gt;
There is also an option to specify scripts from the [[User Reference:Module Command Line Options#Operator Module|command line]] when starting the operator module. When using the [[User_Reference:BCI2000Shell|BCI2000Shell]], or the [[Technical_Reference:Operator_Library|Operator Library]] from your own application, you may execute scripts at any time.&lt;br /&gt;
&lt;br /&gt;
In addition, the operator scripting language may be used to control an operator module over a [[User_Reference:Module_Command_Line_Options#--Pipe|named piipe]], [[User_Reference:Module_Command_Line_Options#--Telnet|Telnet]] or [[User_Reference:Module_Command_Line_Options#--WebSocket|WebSocket]] connection.&lt;br /&gt;
===Syntax===&lt;br /&gt;
&#039;&#039;&#039;Command separation.&#039;&#039;&#039; Scripts consist of sequences of the commands listed below. A command must be terminated with either a newline, or a semicolon (;).&lt;br /&gt;
This allows to put multiple commands into one line, separated by semicolon characters.&lt;br /&gt;
Commands are case-insensitive, variables and values may be case-sensitive, depending on context.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Comments.&#039;&#039;&#039; Lines starting with a &#039;#&#039; character are ignored. Such lines may be used to hold comments. In addition, when any of the first two lines of a script contains &amp;quot;#!&amp;quot; (the Unix shell invocation sequence), it will be ignored. In conjunction with [[User Reference:BCI2000Shell|BCI2000Shell]], this may be used to write Operator scripts that may be treated as executables.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Escaping.&#039;&#039;&#039; In order to resolve ambiguity about command arguments that contain white space, they must be included in double quotes, or the white space must be encoded in URL-fashion, e.g. &#039;&#039;%20&#039;&#039; instead of a space character. Similarly, when an argument contains a semicolon (;), it must be included in double quotes, or the semicolon must be encoded in URL-fashion, i.e. as &#039;&#039;%3B&#039;&#039;. Also, &amp;quot;$&amp;quot; characters indicate command substitution, so they should be encoded as &#039;&#039;%24&#039;&#039; if substitution is not desired.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable Substitution.&#039;&#039;&#039; When a command contains a dollar sign, alphanumeric characters following the dollar sign will be interpreted as the name of a variable: $NAME. The name will be matched against Expression variable names first, followed with Local variable names, and finally Environment variable names. When a match is found, $NAME will be replaced with the content of the matching variable. When no match is found, $NAME will be resolved to an empty string, without triggering an error.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command Substitution.&#039;&#039;&#039; When part of a command is enclosed with ${...}, this subexpression will be substituted with the result of its execution as a command. E.g.,&lt;br /&gt;
 LOG &amp;quot;Current system state is: ${GET SYSTEM STATE}&amp;quot;&lt;br /&gt;
 LOG &amp;quot;The path environment variable is: ${PATH}&amp;quot;&lt;br /&gt;
Note that the last example uses the short form of the GET command, which will return the value of a PATH parameter or a PATH state if such exists. To make sure that only environment variables are matched, use the long form of the GET command:&lt;br /&gt;
 LOG MESSAGE &amp;quot;The path environment variable is: ${GET VARIABLE PATH}&amp;quot;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Substitutions may be nested, i.e. the following will work as expected:&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${$MyVar}&amp;quot;&lt;br /&gt;
 SET MyVar &amp;quot;LIST STATES&amp;quot;; LOG &amp;quot;States are: ${${GET VARIABLE MyVar}}&amp;quot;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mathematical Expressions.&#039;&#039;&#039; A command may consist of a single [[User Reference:Expression Syntax|mathematical expression]]. This expression is then evaluated, and its result is returned as the command&#039;s result. As a special case, this allows the use of expression variables in ${...} substitutions. Consider for example&lt;br /&gt;
 x:=0; WHILE x&amp;lt;10; LOG ${x:=x+1}; END&lt;br /&gt;
There, the first command creates and initializes the expression variable x. In the WHILE condition, an expression is allowed as well as any command. In the LOG command, an expression appears in ${...}, which executes the expression in braces, and substitutes the result of the expression as an argument into the LOG command, which adds an entry to the Operator log. This results in a sequence of 10 log entries, containing the numbers from 1 to 10.&lt;br /&gt;
&lt;br /&gt;
===Commands===&lt;br /&gt;
====Control commands====&lt;br /&gt;
These commands allow conditional execution of parts of a script. When a condition is expected, any other scripting command may be given. Its result will be considered to represent a boolean value of &amp;quot;true&amp;quot; if it is empty, a nonzero number, or the string &amp;quot;true&amp;quot;. It will be taken to represent a boolean value of &amp;quot;false&amp;quot; if it contains a numeric value of zero, or any string that does not evaluate to a nonzero number. Note that identification of an empty value with &amp;quot;true&amp;quot; differs from string handling in the EVALUATE CONDITION command. This is because most scripting commands return nothing on success, but an error message on failure.&lt;br /&gt;
&lt;br /&gt;
The output of the SYSTEM and START EXECUTABLE commands is handled specially. There, the result code of the created child process is translated into a boolean value in the ordinary manner, treating a result code of zero as &amp;quot;true&amp;quot;, and any other result code as &amp;quot;false&amp;quot;. This allows to use external commands in the same way as in a native shell.&lt;br /&gt;
&lt;br /&gt;
=====IF &amp;lt;condition&amp;gt;; &amp;lt;if commands&amp;gt;; [ ELSEIF &amp;lt;condition&amp;gt;; &amp;lt;elseif commands&amp;gt;;] ... [ ELSE; &amp;lt;else commands&amp;gt;;] END=====&lt;br /&gt;
Executes &#039;&#039;if commands&#039;&#039; if &#039;&#039;condition&#039;&#039; evaluates to &amp;quot;true&amp;quot;. Otherwise, the &#039;&#039;elseif commands&#039;&#039; of the first matching &#039;&#039;elseif condition&#039;&#039; are executed. When none of the &#039;&#039;elseif conditions&#039;&#039; evaluates to &amp;quot;true&amp;quot;,  &#039;&#039;else commands&#039;&#039; are executed. ELSEIF and ELSE blocks may be omitted.&lt;br /&gt;
&lt;br /&gt;
=====WHILE &amp;lt;condition&amp;gt;; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; while &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
=====DO; &amp;lt;loop commands&amp;gt;; UNTIL &amp;lt;condition&amp;gt;=====&lt;br /&gt;
Executes &#039;&#039;loop commands&#039;&#039; until &#039;&#039;condition&#039;&#039; evaluates to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====FOR &amp;lt;name&amp;gt; IN &amp;lt;item1&amp;gt; &amp;lt;item2&amp;gt; ... ; &amp;lt;loop commands&amp;gt;; END=====&lt;br /&gt;
Creates a local variable with the specified name. Then, sequentially assigns each &#039;&#039;item&#039;&#039; to that variable, and executes &#039;&#039;loop commands&#039;&#039;. If an &#039;&#039;item&#039;&#039; contains newline characters, it is split up into multiple items, corresponding to the lines contained in the &#039;&#039;item&#039;&#039;. E.g.,&lt;br /&gt;
 FOR i IN top ${LIST FILES} bottom; LOG ${i}; END&lt;br /&gt;
will first write a log entry &amp;quot;top&amp;quot;. Then, it will create a log entry for each file in the current directory, and finally, it will create a log entry &amp;quot;bottom&amp;quot;.&lt;br /&gt;
=====RETURN [&amp;lt;value&amp;gt;]=====&lt;br /&gt;
Finishes execution of the current script, and optionally returns a value to the caller.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Conditions====&lt;br /&gt;
=====EVALUATE CONDITION &amp;lt;left&amp;gt; [&amp;lt;op&amp;gt; [&amp;lt;right&amp;gt;]]=====&lt;br /&gt;
Evaluates a comparison between the &#039;&#039;left&#039;&#039; and &#039;&#039;right&#039;&#039; operands. As a comparison operator, the following may be specified: ==, !=, ~=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. There, the != operator behaves identically to the ~= operator. When a test for equality is performed, the two operands are treated as strings, and compared in a case-insensitive manner. When any of the inequality tests is performed, the two operands are converted into floating-point numbers before comparison.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;right&#039;&#039; operand may be omitted, in which case it is treated as if an empty string were specified. Also, the &#039;&#039;op&#039;&#039; operator may be omitted, in which case the following rules apply regarding the remaining operand: If it is an empty string, or equal to the string &amp;quot;false&amp;quot; in case-insensitive comparison, the result is &amp;quot;false&amp;quot;. If entirely consists of the text representation of a floating-point number, the result is &amp;quot;false&amp;quot; if the number is 0, and &amp;quot;true&amp;quot; if the number is not 0.&lt;br /&gt;
&lt;br /&gt;
Inspired by the unix sh shells&#039; &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; command, there exists a short form of the EVALUATE CONDITION command, where the arguments of EVALUATE CONDITION may appear within square brackets. This allows constructs such as&lt;br /&gt;
 IF [ ${MyVar} == MyValue ]; LOG Is equal; ELSE; LOG Is different; END&lt;br /&gt;
Note that the arguments to EVALUATE CONDITION must always be separated by white space, no matter whether its long or short form is used.&lt;br /&gt;
&lt;br /&gt;
Conditions may be combined logically using the operators &amp;amp;&amp;amp; and ||.   These go &#039;&#039;outside&#039;&#039; the square brackets.  Note also that whitespace around the comparison operators is critical, otherwise the conditional will be treated as a single string (which will always evaluate to &amp;quot;true&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 IF [ ${foo} == foo ] || [ ${bar} == bar ]; LOG got a match; END&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Local Variables====&lt;br /&gt;
Besides environment variables, there exist local variables in scripts. Local variables are inherited by sub-scripts executed with the EXECUTE SCRIPT command, but changes to the variable&#039;s values will not be propagated to the calling script.&lt;br /&gt;
=====SET VARIABLE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message generated.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Environment Variables====&lt;br /&gt;
These scripting commands allow to read and modify environment variables. Changes to environment variables will be visible to child processes started with SYSTEM or START EXECUTABLE. Variable values are stored as strings. Variable names may not contain the equals sign.&lt;br /&gt;
=====SET ENVIRONMENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named variable to the specified value.&lt;br /&gt;
=====CLEAR ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named variable from memory.&lt;br /&gt;
=====GET ENVIRONMENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns the variable&#039;s current value. When the variable does not exist, an empty value is returned rather than an error message.&lt;br /&gt;
=====WRITE ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
Writes a series of SET ENVIRONMENT statements to the specified file, overwriting any previous file contents.  This saves the values of the named variables in such a way that you can later load them back by calling EXECUTE SCRIPT &amp;lt;filename&amp;gt;. The variable names may refer to either local or environment variables at the time of writing, but when you execute the script they will all be loaded as environment variables.&lt;br /&gt;
=====APPEND ENVIRONMENT &amp;lt;fileName&amp;gt; &amp;lt;variableName1&amp;gt; &amp;lt;variableName2&amp;gt; ...=====&lt;br /&gt;
This is the same as WRITE ENVIRONMENT, except that the SET ENVIRONMENT statements are appended to the named file without overwriting its previous contents.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Scripts====&lt;br /&gt;
=====SET SCRIPT &amp;lt;handler names&amp;gt; &amp;lt;scripting commands&amp;gt;=====&lt;br /&gt;
Associates a sequence of scripting commands with the named handler. Handlers are specified by names as given [[#Handlers|below]]. Multiple handlers may be specified by concatenating their names with a pipe character, e.g. &amp;quot;OnStart|OnResume&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Scripting commands must be included in double quotes, unless they consist of a single word.&lt;br /&gt;
When specifying a sequence of scripting commands, they must be separated with a semicolon character: &amp;quot;SetConfig; Start&amp;quot;. In order to use double quotes or semicolons within the commands themselves, encode these as you would in a URL, i.e. replace a double quote character with &#039;&#039;%22&#039;&#039;, and a semicolon with &#039;&#039;%3B&#039;&#039;: &amp;quot;Load Parameters %22my file%22&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To use a script file rather than a literal script, use the EXECUTE SCRIPT command:&lt;br /&gt;
 SET SCRIPT OnConnect &amp;quot;EXECUTE SCRIPT myscript.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=====GET SCRIPT &amp;lt;handler name&amp;gt;=====&lt;br /&gt;
Returns the script associated with the specified handler.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR SCRIPT &amp;lt;handler names&amp;gt;=====&lt;br /&gt;
Clears scripts for the given handlers. Equivalent to calling SET SCRIPT with an empty script.&lt;br /&gt;
&lt;br /&gt;
=====EXECUTE SCRIPT &amp;lt;file or handler name&amp;gt; [&amp;lt;Arg1&amp;gt; &amp;lt;Arg2&amp;gt; ... &amp;lt;Arg9&amp;gt;]=====&lt;br /&gt;
Executes a script contained in a file, and optionally sets the script&#039;s local variables &#039;&#039;1&#039;&#039; to &#039;&#039;9&#039;&#039; to the specified values. To execute script commands already associated with a handler, provide a handler name rather than a file. When the script is executed successfully, the result of the last executed script command becomes the result of the EXECUTE SCRIPT command itself. Use &amp;quot;RETURN &amp;lt;value&amp;gt;&amp;quot; anywhere in a script in order to finish execution, and return a certain value.&lt;br /&gt;
&lt;br /&gt;
When you run a script through EXECUTE SCRIPT, it will inherit copies of variables from its calling script/command line. Modifications of variables will be local to the script, and will be lost when script execution is complete.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;AbortOnError&#039;&#039; variable determines whether a script is aborted when any of its commands result in an error message. &#039;&#039;AbortOnError&#039;&#039; is not inherited but defaults to 1 in any script.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Parameters====&lt;br /&gt;
=====LOAD PARAMETERFILE &amp;lt;file&amp;gt;, LOAD PARAMETERS &amp;lt;file&amp;gt;=====&lt;br /&gt;
Loads a parameter file specified by its path and name. Relative paths are interpreted relative to the operator module&#039;s working directory at startup. Usually, this matches the executable&#039;s location in the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
As the parameter file name must not contain white space, please use HTML-type encoding for white space characters, such as &amp;lt;tt&amp;gt;Documents%20and%20Settings&amp;lt;/tt&amp;gt; when referring to a user&#039;s &amp;quot;Documents and Settings&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
NOTE: Only those parameters will be loaded that do exist at the time when this command is called. In idle state, no parameters exist other than created by ADD PARAMETER. After modules are connected and have published their parameters to the Operator module, a full set of parameters exists.&lt;br /&gt;
&lt;br /&gt;
=====ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;=====&lt;br /&gt;
Adds a parameter to the system. The parameter is specified as a [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====EXISTS PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====ISEMPTY PARAMETER &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified parameter exists and has no values, &amp;quot;false&amp;quot; if it exists and has values.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )] &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named parameter to the specified value. Values that contain special characters, or whitespace must use the [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. Use parentheses to specify indices or labels. Omitted indices default to 1.&lt;br /&gt;
&lt;br /&gt;
=====SET [JSON] PARAMETER &amp;lt;parameter line&amp;gt;=====&lt;br /&gt;
Replace a parameter&#039;s value and definition with the information given in the [[Technical_Reference:Parameter_Definition#Parameter_Lines|parameter line]]. The parameter must exist in the system when this command is executed.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, the parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETER &amp;lt;name&amp;gt;[( idx1, idx2 )]=====&lt;br /&gt;
Prints the value of the named parameter. Use parentheses to specify indices or labels.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERROWS &amp;lt;parameter name&amp;gt; &amp;lt;rows&amp;gt;=====&lt;br /&gt;
Sets the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERROWS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of rows in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====SET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Sets the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====GET PARAMETERCOLS &amp;lt;parameter name&amp;gt;=====&lt;br /&gt;
Prints the number of columns in the named parameter.&lt;br /&gt;
&lt;br /&gt;
=====LIST [JSON] PARAMETER &amp;lt;wildcard expression&amp;gt;, LIST [JSON] PARAMETERS=====&lt;br /&gt;
Prints all parameters with names matching the wildcard expression, in form of parameter lines.&lt;br /&gt;
&lt;br /&gt;
If the optional &amp;quot;JSON&amp;quot; attribute is given, matching parameters are provided in [[User Reference:JSON Parameter Format|JSON parameter format]], as an array of parameter objects.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR PARAMETERS=====&lt;br /&gt;
Clears the list of parameters in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on States====&lt;br /&gt;
In BCI2000, there are three types of States that differ in their alignment to brain signal data (see [[Technical_Reference:State_Definition#Kinds_of_States|Kinds of States]]). This section applies to both Stream States, and normal States.&lt;br /&gt;
For Event States, see the next section.&lt;br /&gt;
&lt;br /&gt;
=====ADD STATE &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds a state variable to the system. State variables are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after system initialization has completed, i.e. its use is restricted to the &amp;quot;Idle&amp;quot; and &amp;quot;Publishing&amp;quot; [[Technical_Reference:States_of_Operation#Publishing_Phase|phases of system operation]]. In terms of handlers, its use is restricted to the &#039;&#039;OnConnect&#039;&#039; handler.&lt;br /&gt;
=====EXISTS STATE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified state exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET STATE &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, SET STATES &amp;lt;name1&amp;gt; &amp;lt;value1&amp;gt; &amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt; ...=====&lt;br /&gt;
Sets the named state variable to the specified integer value by sending a state message to the source module.&lt;br /&gt;
Setting the &#039;&#039;Running&#039;&#039; state to 1 will start system operation, setting it to 0 will suspend the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;SET STATES&amp;lt;/tt&amp;gt; will atomically set the values of multiple states.&lt;br /&gt;
&lt;br /&gt;
=====GET STATE[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named state. Note that state values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0. In that case, GET STATE will return the state&#039;s initial value.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the state value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the state&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST STATE &amp;lt;wildcard expression&amp;gt;, LIST STATES=====&lt;br /&gt;
Lists all states, or states with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR STATES=====&lt;br /&gt;
Clears the list of states in the system. May only be executed in &#039;&#039;Idle&#039;&#039; and &#039;&#039;Publishing&#039;&#039; system states.&lt;br /&gt;
&lt;br /&gt;
=====FREEZE STATES, THAW STATES=====&lt;br /&gt;
Freezes/thaws the values of all states in the state vector, without interfering with system operation.  &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the state vector. For the duration of its existence, GET STATE calls will be diverted to the snapshot.  This is useful for ensuring that multiple GET STATE commands actually retrieve mutually-consistent values from different state variables (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
=====GET STATEVECTOR SAMPLES=====&lt;br /&gt;
Returns the number of samples in the state vector per block of data. In the system&#039;s &amp;quot;Running&amp;quot; state, this matches the number of samples per block in the source data. Prior to the &amp;quot;Running&amp;quot; state, this command returns 1 because the state vector has not yet been updated from the application module.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Events====&lt;br /&gt;
Events are a special type of state, which are recorded asynchronously, at single-sample resolution. Events may only be added while the system is in &amp;quot;idle&amp;quot; state. This kind of events is not related to [[#Handlers|Operator Events]] as defined below.&lt;br /&gt;
=====ADD EVENT &amp;lt;name&amp;gt; &amp;lt;bit width&amp;gt; &amp;lt;initial value&amp;gt;=====&lt;br /&gt;
Adds an event to the system. Like state variables, events are defined by name, bit width, and initial value (see [[Technical Reference:State Definition]]). This command may not be used after the system has started up, so it is typically executed in a batch file before &#039;&#039;STARTUP&#039;&#039; has been called.&lt;br /&gt;
&lt;br /&gt;
=====EXISTS EVENT &amp;lt;name&amp;gt;=====&lt;br /&gt;
Returns &amp;quot;true&amp;quot; when the specified event exists in the system, and &amp;quot;false&amp;quot; otherwise.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In versions prior to BCI2000 3.06, this command behaved as described for PULSE EVENT below, rather than as advertised. If you used SET EVENT in your scripts, it is recommended to replace it with PULSE EVENT in order to retain original behavior.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENT &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Asynchronously sets an event to the given value for a single sample duration. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====SET EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values. Using this command, rather than multiple SET EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====PULSE EVENTS [&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;] [&amp;lt;name2&amp;gt; &amp;lt;value2&amp;gt;] ... =====&lt;br /&gt;
Asynchronously sets given events to their specified values for a single sample duration. Using this command, rather than multiple PULSE EVENT commands in a row, ensures that all event changes are recorded at exactly the same point in time. Recording events requires the EventLink logger component to be present in the source module.&lt;br /&gt;
&lt;br /&gt;
=====GET EVENT[(&amp;lt;sample&amp;gt;)] &amp;lt;name&amp;gt;=====&lt;br /&gt;
Gets the value of the named event. Note that evemt values are not updated from the application module when the &#039;&#039;OperatorBackLink&#039;&#039; parameter is 0.&lt;br /&gt;
&lt;br /&gt;
An optional one-based sample index may be given to indicate that the event&#039;s value should be retrieved at the given sample position. Sample positions range from 1 to the number of samples per block present in the state vector. The number of samples per block may be retrieved using GET STATEVECTOR SAMPLES.&lt;br /&gt;
&lt;br /&gt;
By default, the event&#039;s value is retrieved for sample index 1.&lt;br /&gt;
&lt;br /&gt;
=====LIST EVENT &amp;lt;wildcard expression&amp;gt;, LIST EVENTS=====&lt;br /&gt;
Lists all events, or events with names matching the given wildcard expression, in form of state lines.&lt;br /&gt;
=====CLEAR EVENTS=====&lt;br /&gt;
Clears the list of events in the system. May only be executed in &#039;&#039;Idle&#039;&#039; state.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on VisProperties====&lt;br /&gt;
=====SET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt; &amp;lt;value&amp;gt;=====&lt;br /&gt;
Sets the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID to the given value. If the visualization ID contains a dot character, it must be encoded in [[Technical_Reference:Parameter_Definition#Special_Characters|parameter value encoding]]. E.g., setting the window width for the visualization ID &amp;quot;2.D1&amp;quot; would be written &amp;lt;code&amp;gt;SET VISPROPERTY 2%2ED1.Width 200&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====RESET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Removes the named visualization property with the specified visualization ID from the property store, effectively resetting its value to its default.&lt;br /&gt;
&lt;br /&gt;
=====GET VISPROPERTY &amp;lt;visID&amp;gt;.&amp;lt;name&amp;gt;=====&lt;br /&gt;
Prints the value of the named [[Technical Reference:Visualization Properties|visualization property]] for the specified visualization ID.&lt;br /&gt;
&lt;br /&gt;
=====SET VISPROPERTIES &amp;lt;property set ID&amp;gt;=====&lt;br /&gt;
Applies a set of visualization property values as given in the [[#VisPropertySets|VisPropertySets]] parameter. In that matrix-valued parameter, row labels specify visualization properties such as &amp;quot;SRCD.Left&amp;quot;, and columns represent sets of property values. Column labels are IDs of the corresponding property sets.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on the Control Signal====&lt;br /&gt;
=====GET SIGNAL( &amp;lt;channel index&amp;gt;, &amp;lt;element index&amp;gt; )=====&lt;br /&gt;
Prints the value of the control signal at the given indices. Indices are 1-based.&lt;br /&gt;
=====GET SIGNAL CHANNELS=====&lt;br /&gt;
Prints the number of channels in the control signal.&lt;br /&gt;
=====GET SIGNAL ELEMENTS=====&lt;br /&gt;
Prints the number of elements (samples) in the control signal.&lt;br /&gt;
=====FREEZE SIGNAL, THAW SIGNAL=====&lt;br /&gt;
Freezes/thaws the contents of the control signal, without interfering with system operation. &amp;quot;Freezing&amp;quot; creates, and &amp;quot;thawing&amp;quot; discards, a frozen snapshot of the control signal. For the duration of its existence, GET SIGNAL calls will be diverted to the snapshot. This is useful for ensuring that multiple GET SIGNAL commands actually retrieve mutually-consistent values from different elements in the control signal (i.e. values from the same sample-block).&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Expressions====&lt;br /&gt;
=====EVALUATE EXPRESSION &amp;lt;expression&amp;gt;=====&lt;br /&gt;
This command treats the remainder of the command as a literal mathematical expression (for a description, see [[User Reference:Expression Syntax]]). An expression may contain assignments to variables; such variables may then be used in later expressions. Note that expression variables are different from local and environment variables that may be accessed by GET/SET VARIABLE/ENVIRONMENT. Expression variables hold numerical values, while local and environment variables hold string values. Also, environment variables are accessible to child processes started with SYSTEM or START EXECUTABLE, while expression variables are accessible only to scripts. When a script is executed using the EXECUTE SCRIPT command, it will inherit a copy of all expression variables present. Changes to these variables from the executed script will not be visible in the parent script.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR EXPRESSION VARIABLE &amp;lt;name&amp;gt;=====&lt;br /&gt;
Clears the named expression variable from storage.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Watches====&lt;br /&gt;
A &amp;quot;Watch&amp;quot; is an object that consists of a set of expressions, and an action. Whenever the value of any of the expressions changes, the watch is &amp;quot;triggered&amp;quot;, and the action is executed. Watches allow client applications to respond to BCI2000 state changes in a reliable manner. Rather than polling information from BCI2000, a client may create a watch to be notified about changes of interest. This avoids the problem of missing short-lived changes, which is inherent in the polling approach.&lt;br /&gt;
&lt;br /&gt;
For watches created through operator scripting, the action consists of dumping values of all the expressions to a UDP port.&lt;br /&gt;
&lt;br /&gt;
The intended use of a watch from a client application is to create a separate thread that reads from the watch&#039;s UDP port in a blocking mode, and calls an appropriate handler function whenever it receives data.&lt;br /&gt;
The data sent will consist of a single UDP packet with a single line in ASCII format, terminated with a CRLF sequence. The line consists of tab-separated data fields, which contain the current values of the expressions specified when creating the watch. In addition, the first field contains a time stamp in milliseconds. This time stamp represents the point in time where the expression value changed, with an accuracy of a single sample.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH [decimate &amp;lt;n&amp;gt;] &amp;lt;expression1&amp;gt; &amp;lt;expression2&amp;gt; ... [AT &amp;lt;ip:port&amp;gt;]=====&lt;br /&gt;
Adds a watch for the listed expressions. Each expression&#039;s value will be reported in a separate field. When an address is specified in &amp;lt;tt&amp;gt;ip:port&amp;lt;/tt&amp;gt; format, the watch tries to open that port for output, and creation fails if that port is taken. When no address is specified, a free port is chosen automatically. In both cases, successful creation of the watch is indicated by returning the output address in ASCII format. The address is also used to uniquely identify a watch in the context of a connection.&lt;br /&gt;
&lt;br /&gt;
When a &#039;&#039;decimate &amp;lt;n&amp;gt;&#039;&#039; clause is present, the watch will be created with decimation, i.e. it will only be evaluated for every &#039;&#039;n&#039;&#039;th&lt;br /&gt;
sample of the state vector.&lt;br /&gt;
&lt;br /&gt;
If a watch is created through a remote connection, it will use the remote host&#039;s external IP address for automatically chosen addresses. Otherwise, the output port will be associated with the machine&#039;s &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; address.&lt;br /&gt;
&lt;br /&gt;
Watches may be created even if the system is currently running. In this case, the watch is triggered immediately at creation, and sends its current expression values to its output port.&lt;br /&gt;
&lt;br /&gt;
=====ADD WATCH SYSTEM STATE [AT &amp;lt;address&amp;gt;]=====&lt;br /&gt;
Similar to the first variant of ADD WATCH, but will watch the system&#039;s state as reported by GET SYSTEM STATE.&lt;br /&gt;
&lt;br /&gt;
=====CLEAR WATCH &amp;lt;address&amp;gt;, CLEAR WATCHES [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Removes the watches specified by address, or those with their addresses matching a wildcard expression. If CLEAR WATCHES is called without argument, all watches will be deleted.&lt;br /&gt;
&lt;br /&gt;
=====TRIGGER WATCH &amp;lt;address&amp;gt;, TRIGGER WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Forces dumping of the watches&#039; current expression values to their output ports. Mostly useful for testing purposes.&lt;br /&gt;
&lt;br /&gt;
=====LIST WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Displays a list of existing watches, and their addresses.&lt;br /&gt;
&lt;br /&gt;
=====COUNT WATCHES  [&amp;lt;wildcard-expression&amp;gt;]=====&lt;br /&gt;
Returns the number of existing watches, or the number of watches whose addresses match the optional wildcard expression.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Files, Directories, and Paths====&lt;br /&gt;
=====EXTRACT DIRECTORY &amp;lt;path&amp;gt;, EXTRACT FILE &amp;lt;path&amp;gt;, EXTRACT FILE BASE &amp;lt;path&amp;gt;=====&lt;br /&gt;
Extracts the directory or file portion of a given path. When the path specifies a non-existing directory, the directory name must be followed with a separator (&amp;quot;/&amp;quot;) in order to be recognized as a directory. The EXTRACT DIRECTORY command always returns its result with a trailing separator. The EXTRACT FILE BASE command returns the file portion without extension.&lt;br /&gt;
&lt;br /&gt;
=====IS DIRECTORY &amp;lt;path&amp;gt;, IS FILE &amp;lt;path&amp;gt;, IS PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Determines whether the specified path points to an existing directory, file, or any of the two. The result is returned as one of the strings &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
=====PARENT DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns the parent directory of the specified path, independently of whether the path points to a directory, or to a file.&lt;br /&gt;
=====CURRENT DIRECTORY=====&lt;br /&gt;
Returns the current working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories.&lt;br /&gt;
&lt;br /&gt;
=====CHANGE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Changes the script&#039;s working directory. Note that working directories are per-script, i.e. multiple scripts running in parallel may have different working directories. Also, this command will only affect the default directory of scripting commands, not the application-global working directory as seen by the OS.&lt;br /&gt;
&lt;br /&gt;
=====MAKE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Creates a new directory with the given path. The directory&#039;s parent must exist for the command to succeed.&lt;br /&gt;
=====LIST DIRECTORY [&amp;lt;path&amp;gt; or &amp;lt;wildcard expression&amp;gt;]=====&lt;br /&gt;
Returns a listing of the specified directory, or the current working directory if no path is specified. The listing is in long form. You may use wildcard expressions in order to restrict the output.&lt;br /&gt;
=====LIST FILE &amp;lt;wildcard expression&amp;gt;=====&lt;br /&gt;
Returns a list of file names matching &#039;&#039;wildcard expression&#039;&#039; in the current directory.&lt;br /&gt;
=====LIST FILES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of file names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all files are listed. When &#039;&#039;directory&#039;&#039; is missing, files in the current directory are listed.&lt;br /&gt;
=====LIST DIRECTORIES [&amp;lt;directory&amp;gt; [&amp;lt;wildcard expression&amp;gt;]]=====&lt;br /&gt;
Returns a list of directory names from the specified directory, matching &#039;&#039;wildcard expression&#039;&#039;. When &#039;&#039;wildcard expression&#039;&#039; is missing, all directories are listed. When &#039;&#039;directory&#039;&#039; is missing, directories in the current directory are listed.&lt;br /&gt;
&lt;br /&gt;
=====RENAME FILE &amp;lt;current path&amp;gt; &amp;lt;new path&amp;gt;, RENAME DIRECTORY &amp;lt;current path&amp;gt; &amp;lt;new name&amp;gt;=====&lt;br /&gt;
Renames a file resp. a directory. For files, a different path may be given in the second argument, resulting in that the file is moved to the location specified by the new path. For directories, the path up to the directory&#039;s name must stay the same.&lt;br /&gt;
=====REMOVE FILE &amp;lt;path&amp;gt;, REMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified file or directory. This command cannot be undone. The directory must be empty for the command to succeed.&lt;br /&gt;
=====FORCEREMOVE DIRECTORY &amp;lt;path&amp;gt;=====&lt;br /&gt;
Removes the specified directory and its contents. Symbolic links are treated as ordinary files, i.e. they are not followed. This command cannot be undone.&lt;br /&gt;
=====NORMALIZED PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
Returns &amp;lt;path&amp;gt;, with the following transformations applied:&lt;br /&gt;
*Removes relative elements (&amp;lt;tt&amp;gt;..&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;.&amp;lt;/tt&amp;gt;) as far as possible. For absolute paths, the result will not contain any relative elements; for relative paths, double-dots may appear at the beginning of the result if necessary.&lt;br /&gt;
If a relative path simplifies to the empty string, &amp;lt;tt&amp;gt;./&amp;lt;/tt&amp;gt; is returned. Thus, the result of NORMALIZED PATH is never empty, unless its input was empty.&lt;br /&gt;
*Replaces backward slashes with forward slashes to achieve uniformity across platforms.&lt;br /&gt;
*On case-insensitive file systems, replaces the spelling of names with the one stored in the file system.&lt;br /&gt;
*On Win32, replaces short (8.3) names with long ones.&lt;br /&gt;
&lt;br /&gt;
=====CANONICAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
If &amp;lt;path&amp;gt; points to an existing file or directory, CANONICAL PATH returns a valid absolute file path, suitable as an unambiguous representation for the object pointed to. Especially, two non-empty canonical path strings will compare equal if and only if they refer to the same file system object.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;path&amp;gt; does not point to an existing file system object, construction of a canonical path is not possible due to lack of information about the named object, and CANONICAL PATH will return an empty string.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTES:&#039;&#039;&#039; The need for an unambiguous, or canonical, representation arises due to ambiguities in the string representation of paths, and in file systems themselves.&lt;br /&gt;
*Paths may contain relative elements: &amp;lt;tt&amp;gt;/mydir/../myfile&amp;lt;/tt&amp;gt; points to the same object as &amp;lt;tt&amp;gt;/myfile&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*A path that involves symbolic links will point to the same object as a path containing one or more of those links in resolved form.&lt;br /&gt;
*File systems may be case-insensitive, or may even provide multiple distinct names for individual directory entries (Win32 short vs. long names).&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;Win32,&#039;&#039;&#039; CANONICAL PATH returns the short (8.3) representation of a path, using uppercase spelling, and backslashes as directory separators. Apart from efficiency considerations, this aesthetically unpleasing representation has been chosen to discourage its use for anything except comparing file system objects.&lt;br /&gt;
&lt;br /&gt;
On &#039;&#039;&#039;other systems,&#039;&#039;&#039; CANONICAL PATH will return the result of the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
In both cases, a CANONICAL PATH will end with a native directory separator if, and only if, the object pointed to is a directory.&lt;br /&gt;
&lt;br /&gt;
=====REAL PATH &amp;lt;path&amp;gt;=====&lt;br /&gt;
On this command provides a work-alike for the POSIX &amp;lt;tt&amp;gt;realpath()&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
If &amp;lt;path&amp;gt; is empty, or if &amp;lt;path&amp;gt; points to a non-existing object, the result will be empty. Otherwise, an absolute path will be returned, with symbolic links resolved, using forward slashes as directory separators, and with spelling normalized as described for NORMALIZED PATH. A forward slash will be appended if the path points to a directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; In principle, the path returned by REAL PATH should be just as unambiguous as the result of CANONICAL PATH. However, there are a few caveats:&lt;br /&gt;
* On case-insensitive file systems, two independently obtained results of REAL PATH might differ in case spelling even if referring to the same file system object. This should not be the case for CANONICAL PATH.&lt;br /&gt;
* Determining the result of CANONICAL PATH is a fast operation. In contrast, REAL PATH may be expensive to determine, as for each directory on the path a listing needs to be obtained, and a canonical path needs to be formed, and compared, for half of the listed directory entries on average.&lt;br /&gt;
* On Win32, quite some amount of complexity arises from backward compatibility layers, forbidden file names, multiple filesystem roots, etc. Internally calling &amp;lt;tt&amp;gt;GetShortPathName()&amp;lt;/tt&amp;gt;, CANONICAL PATH does not need to handle that complexity, and may be considered more reliable for identifying file system objects than REAL PATH.&lt;br /&gt;
&lt;br /&gt;
=====READ FILE &amp;lt;filename&amp;gt;=====&lt;br /&gt;
Returns the text content of the file indicated by &amp;lt;filename&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=====WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;,  OVERWRITE FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;, APPEND TO FILE &amp;lt;filename&amp;gt; &amp;lt;line&amp;gt;=====&lt;br /&gt;
These commands write the specified &amp;lt;line&amp;gt; of text to the file indicated by &amp;lt;filename&amp;gt;.   They behave like the &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command of a typical shell, in the sense that a line-ending will be automatically added to the &amp;lt;line&amp;gt; if it does not already end with one. To suppress the automatic line-ending, you can say WRITE FILE &amp;lt;filename&amp;gt; &amp;lt;content&amp;gt; WITHOUT LINE ENDING (or equivalently, for short, you can say WITHOUT LF or WITHOUT CRLF). Any previous content in &amp;lt;file&amp;gt; will be lost if you use WRITE or OVERWRITE (they are the same, just synonyms for each other) whereas APPEND preserves previous content and adds the new &amp;lt;line&amp;gt; to the end.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on executables====&lt;br /&gt;
=====START EXECUTABLE &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Behaves identically to CREATE PROCESS, except that it does not report a process id for the new process. For details, see CREATE PROCESS.&lt;br /&gt;
&lt;br /&gt;
=====CATEGORIZE EXECUTABLE &amp;lt;name or path&amp;gt;=====&lt;br /&gt;
BCI2000 keeps a list of executables/modules that have been built, and sorts them into categories. The CATEGORIZE EXECUTABLE command provides a way to retrieve that information. Given the name or path of an executable, it outputs one of the following categories:&lt;br /&gt;
* SignalSource,&lt;br /&gt;
* SignalProcessing,&lt;br /&gt;
* Application,&lt;br /&gt;
* Operator,&lt;br /&gt;
* Tool,&lt;br /&gt;
* Helper,&lt;br /&gt;
* Unknown.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Lines of input/output====&lt;br /&gt;
=====WRITE LINE &amp;lt;line&amp;gt;=====&lt;br /&gt;
Writes a line of output. Destination depends on the context in which a script is executed. If the context is an Operator Handler, output is written as a log entry. If the context is a telnet session, output is written to the telnet connection. If the context is a [[User Reference:BCI2000Shell|BCI2000Shell]], output is written to the shell&#039;s stdout.&lt;br /&gt;
&lt;br /&gt;
=====READ LINE=====&lt;br /&gt;
Reads a line of input from the current execution context&#039;s input. If the command is executed within an Operator Handler, it will fail. If executed within a telnet session, the other side of the connection is prompted for input. If executed from within a [[User Reference:BCI2000Shell|BCI2000Shell]], input is read from the shell&#039;s stdin.&lt;br /&gt;
&lt;br /&gt;
====Commands operating on Processes in the Operating System====&lt;br /&gt;
=====CREATE PROCESS &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Starts the specified executable with options. This command returns after the started program has finished initialization, i.e. it will detect load time failures such as missing DLLs on Windows. If the process is still running when CREATE PROCESS returns, its result will be an operating system process id (pid). If the process has terminated, CREATE PROCESS will report its exit code marked with an &amp;lt;tt&amp;gt;ExitCode&amp;lt;/tt&amp;gt; tag to allow distinction between a pid and an exit code.&lt;br /&gt;
Please note that CREATE PROCESS requires quoting of arguments differently from other scripting commands. For details, see the SYSTEM command.&lt;br /&gt;
&lt;br /&gt;
=====TERMINATE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Tries to terminate the process with the given operating system pid, waiting for the process to terminate before returning. Will return &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that a suitable process existed but could not be terminated.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR PROCESS &amp;lt;pid&amp;gt; [&amp;lt;timeout seconds&amp;gt; = infinite]=====&lt;br /&gt;
Waits for the process with the given operating system pid to terminate, or the timeout to expire. Returns &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; to indicate that the process is still executing.&lt;br /&gt;
&lt;br /&gt;
=====SHOW PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows visible which are associated with the process referred to by pid.&lt;br /&gt;
In addition, brings one of the process&#039; top level (desktop level) windows to the front for user interaction.&lt;br /&gt;
&lt;br /&gt;
=====HIDE PROCESS &amp;lt;pid&amp;gt;=====&lt;br /&gt;
Makes all windows invisible which are associated with the process referred to by pid.&lt;br /&gt;
&lt;br /&gt;
====Global commands====&lt;br /&gt;
=====HELP [&amp;lt;type&amp;gt;]=====&lt;br /&gt;
When called with a type argument, lists commands that exist for the specified type (e.g., SYSTEM, or FILE). When called without argument, lists all commands in their main form. HELP ALL will list all commands, including synonyms.&lt;br /&gt;
&lt;br /&gt;
=====SET &amp;lt;name&amp;gt; &amp;lt;value&amp;gt;, GET &amp;lt;name&amp;gt;, &amp;lt;name&amp;gt;=====&lt;br /&gt;
Allows to set or retrieve the value of local and environment variables. The name is matched against local and environment variables. When no variable with the given name is found, SET will create a local variable, while GET will result in an error. GET may be further abbreviated to only consist of a name.&lt;br /&gt;
&lt;br /&gt;
GET further allows evaluation of [[User_Reference:Expression_Syntax|mathematical expressions]]. When the expression is invalid, or contains an unknown variable, an error is triggered.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM STATE=====&lt;br /&gt;
Prints the current system state. This will be one of Unavailable, Idle, Startup, Initialization, Resting, Suspended, ParamsModified, Running, Termination, Busy (for details, see the WAIT FOR command below).&lt;br /&gt;
&lt;br /&gt;
=====GET CURRENT RUN FILE=====&lt;br /&gt;
Prints the full path to the current run file, or an empty string, if called outside Running state.&lt;br /&gt;
&lt;br /&gt;
=====WAIT FOR &amp;lt;system state&amp;gt; [&amp;lt;timeout seconds&amp;gt;]=====&lt;br /&gt;
Waits until the system is in the specified state. This may be one of Idle, Startup, Connected, Resting, Suspended, ParamsModified, Running, Busy, or a combination of these, separated with a pipe character: &amp;quot;Resting|Suspended&amp;quot;. When no timeout is given, this command waits indefinitely. If the wait is successful, i.e. system state matches one of the specified states, WAIT FOR will return a value of &amp;quot;true&amp;quot;. If timeout occurred, WAIT FOR will return &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the BCI2000 system is shut down while a script is executing a WAIT FOR command, the script will be terminated with a &amp;quot;wait aborted&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
In more detail, user visible states are:&lt;br /&gt;
* Idle: System is shut down and does not do other processing than executing scripts.&lt;br /&gt;
* Startup: System has started up and is listening for incoming connections.&lt;br /&gt;
* Connected: All core modules have connected to the system.&lt;br /&gt;
* Resting: The system has been initialized but is not running.&lt;br /&gt;
* Suspended: The system has ended running and is behaving like in Resting.&lt;br /&gt;
* ParamsModified: In Suspended mode, parameter changes have been published and will be applied at Resume.&lt;br /&gt;
* Running: The system is running, processing brain signals, and displaying stimuli.&lt;br /&gt;
* Busy: The system is performing a transition from one state to another.&lt;br /&gt;
&lt;br /&gt;
As a synonym for &amp;quot;Connected,&amp;quot; &amp;quot;Initialization&amp;quot; is valid as well since it is compatible with the nomenclature in StateMachine.h. Still, it should be avoided because it is easily confused with, but very distinct from, the actions performed in the Initialize() phase.&lt;br /&gt;
&lt;br /&gt;
=====SLEEP &amp;amp;lt;time in seconds&amp;amp;gt;=====&lt;br /&gt;
Waits (sleeps) for the given amount of time. Timing resolution is 50ms. Tends to sleep a little longer than specified, with the error growing with duration.&lt;br /&gt;
&lt;br /&gt;
=====GET SYSTEM VERSION=====&lt;br /&gt;
Prints BCI2000 version information.&lt;br /&gt;
=====SETCONFIG, SET CONFIG=====&lt;br /&gt;
Applies current parameters to the system. Corresponds to the &#039;&#039;SetConfig&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
&lt;br /&gt;
=====START=====&lt;br /&gt;
Starts or resumes system operation, corresponding to the &#039;&#039;Start/Resume&#039;&#039; button in the GUI version of the Operator module.&lt;br /&gt;
=====STOP=====&lt;br /&gt;
Stops system operation. Corresponds to the &#039;&#039;Stop&#039;&#039; button in the GUI version of the Operator.&lt;br /&gt;
=====STARTUP SYSTEM=====&lt;br /&gt;
When in idle state, starts up the system to wait for incoming connections from core modules. Additionally, the following arguments may be given: 1) an IP address on which to listen (default is to listen on all addresses), and 2) a list of generic core module names with ports. The default configuration corresponds to these arguments:&lt;br /&gt;
 STARTUP SYSTEM * SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
A system log file may optionally be specified on this line, by inserting the &amp;lt;code&amp;gt;--SystemLogFile&amp;lt;/code&amp;gt; flag between the IP address and the module specifiers. For example:&lt;br /&gt;
&lt;br /&gt;
 STARTUP SYSTEM * --SystemLogFile=&amp;quot;SOME FILE.TXT&amp;quot; SignalSource:4000 SignalProcessing:4001 Application:4002&lt;br /&gt;
&lt;br /&gt;
The system log file will record all operator log window messages for the current launch, until the system shuts down.  It may be helpful to use the variables &amp;lt;code&amp;gt;$YYYYMMDD&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$HHMMSS&amp;lt;/code&amp;gt; to specify the filename.&lt;br /&gt;
&lt;br /&gt;
=====SHUTDOWN SYSTEM=====&lt;br /&gt;
Shuts down core modules, and enters idle system state.&lt;br /&gt;
=====RESET SYSTEM=====&lt;br /&gt;
Shuts down the system, and clears all parameter, state, and event information.&lt;br /&gt;
&lt;br /&gt;
=====QUIT, EXIT [&amp;lt;result&amp;gt;]=====&lt;br /&gt;
Quits the operator module after terminating all BCI2000 modules. The optional &#039;&#039;result&#039;&#039; argument determines the result of the executed script.&lt;br /&gt;
&lt;br /&gt;
=====CLOSE CONNECTION, TERMINATE CONNECTION=====&lt;br /&gt;
In the context of a telnet or websocket connection, this command will terminate the connection.&lt;br /&gt;
In other contexts, such as event handlers, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=====SYSTEM &amp;lt;command line&amp;gt;=====&lt;br /&gt;
Executes a shell command, redirecting any console output into the command&#039;s script result. E.g., to obtain a directory listing, under Windows, you would enter&lt;br /&gt;
 SYSTEM DIR&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Arguments to the SYSTEM command are executed by the operating system&#039;s shell, and thus may require quoting different from the other scripting commands. E.g., writing&lt;br /&gt;
 SET mydir ${PARENT DIRECTORY $BCI2000LAUNCHDIR}; ECHO ${LIST FILES $mydir}&lt;br /&gt;
will list files in the BCI2000 main directory, independently of whether the path to that directory contains space characters or not. However, to obtain a directory listing through the SYSTEM command, you would need to write&lt;br /&gt;
 ECHO ${SYSTEM DIR &amp;quot;$mydir&amp;quot;}&lt;br /&gt;
to make sure the content of the variable &#039;&#039;mydir&#039;&#039; is interpreted as a single argument, independently of whether it contains space characters.&lt;br /&gt;
&lt;br /&gt;
=====LOG &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log.&lt;br /&gt;
=====WARN &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as a warning.&lt;br /&gt;
=====ERROR &amp;lt;message&amp;gt;=====&lt;br /&gt;
Append the specified message to the system log, formatted as an error message.&lt;br /&gt;
&lt;br /&gt;
=====CAPTURE MESSAGES &amp;lt;message types&amp;gt;=====&lt;br /&gt;
Captures system log messages into a background buffer. When no message type is given, all messages are captured. When &amp;quot;None&amp;quot; is given as a message type, message capturing is disabled. Otherwise, the message type must be one of &amp;quot;Errors&amp;quot;, &amp;quot;Warnings&amp;quot;, &amp;quot;Debug&amp;quot;, &amp;quot;Log&amp;quot;. Multiple message types may be specified in a single command. When &amp;quot;None&amp;quot; appears within a single command, all preceding message types are ignored. Multiple CAPTURE MESSAGES commands are cumulative, except when &amp;quot;None&amp;quot; is specified as a message type.&lt;br /&gt;
&lt;br /&gt;
=====FLUSH MESSAGES=====&lt;br /&gt;
Clears the background message buffer, and returns its previous content. Use CAPTURE MESSAGES to capture messages into the background message buffer.&lt;br /&gt;
&lt;br /&gt;
====Operator-module defined Commands====&lt;br /&gt;
=====HIDE WINDOW [&amp;lt;name&amp;gt;], SHOW WINDOW [&amp;lt;name&amp;gt;]=====&lt;br /&gt;
Hides or shows the specified window. When called without a window name, the Operator module&#039;s main window is hidden or shown. The window name may be one of Main, Configuration, Log, Watches, and Visualizations. When &amp;quot;Watches&amp;quot; is given, the window state refers to visibility of the Watches area in the Visualizations window.&lt;br /&gt;
&lt;br /&gt;
=====MOVE WINDOW &amp;lt;name&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE WINDOW &amp;lt;name&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified window with one of the above names.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE WINDOW &amp;lt;name&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====SET TITLE &amp;lt;title&amp;gt;=====&lt;br /&gt;
Sets the title of the main Operator window.&lt;br /&gt;
=====SET BUTTON &amp;lt;idx&amp;gt; &amp;lt;label&amp;gt; &amp;lt;commands&amp;gt;=====&lt;br /&gt;
Configures the function button with 1-based index &#039;&#039;idx&#039;&#039; such that it is labelled &#039;&#039;label&#039;&#039; and executes &#039;&#039;commands&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=====VISUALIZE WATCH [decimate &amp;lt;n&amp;gt;] [range &amp;lt;min&amp;gt; &amp;lt;max&amp;gt;] &amp;lt;expression1&amp;gt; ...=====&lt;br /&gt;
Adds a watch for the given expressions to the operator module&#039;s Watches window, and makes the Watches window visible if it is hidden. If the &#039;&#039;decimate&#039;&#039; clause is present, the command will create a watch which will be evaluated only for every &#039;&#039;n&#039;&#039;th sample in the state vector. If the &#039;&#039;range&#039;&#039; clause is present, display minimum and maximum will not be adjusted automatically but will be fixed to the values given.&lt;br /&gt;
&lt;br /&gt;
By default, &#039;&#039;decimate&#039;&#039; has a value of &amp;quot;auto&amp;quot;; this means that there is no decimation of evaluation (i.e., all samples are evaluated) but changes that occur within 1ms will be shortened into their maximum and minimum, and thus reported as only two values.&lt;br /&gt;
This has proven to be efficient for avoiding sluggishness from flooding the application with events.&lt;br /&gt;
&lt;br /&gt;
=====MOVE VISUALIZATON &amp;lt;visID&amp;gt; &amp;lt;x&amp;gt; &amp;lt;y&amp;gt;, RESIZE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;width&amp;gt; &amp;lt;height&amp;gt;=====&lt;br /&gt;
Moves resp. resizes the specified visualization window.&lt;br /&gt;
Window decorations (title bar, frame) are taken into consideration such that the total size of the window matches the given width and height. If unknown, visualization IDs may be obtained from the Operator&#039;s &#039;&#039;Window-&amp;gt;Visualizations&#039;&#039; menu.&lt;br /&gt;
&lt;br /&gt;
=====ARRANGE VISUALIZATION &amp;lt;visID&amp;gt; &amp;lt;rows&amp;gt; &amp;lt;cols&amp;gt; &amp;lt;row&amp;gt; &amp;lt;col&amp;gt; [&amp;lt;rowspan&amp;gt; &amp;lt;colspan&amp;gt;]=====&lt;br /&gt;
Arranges the named visualization window in a virtual &#039;&#039;rows&#039;&#039; x &#039;&#039;cols&#039;&#039; grid at grid position &#039;&#039;row, col&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Optional &#039;&#039;rowspan&#039;&#039; and &#039;&#039;colspan&#039;&#039; arguments may be given to specify the extension of the window across more than one row or column. &lt;br /&gt;
Using a &#039;&#039;rowspan&#039;&#039; of 0 will result in the window assuming its minimum height.&lt;br /&gt;
Likewise, a &#039;&#039;colspan&#039;&#039; of 0 will result in the window&#039;s minimum width.&lt;br /&gt;
&lt;br /&gt;
If multiple screens are present, windows are arranged on the screen that contains the Operator window.&lt;br /&gt;
&lt;br /&gt;
=====RECORD VISUALIZATION &amp;lt;visID&amp;gt; [on|off]=====&lt;br /&gt;
Registers the named visualization for recording. The visualization name must be the short name as displayed in the &#039;&#039;View-&amp;gt;Visualizations&#039;&#039; menu. Switching a visualization recording to &amp;quot;on&amp;quot; is only possible in idle state (because an event for recording frame numbers must be registered in the system). When a visualization is registered for recording, its frames are stored immediately as they arrive at the operator module.&lt;br /&gt;
&lt;br /&gt;
Example: Recording the application window&lt;br /&gt;
 RECORD VISUALIZATION ApplicationWindow on&lt;br /&gt;
 ...&lt;br /&gt;
 # after parameters have been loaded&lt;br /&gt;
 Set parameter VisualizeApplicationWindow 1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
=====PUT NOTE &amp;lt;note&amp;gt;=====&lt;br /&gt;
Adds the given text to the [[User_Reference:Operator_Notes#Taking_Notes_during_recording_in_Operator|notes window]].&lt;br /&gt;
If the system is in &#039;&#039;Running&#039;&#039; state, the text will also be added to the current notes file as described under&lt;br /&gt;
[[User_Reference:Operator_Notes#Note_storage_and_file_format|&amp;quot;notes file&amp;quot;]].&lt;br /&gt;
&lt;br /&gt;
=====START TELNET [&amp;lt;address&amp;gt;], STOP TELNET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a telnet server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3999.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
=====START WEBSOCKET [&amp;lt;address&amp;gt;], STOP WEBSOCKET [&amp;lt;address&amp;gt;]=====&lt;br /&gt;
Starts or stops a websocket server listening at the given address. The address is in &amp;lt;IP&amp;gt;:&amp;lt;port&amp;gt; format. The default address is 127.0.0.1:3998.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; You should not use this command on global internet addresses, as there is no authentication performed. Only use addresses in the local network, such as 10.x.x.x, 172.x.x.x, or 192.168.x.x.&lt;br /&gt;
&lt;br /&gt;
====Operator-module Commands for Soliciting Input from the User====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [INPUT] FILE[S] [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to select an existing file (or multiple files, if the keyword FILES is used). Print the resulting file path(s).&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE [OUTPUT] FILE [OF TYPE &amp;lt;.ext1&amp;gt; [&amp;lt;.ext2&amp;gt; ...]] [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a file into which data can be saved (with an overwrite confirmation dialog if it already exists). Print the resulting file path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CHOOSE DIRECTORY [STARTING AT &amp;lt;dir&amp;gt;] [WITH PROMPT &amp;lt;message&amp;gt;]=====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user to specify a directory. Print the resulting directory path.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
=====CUSTOM DIALOG [MESSAGE &amp;lt;msg&amp;gt;] [VAR &amp;lt;varname&amp;gt; &amp;lt;label&amp;gt; {[&amp;lt;options&amp;gt;]} ] [BUTTONS {&amp;lt;buttons&amp;gt;}] ... =====&lt;br /&gt;
Via the Qt graphical user interface, prompt the user with a modal dialog that can be flexibly customized.&lt;br /&gt;
(See the [[User_Reference:Custom_GUI_Commands|Custom GUI Commands]] page for details and examples.)&lt;br /&gt;
&lt;br /&gt;
===Predefined Variables===&lt;br /&gt;
The following variables exist when an Operator script is executed.&lt;br /&gt;
Some of these variables are marked with &#039;&#039;local&#039;&#039;. This means that they are not environment variables, i.e. they are invisible to child processes that are launched using the SYSTEM or START EXECUTABLE commands, and their values may be different between script invocations. In script code, they are accessed like ordinary variables.&lt;br /&gt;
====BCI2000LAUNCHDIR====&lt;br /&gt;
The full absolute path to the directory where the Operator module resides. This is also prepended to the PATH environment variable, such that executables from the current BCI2000 installation will have precedence over any other executable with the same name.&lt;br /&gt;
&lt;br /&gt;
On macOS, this is the path where the Operator module&#039;s application bundle resides. In the default configuration, this is the BCI2000 prog directory, both on macOS and on other platforms.&lt;br /&gt;
&lt;br /&gt;
====BCI2000BINARY====&lt;br /&gt;
The full absolute path to the Operator module.&lt;br /&gt;
====LogLevel (local)====&lt;br /&gt;
Determines the amount of log information written to the Operator log. This variable only affects log messages originating from the current script. May be 2 (display all log messages), 1 (display fewer log messages), or 0 (suppress all log messages). Set to 1 by default. Changes to this local variable are not propagated to any sub-scripts called. &#039;&#039;NOTE:&#039;&#039; Only log messages are controlled by this variable. Error messages originating from a script with &#039;LogLevel 0&#039; will still be displayed in the Operator log. When &#039;AbortOnError&#039; is set to 0, you may set &#039;LogLevel&#039; to -1 in order to display error messages. When &#039;AbortOnError&#039; is 1 (the default), error messages will always be displayed to indicate the reason for failure.&lt;br /&gt;
&lt;br /&gt;
====AbortOnError (local)====&lt;br /&gt;
Determines if a script is aborted when an error happens, or whether the error is silently ignored. Set to 1 by default (script is aborted on error). Changes to this local variable are not propagated to any sub-scripts called.&lt;br /&gt;
&lt;br /&gt;
====Result (local)====&lt;br /&gt;
The result of the last executed scripting command. When a script is executed by calling EXECUTE SCRIPT, the script&#039;s last executed command determines the result of the EXECUTE SCRIPT command itself.&lt;br /&gt;
&lt;br /&gt;
====0, 1, ... 9 (local)====&lt;br /&gt;
When a script file is being executed, these variables contain the arguments of the EXECUTE SCRIPT command.&lt;br /&gt;
&#039;&#039;$0&#039;&#039; resolves to the full absolute path to the current script file. Within scripts, all of the &#039;&#039;0-9&#039;&#039; variables are defined, and those that do not have a matching argument are empty.&lt;br /&gt;
&lt;br /&gt;
====YYYYMMDD (local)====&lt;br /&gt;
Local time at execution of the current script, in YYYYMMDD format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
====HHMMSS (local)====&lt;br /&gt;
Local time at execution of the current script, in HHMMSS format. In interactive sessions, reflects the time when the session was initiated.&lt;br /&gt;
&lt;br /&gt;
===Abbreviated commands and synonyms===&lt;br /&gt;
To minimize the need of consulting documentation, as well as for backward compatibility, a number of &#039;&#039;&#039;synonymous commands&#039;&#039;&#039; are provided. E.g., states may be added by INSERT STATE as well as ADD STATE, and the existence of a file may be queried by IS FILE as well as EXISTS FILE. For an overview over all allowed forms of commands, use the HELP ALL command.&lt;br /&gt;
&lt;br /&gt;
To simplify operation in interactive sessions, &#039;&#039;&#039;abbreviated commands&#039;&#039;&#039; exist. Currently, these are:&lt;br /&gt;
:&#039;&#039;&#039;cd&#039;&#039;&#039; for CHANGE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;pwd&#039;&#039;&#039; and &#039;&#039;&#039;cd&#039;&#039;&#039; without argument for CURRENT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;ls&#039;&#039;&#039; and &#039;&#039;&#039;dir&#039;&#039;&#039; for LIST DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;mkdir&#039;&#039;&#039; for MAKE DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;echo&#039;&#039;&#039; for WRITE LINE,&lt;br /&gt;
:&#039;&#039;&#039;realpath&#039;&#039;&#039; for REAL PATH,&lt;br /&gt;
:&#039;&#039;&#039;dirname&#039;&#039;&#039; for EXTRACT DIRECTORY,&lt;br /&gt;
:&#039;&#039;&#039;basename&#039;&#039;&#039; for EXTRACT FILE BASE.&lt;br /&gt;
&lt;br /&gt;
===Handlers===&lt;br /&gt;
In the Operator GUI, script execution is bound to a number of Operator Events (not to be confused with Event states, above) that occur during various [[Technical Reference:States of Operation|stages of BCI2000 system operation]]:&lt;br /&gt;
====OnConnect====&lt;br /&gt;
This handler runs at startup, as soon as all modules are connected to the operator module.&lt;br /&gt;
====OnSetConfig====&lt;br /&gt;
This handler runs each time a set of parameters is applied to the system. This happens when the user clicks the &#039;&#039;SetConfig&#039;&#039; button. Execution of the &#039;&#039;SETCONFIG&#039;&#039; command also runs this handler.&lt;br /&gt;
&lt;br /&gt;
====OnStart, OnResume====&lt;br /&gt;
These handlers are triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. One of these handlers is also triggered when the &#039;&#039;Running&#039;&#039; state variable is set to 1 from a script. Whether &#039;&#039;OnStart&#039;&#039; or &#039;&#039;OnResume&#039;&#039; is triggered depends on whether the system has been running before with the current set of parameters.&lt;br /&gt;
&lt;br /&gt;
====OnStartRun====&lt;br /&gt;
Similarly to OnStart and OnResume, this handler is triggered by the &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; button. Unlike other event handlers, OnStartRun has an argument, which is the current run file.&lt;br /&gt;
&lt;br /&gt;
OnStart or OnResume are triggered immediately after &#039;&#039;Start&#039;&#039;/&#039;&#039;Resume&#039;&#039; has been pressed, whereas OnStartRun is deferred until modules have confirmed to be in Running state. This makes sure that the OnStartRun event handler receives a valid run file name.&lt;br /&gt;
&lt;br /&gt;
====OnNextFilePart====&lt;br /&gt;
This handler is triggered during a run, whenever the &#039;&#039;FilePart&#039;&#039; event state is incremented. It allows scripts to know when a new&lt;br /&gt;
partial file has begun. For further information, see the [[User_Reference:BCI2000FileWriter#FileSplittingCondition|FileSplittingCondition]] parameter.&lt;br /&gt;
&lt;br /&gt;
====OnSuspend/OnStopRun====&lt;br /&gt;
Triggered when the system goes from running into suspended mode. This happens whenever the &#039;&#039;Running&#039;&#039; state variable changes from 1 to 0. This may happen when the user clicks &#039;&#039;Suspend&#039;&#039;, when the application module switches the system into suspended mode, or when a script sets the &#039;&#039;Running&#039;&#039; state variable to 0.&lt;br /&gt;
&lt;br /&gt;
====OnShutdown====&lt;br /&gt;
Triggered when the operator module shuts down connections, and switches into idle state.&lt;br /&gt;
&lt;br /&gt;
====OnExit====&lt;br /&gt;
Triggered when the operator module exits. Execution of the QUIT command also triggers this handler. This handler is not available to the SET SCRIPT and CLEAR SCRIPT commands. Also, when both an OnShutdown and an OnExit script are defined, the OnExit script may be executed before the OnShutdown script.&lt;br /&gt;
&lt;br /&gt;
====Associating Scripts with Operator Events====&lt;br /&gt;
In the operator module&#039;s preferences dialog, script commands may be entered for each of the handlers listed above.&lt;br /&gt;
Scripts may be specified as paths to script files, or as immediate one-line scripts.&lt;br /&gt;
Entries that start with a minus sign (-) are treated as one-line scripts, which may contain multiple commands separated with semicolons.&lt;br /&gt;
&lt;br /&gt;
Scripts may also be specified from the command line used to start up the operator module. There, handler names are followed with the content of the respective preference entry, enclosed in double quotes (&amp;quot;...&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Finally, scripts may be specified using the SET SCRIPT command of the scripting language itself.&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
====Making use of the Operator module&#039;s Function Buttons====&lt;br /&gt;
To add a state variable called &amp;quot;Artifact&amp;quot;, and to set it using the operator&#039;s function buttons, do this:&lt;br /&gt;
*Enter the following line under &amp;quot;After All Modules Connected&amp;quot; in the operator&#039;s preferences dialog (note the minus sign):&lt;br /&gt;
 -ADD STATE Artifact 1 0&lt;br /&gt;
*Under &amp;quot;Function Buttons&amp;quot;, enter &amp;quot;Set Artifact&amp;quot; as the name of button 1, and as its command, enter (note there is no minus sign):&lt;br /&gt;
 SET STATE Artifact 1&lt;br /&gt;
*Enter &amp;quot;Clear Artifact&amp;quot; as the name of button 2, and as its command, enter&lt;br /&gt;
 SET STATE Artifact 0&lt;br /&gt;
&lt;br /&gt;
====A fully automated BCI2000 session====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Echo Please enter a subject ID:&lt;br /&gt;
Set SubjectID ${Read line}&lt;br /&gt;
&lt;br /&gt;
Startup system&lt;br /&gt;
Start executable SignalGenerator&lt;br /&gt;
Start executable SpectralSignalProcessing&lt;br /&gt;
Start executable CursorTask&lt;br /&gt;
Wait for Connected&lt;br /&gt;
Load parameterfile &amp;quot;../parms/examples/CursorTask_SignalGenerator.prm&amp;quot;&lt;br /&gt;
For i in 1 2 3&lt;br /&gt;
  Load parameterfile &amp;quot;../parms/MyExperiment/Session$i.prm&amp;quot;&lt;br /&gt;
  Set parameter SubjectName $SubjectID&lt;br /&gt;
  Set parameter SubjectSession $i&lt;br /&gt;
  Set config&lt;br /&gt;
  Wait for Resting&lt;br /&gt;
  Start&lt;br /&gt;
  Wait for Suspended 1000&lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Automating BCI2000 by Operator command line arguments====&lt;br /&gt;
The following example shows how to specify script commands from the command line.&lt;br /&gt;
It fully automates BCI2000 operation by loading a parameter file, applying parameters, starting the system once the parameters are applied, and quitting the system once the run is over. For better readability, the example is broken across lines, using the ^ DOS line continuation character.&lt;br /&gt;
&lt;br /&gt;
 operator.exe --OnConnect &amp;quot;-LOAD PARAMETERFILE ../parms/examples/CursorTask_SignalGenerator.prm; SETCONFIG&amp;quot; ^&lt;br /&gt;
              --OnSetConfig &amp;quot;-SET STATE Running 1&amp;quot;  ^&lt;br /&gt;
              --OnSuspend &amp;quot;-QUIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Automatically arranging windows in a 4x2 grid====&lt;br /&gt;
The following example arranges Source and Roundtrip visualizations on the left side of the screen.&lt;br /&gt;
On the right side, a large area is dedicated to the Operator&#039;s log window, and the Operator&#039;s main window sits at the bottom right.&lt;br /&gt;
&lt;br /&gt;
 Arrange Visualization SRCD 4 2 1 1 2 1&lt;br /&gt;
 Arrange Visualization RNDT 4 2 3 1&lt;br /&gt;
 Arrange Window Main 4 2 4 2&lt;br /&gt;
 Arrange Window Log  4 2 1 2 3 1&lt;br /&gt;
&lt;br /&gt;
[[File:Operator_Arrangement.PNG|center|640px|border]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Module Command Line Options]], [[User Reference:Operator Module]], [[User Reference:BCI2000Shell]], [[Technical Reference:States of Operation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:User Interface]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12667</id>
		<title>User Reference:JSON Parameter Format</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12667"/>
		<updated>2026-10-12T16:34:11Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Synopsis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
The BCI2000 JSON parameter format defines how [[Technical Reference:Parameter Definition|BCI2000 parameters]] are represented when using JSON related parameter functions in the [[Programming Reference:BCI2000Remote Class|BCI2000Remote Class]], the [[Technical Reference:Operator Library|Operator Library]], or [[User Reference:Operator Module Scripting|Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
Due to the fact that a Python &#039;&#039;dict&#039;&#039; object may easily be represented in JSON format, the JSON parameter format is most useful when used with Python.&lt;br /&gt;
&lt;br /&gt;
This allows creating a &#039;&#039;dict&#039;&#039; object with the desired parameter properties, and then converting it to JSON representation using the &amp;lt;tt&amp;gt;json.dumps()&amp;lt;/tt&amp;gt; function. Similarly, a JSON string may be converted to a Python &#039;&#039;dict&#039;&#039; object using the &amp;lt;tt&amp;gt;json.loads()&amp;lt;/tt&amp;gt; function (see example below).&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
The following properties are used when reading a JSON string into a parameter object. Any other properties are ignored. The only mandatory properties are &amp;quot;Name&amp;quot; and &amp;quot;Values&amp;quot;. If the parameter is supposed to appear in the Operator module&#039;s parameter editor dialog, the &amp;quot;Section&amp;quot; property must be provided as well.&lt;br /&gt;
&lt;br /&gt;
===Name===&lt;br /&gt;
The parameter name, with an optional path, separated by slashes (&amp;quot;/&amp;quot;). The path does not refer to the filesystem but to the internal hierarchy of filters in the BCI2000 system. Typically, you will only provide a name here, or use a path obtained from one of the &amp;lt;tt&amp;gt;GetParameterJson()&amp;lt;/tt&amp;gt; call.&lt;br /&gt;
&lt;br /&gt;
===Type===&lt;br /&gt;
The parameter&#039;s type, which may indicate data type, such as &#039;&#039;string&#039;&#039;, &#039;&#039;float&#039;&#039;, &#039;&#039;int&#039;&#039;, and shape, such as &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039;. Data type is not enforced, and may be omitted for &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039; parameters.&lt;br /&gt;
&lt;br /&gt;
===Sections===&lt;br /&gt;
An array of strings which describe a hierarchy of sections, with the first one indicating the tab in the Operator module&#039;s parameter editor dialog, and the second one indicating the group box inside the tab. Any number of sections may be given but only the first two will be used in the current implementation of BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Values===&lt;br /&gt;
An array of parameter values. For matrix valued parameters, this array is counted first by row index, and then by column index, i.e. neighboring row indices correspond to neighboring indices in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; are given, the size of the &#039;&#039;Values&#039;&#039; array must be consistent with the sizes of the &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; arrays, i.e. the number of &#039;&#039;Values&#039;&#039; must equal the product of the numbers of &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If neither &#039;&#039;RowLabels&#039;&#039; nor &#039;&#039;ColumnLabels&#039;&#039; are given, &#039;&#039;ColumnLabels&#039;&#039; will be set to a single &amp;quot;1&amp;quot; entry, and &#039;&#039;RowLabels&#039;&#039; will be set to a list from &amp;quot;1&amp;quot; to the number of entries in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
Otherwise, reading the parameter from the JSON string will fail.&lt;br /&gt;
&lt;br /&gt;
===RowLabels, ColumnLabels===&lt;br /&gt;
Arrays of row resp. column labels. For single-valued and list parameters, you may omit &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; as described under &#039;&#039;Values&#039;&#039;.&lt;br /&gt;
For matrix parameters, the shape of the matrix is derived from the number of entries in row and column labels.&lt;br /&gt;
&lt;br /&gt;
If no textual labels are available for rows and columns, specify a string-valued list from &amp;quot;1&amp;quot; to the number of entries in each property (a so-called trivial label).&lt;br /&gt;
&lt;br /&gt;
===Comment===&lt;br /&gt;
An arbitrary text describing the parameter to the user. This is displayed in the Operator module&#039;s parameter editor, next to the parameter value.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;Comment&#039;&#039; property may also contain additional information about a parameter; see [[Technical Reference:Parameter Definition]] for details.&lt;br /&gt;
&lt;br /&gt;
===DefaultValue===&lt;br /&gt;
An example value that may be provided to show how a parameter may be used. This is typically omitted.&lt;br /&gt;
&lt;br /&gt;
===LowRange, HighRange===&lt;br /&gt;
Values that represent a numerical parameter&#039;s minimum and maximum values. In the context of JSON parameters, these are typically unused and thus omitted.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The following is an example in Python, using the [[Programming Reference:BCI2000Remote Class|BCI2000Remote Class]].&lt;br /&gt;
&lt;br /&gt;
 import json&lt;br /&gt;
 &lt;br /&gt;
 bci = BCI2000Remote()&lt;br /&gt;
 print(&amp;quot;Operator path: &amp;quot; + bci.OperatorPath)&lt;br /&gt;
 bci.WindowVisible = True&lt;br /&gt;
 bci.WindowTitle = &amp;quot;Python controlled&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 bci.SubjectID = &amp;quot;pysub&amp;quot;&lt;br /&gt;
 bci.Connect()&lt;br /&gt;
 &lt;br /&gt;
 myparam = dict()&lt;br /&gt;
 myparam[&amp;quot;Name&amp;quot;] = &#039;foo&#039;&lt;br /&gt;
 myparam[&amp;quot;Sections&amp;quot;] = [&#039;blubb&#039;, &#039;blobb&#039;]&lt;br /&gt;
 myparam[&amp;quot;Type&amp;quot;] = &#039;string&#039;&lt;br /&gt;
 myparam[&amp;quot;Values&amp;quot;] = [&#039;bar&#039;]&lt;br /&gt;
 myparam[&amp;quot;Comment&amp;quot;] = &#039;This is a test parameter created from Python.&#039;&lt;br /&gt;
 bci.AddParameterJson(json.dumps(myparam))&lt;br /&gt;
 &lt;br /&gt;
 myparam2 = json.loads(bci.GetParameterJson(&#039;foo&#039;))&lt;br /&gt;
 print(myparam2)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[Technical Reference:Parameter Definition]],&lt;br /&gt;
[[Programming Reference:BCI2000Remote Class]],&lt;br /&gt;
[[Technical Reference:Operator Library]],&lt;br /&gt;
[[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Specification]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12666</id>
		<title>User Reference:JSON Parameter Format</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12666"/>
		<updated>2026-10-12T16:33:32Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
The BCI2000 JSON parameter format defines how [[Technical Reference:Parameter Definition|BCI2000 parameters]] are represented when using JSON related parameter functions in the [[Programming Reference:BCI2000Remote Class]], the [[Technical Reference:Operator Library]], or [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
Due to the fact that a Python &#039;&#039;dict&#039;&#039; object may easily be represented in JSON format, the JSON parameter format is most useful when used with Python.&lt;br /&gt;
&lt;br /&gt;
This allows creating a &#039;&#039;dict&#039;&#039; object with the desired parameter properties, and then converting it to JSON representation using the &amp;lt;tt&amp;gt;json.dumps()&amp;lt;/tt&amp;gt; function. Similarly, a JSON string may be converted to a Python &#039;&#039;dict&#039;&#039; object using the &amp;lt;tt&amp;gt;json.loads()&amp;lt;/tt&amp;gt; function (see example below).&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
The following properties are used when reading a JSON string into a parameter object. Any other properties are ignored. The only mandatory properties are &amp;quot;Name&amp;quot; and &amp;quot;Values&amp;quot;. If the parameter is supposed to appear in the Operator module&#039;s parameter editor dialog, the &amp;quot;Section&amp;quot; property must be provided as well.&lt;br /&gt;
&lt;br /&gt;
===Name===&lt;br /&gt;
The parameter name, with an optional path, separated by slashes (&amp;quot;/&amp;quot;). The path does not refer to the filesystem but to the internal hierarchy of filters in the BCI2000 system. Typically, you will only provide a name here, or use a path obtained from one of the &amp;lt;tt&amp;gt;GetParameterJson()&amp;lt;/tt&amp;gt; call.&lt;br /&gt;
&lt;br /&gt;
===Type===&lt;br /&gt;
The parameter&#039;s type, which may indicate data type, such as &#039;&#039;string&#039;&#039;, &#039;&#039;float&#039;&#039;, &#039;&#039;int&#039;&#039;, and shape, such as &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039;. Data type is not enforced, and may be omitted for &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039; parameters.&lt;br /&gt;
&lt;br /&gt;
===Sections===&lt;br /&gt;
An array of strings which describe a hierarchy of sections, with the first one indicating the tab in the Operator module&#039;s parameter editor dialog, and the second one indicating the group box inside the tab. Any number of sections may be given but only the first two will be used in the current implementation of BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Values===&lt;br /&gt;
An array of parameter values. For matrix valued parameters, this array is counted first by row index, and then by column index, i.e. neighboring row indices correspond to neighboring indices in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; are given, the size of the &#039;&#039;Values&#039;&#039; array must be consistent with the sizes of the &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; arrays, i.e. the number of &#039;&#039;Values&#039;&#039; must equal the product of the numbers of &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If neither &#039;&#039;RowLabels&#039;&#039; nor &#039;&#039;ColumnLabels&#039;&#039; are given, &#039;&#039;ColumnLabels&#039;&#039; will be set to a single &amp;quot;1&amp;quot; entry, and &#039;&#039;RowLabels&#039;&#039; will be set to a list from &amp;quot;1&amp;quot; to the number of entries in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
Otherwise, reading the parameter from the JSON string will fail.&lt;br /&gt;
&lt;br /&gt;
===RowLabels, ColumnLabels===&lt;br /&gt;
Arrays of row resp. column labels. For single-valued and list parameters, you may omit &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; as described under &#039;&#039;Values&#039;&#039;.&lt;br /&gt;
For matrix parameters, the shape of the matrix is derived from the number of entries in row and column labels.&lt;br /&gt;
&lt;br /&gt;
If no textual labels are available for rows and columns, specify a string-valued list from &amp;quot;1&amp;quot; to the number of entries in each property (a so-called trivial label).&lt;br /&gt;
&lt;br /&gt;
===Comment===&lt;br /&gt;
An arbitrary text describing the parameter to the user. This is displayed in the Operator module&#039;s parameter editor, next to the parameter value.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;Comment&#039;&#039; property may also contain additional information about a parameter; see [[Technical Reference:Parameter Definition]] for details.&lt;br /&gt;
&lt;br /&gt;
===DefaultValue===&lt;br /&gt;
An example value that may be provided to show how a parameter may be used. This is typically omitted.&lt;br /&gt;
&lt;br /&gt;
===LowRange, HighRange===&lt;br /&gt;
Values that represent a numerical parameter&#039;s minimum and maximum values. In the context of JSON parameters, these are typically unused and thus omitted.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The following is an example in Python, using the [[Programming Reference:BCI2000Remote Class|BCI2000Remote Class]].&lt;br /&gt;
&lt;br /&gt;
 import json&lt;br /&gt;
 &lt;br /&gt;
 bci = BCI2000Remote()&lt;br /&gt;
 print(&amp;quot;Operator path: &amp;quot; + bci.OperatorPath)&lt;br /&gt;
 bci.WindowVisible = True&lt;br /&gt;
 bci.WindowTitle = &amp;quot;Python controlled&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 bci.SubjectID = &amp;quot;pysub&amp;quot;&lt;br /&gt;
 bci.Connect()&lt;br /&gt;
 &lt;br /&gt;
 myparam = dict()&lt;br /&gt;
 myparam[&amp;quot;Name&amp;quot;] = &#039;foo&#039;&lt;br /&gt;
 myparam[&amp;quot;Sections&amp;quot;] = [&#039;blubb&#039;, &#039;blobb&#039;]&lt;br /&gt;
 myparam[&amp;quot;Type&amp;quot;] = &#039;string&#039;&lt;br /&gt;
 myparam[&amp;quot;Values&amp;quot;] = [&#039;bar&#039;]&lt;br /&gt;
 myparam[&amp;quot;Comment&amp;quot;] = &#039;This is a test parameter created from Python.&#039;&lt;br /&gt;
 bci.AddParameterJson(json.dumps(myparam))&lt;br /&gt;
 &lt;br /&gt;
 myparam2 = json.loads(bci.GetParameterJson(&#039;foo&#039;))&lt;br /&gt;
 print(myparam2)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[Technical Reference:Parameter Definition]],&lt;br /&gt;
[[Programming Reference:BCI2000Remote Class]],&lt;br /&gt;
[[Technical Reference:Operator Library]],&lt;br /&gt;
[[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Specification]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12665</id>
		<title>User Reference:JSON Parameter Format</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12665"/>
		<updated>2026-10-12T16:32:33Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* See also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
The BCI2000 JSON parameter format defines how [[Technical Reference:Parameter Definition|BCI2000 parameters]] are represented when using JSON related parameter functions in the [[Programming Reference:BCI2000Remote Class]], the [[Technical Reference:Operator Library]], or [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
Due to the fact that a Python &#039;&#039;dict&#039;&#039; object may easily be represented in JSON format, the JSON parameter format is most useful when used with Python.&lt;br /&gt;
&lt;br /&gt;
This allows creating a &#039;&#039;dict&#039;&#039; object with the desired parameter properties, and then converting it to JSON representation using the &amp;lt;tt&amp;gt;json.dumps()&amp;lt;/tt&amp;gt; function. Similarly, a JSON string may be converted to a Python &#039;&#039;dict&#039;&#039; object using the &amp;lt;tt&amp;gt;json.loads()&amp;lt;/tt&amp;gt; function (see example below).&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
The following properties are used when reading a JSON string into a parameter object. Any other properties are ignored. The only mandatory properties are &amp;quot;Name&amp;quot; and &amp;quot;Values&amp;quot;. If the parameter is supposed to appear in the Operator module&#039;s parameter editor dialog, the &amp;quot;Section&amp;quot; property must be provided as well.&lt;br /&gt;
&lt;br /&gt;
===Name===&lt;br /&gt;
The parameter name, with an optional path, separated by slashes (&amp;quot;/&amp;quot;). The path does not refer to the filesystem but to the internal hierarchy of filters in the BCI2000 system. Typically, you will only provide a name here, or use a path obtained from one of the &amp;lt;tt&amp;gt;GetParameterJson()&amp;lt;/tt&amp;gt; call.&lt;br /&gt;
&lt;br /&gt;
===Type===&lt;br /&gt;
The parameter&#039;s type, which may indicate data type, such as &#039;&#039;string&#039;&#039;, &#039;&#039;float&#039;&#039;, &#039;&#039;int&#039;&#039;, and shape, such as &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039;. Data type is not enforced, and may be omitted for &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039; parameters.&lt;br /&gt;
&lt;br /&gt;
===Sections===&lt;br /&gt;
An array of strings which describe a hierarchy of sections, with the first one indicating the tab in the Operator module&#039;s parameter editor dialog, and the second one indicating the group box inside the tab. Any number of sections may be given but only the first two will be used in the current implementation of BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Values===&lt;br /&gt;
An array of parameter values. For matrix valued parameters, this array is counted first by row index, and then by column index, i.e. neighboring row indices correspond to neighboring indices in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; are given, the size of the &#039;&#039;Values&#039;&#039; array must be consistent with the sizes of the &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; arrays, i.e. the number of &#039;&#039;Values&#039;&#039; must equal the product of the numbers of &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If neither &#039;&#039;RowLabels&#039;&#039; nor &#039;&#039;ColumnLabels&#039;&#039; are given, &#039;&#039;ColumnLabels&#039;&#039; will be set to a single &amp;quot;1&amp;quot; entry, and &#039;&#039;RowLabels&#039;&#039; will be set to a list from &amp;quot;1&amp;quot; to the number of entries in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
Otherwise, reading the parameter from the JSON string will fail.&lt;br /&gt;
&lt;br /&gt;
===RowLabels, ColumnLabels===&lt;br /&gt;
Arrays of row resp. column labels. For single-valued and list parameters, you may omit &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; as described under &#039;&#039;Values&#039;&#039;.&lt;br /&gt;
For matrix parameters, the shape of the matrix is derived from the number of entries in row and column labels.&lt;br /&gt;
&lt;br /&gt;
If no textual labels are available for rows and columns, specify a string-valued list from &amp;quot;1&amp;quot; to the number of entries in each property (a so-called trivial label).&lt;br /&gt;
&lt;br /&gt;
===Comment===&lt;br /&gt;
An arbitrary text describing the parameter to the user. This is displayed in the Operator module&#039;s parameter editor, next to the parameter value.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;Comment&#039;&#039; property may also contain additional information about a parameter; see [[Technical Reference:Parameter Definition]] for details.&lt;br /&gt;
&lt;br /&gt;
===DefaultValue===&lt;br /&gt;
An example value that may be provided to show how a parameter may be used. This is typically omitted.&lt;br /&gt;
&lt;br /&gt;
===LowRange, HighRange===&lt;br /&gt;
Values that represent a numerical parameter&#039;s minimum and maximum values. In the context of JSON parameters, these are typically unused and thus omitted.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The following is an example in Python, using the [[Programming Reference:BCI2000Remote Class]].&lt;br /&gt;
&lt;br /&gt;
 import json&lt;br /&gt;
 &lt;br /&gt;
 bci = BCI2000Remote()&lt;br /&gt;
 print(&amp;quot;Operator path: &amp;quot; + bci.OperatorPath)&lt;br /&gt;
 bci.WindowVisible = True&lt;br /&gt;
 bci.WindowTitle = &amp;quot;Python controlled&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 bci.SubjectID = &amp;quot;pysub&amp;quot;&lt;br /&gt;
 bci.Connect()&lt;br /&gt;
 &lt;br /&gt;
 myparam = dict()&lt;br /&gt;
 myparam[&amp;quot;Name&amp;quot;] = &#039;foo&#039;&lt;br /&gt;
 myparam[&amp;quot;Sections&amp;quot;] = [&#039;blubb&#039;, &#039;blobb&#039;]&lt;br /&gt;
 myparam[&amp;quot;Type&amp;quot;] = &#039;string&#039;&lt;br /&gt;
 myparam[&amp;quot;Values&amp;quot;] = [&#039;bar&#039;]&lt;br /&gt;
 myparam[&amp;quot;Comment&amp;quot;] = &#039;This is a test parameter created from Python.&#039;&lt;br /&gt;
 bci.AddParameterJson(json.dumps(myparam))&lt;br /&gt;
 &lt;br /&gt;
 myparam2 = json.loads(bci.GetParameterJson(&#039;foo&#039;))&lt;br /&gt;
 print(myparam2)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[Technical Reference:Parameter Definition]],&lt;br /&gt;
[[Programming Reference:BCI2000Remote Class]],&lt;br /&gt;
[[Technical Reference:Operator Library]],&lt;br /&gt;
[[User Reference:Operator Module Scripting]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Specification]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12664</id>
		<title>User Reference:JSON Parameter Format</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12664"/>
		<updated>2026-10-12T16:30:59Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
The BCI2000 JSON parameter format defines how [[Technical Reference:Parameter Definition|BCI2000 parameters]] are represented when using JSON related parameter functions in the [[Programming Reference:BCI2000Remote Class]], the [[Technical Reference:Operator Library]], or [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
Due to the fact that a Python &#039;&#039;dict&#039;&#039; object may easily be represented in JSON format, the JSON parameter format is most useful when used with Python.&lt;br /&gt;
&lt;br /&gt;
This allows creating a &#039;&#039;dict&#039;&#039; object with the desired parameter properties, and then converting it to JSON representation using the &amp;lt;tt&amp;gt;json.dumps()&amp;lt;/tt&amp;gt; function. Similarly, a JSON string may be converted to a Python &#039;&#039;dict&#039;&#039; object using the &amp;lt;tt&amp;gt;json.loads()&amp;lt;/tt&amp;gt; function (see example below).&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
The following properties are used when reading a JSON string into a parameter object. Any other properties are ignored. The only mandatory properties are &amp;quot;Name&amp;quot; and &amp;quot;Values&amp;quot;. If the parameter is supposed to appear in the Operator module&#039;s parameter editor dialog, the &amp;quot;Section&amp;quot; property must be provided as well.&lt;br /&gt;
&lt;br /&gt;
===Name===&lt;br /&gt;
The parameter name, with an optional path, separated by slashes (&amp;quot;/&amp;quot;). The path does not refer to the filesystem but to the internal hierarchy of filters in the BCI2000 system. Typically, you will only provide a name here, or use a path obtained from one of the &amp;lt;tt&amp;gt;GetParameterJson()&amp;lt;/tt&amp;gt; call.&lt;br /&gt;
&lt;br /&gt;
===Type===&lt;br /&gt;
The parameter&#039;s type, which may indicate data type, such as &#039;&#039;string&#039;&#039;, &#039;&#039;float&#039;&#039;, &#039;&#039;int&#039;&#039;, and shape, such as &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039;. Data type is not enforced, and may be omitted for &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039; parameters.&lt;br /&gt;
&lt;br /&gt;
===Sections===&lt;br /&gt;
An array of strings which describe a hierarchy of sections, with the first one indicating the tab in the Operator module&#039;s parameter editor dialog, and the second one indicating the group box inside the tab. Any number of sections may be given but only the first two will be used in the current implementation of BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Values===&lt;br /&gt;
An array of parameter values. For matrix valued parameters, this array is counted first by row index, and then by column index, i.e. neighboring row indices correspond to neighboring indices in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; are given, the size of the &#039;&#039;Values&#039;&#039; array must be consistent with the sizes of the &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; arrays, i.e. the number of &#039;&#039;Values&#039;&#039; must equal the product of the numbers of &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If neither &#039;&#039;RowLabels&#039;&#039; nor &#039;&#039;ColumnLabels&#039;&#039; are given, &#039;&#039;ColumnLabels&#039;&#039; will be set to a single &amp;quot;1&amp;quot; entry, and &#039;&#039;RowLabels&#039;&#039; will be set to a list from &amp;quot;1&amp;quot; to the number of entries in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
Otherwise, reading the parameter from the JSON string will fail.&lt;br /&gt;
&lt;br /&gt;
===RowLabels, ColumnLabels===&lt;br /&gt;
Arrays of row resp. column labels. For single-valued and list parameters, you may omit &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; as described under &#039;&#039;Values&#039;&#039;.&lt;br /&gt;
For matrix parameters, the shape of the matrix is derived from the number of entries in row and column labels.&lt;br /&gt;
&lt;br /&gt;
If no textual labels are available for rows and columns, specify a string-valued list from &amp;quot;1&amp;quot; to the number of entries in each property (a so-called trivial label).&lt;br /&gt;
&lt;br /&gt;
===Comment===&lt;br /&gt;
An arbitrary text describing the parameter to the user. This is displayed in the Operator module&#039;s parameter editor, next to the parameter value.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;Comment&#039;&#039; property may also contain additional information about a parameter; see [[Technical Reference:Parameter Definition]] for details.&lt;br /&gt;
&lt;br /&gt;
===DefaultValue===&lt;br /&gt;
An example value that may be provided to show how a parameter may be used. This is typically omitted.&lt;br /&gt;
&lt;br /&gt;
===LowRange, HighRange===&lt;br /&gt;
Values that represent a numerical parameter&#039;s minimum and maximum values. In the context of JSON parameters, these are typically unused and thus omitted.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The following is an example in Python, using the [[Programming Reference:BCI2000Remote Class]].&lt;br /&gt;
&lt;br /&gt;
 import json&lt;br /&gt;
 &lt;br /&gt;
 bci = BCI2000Remote()&lt;br /&gt;
 print(&amp;quot;Operator path: &amp;quot; + bci.OperatorPath)&lt;br /&gt;
 bci.WindowVisible = True&lt;br /&gt;
 bci.WindowTitle = &amp;quot;Python controlled&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 bci.SubjectID = &amp;quot;pysub&amp;quot;&lt;br /&gt;
 bci.Connect()&lt;br /&gt;
 &lt;br /&gt;
 myparam = dict()&lt;br /&gt;
 myparam[&amp;quot;Name&amp;quot;] = &#039;foo&#039;&lt;br /&gt;
 myparam[&amp;quot;Sections&amp;quot;] = [&#039;blubb&#039;, &#039;blobb&#039;]&lt;br /&gt;
 myparam[&amp;quot;Type&amp;quot;] = &#039;string&#039;&lt;br /&gt;
 myparam[&amp;quot;Values&amp;quot;] = [&#039;bar&#039;]&lt;br /&gt;
 myparam[&amp;quot;Comment&amp;quot;] = &#039;This is a test parameter created from Python.&#039;&lt;br /&gt;
 bci.AddParameterJson(json.dumps(myparam))&lt;br /&gt;
 &lt;br /&gt;
 myparam2 = json.loads(bci.GetParameterJson(&#039;foo&#039;))&lt;br /&gt;
 print(myparam2)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[Technical Reference:Parameter Definition]],&lt;br /&gt;
[[Programming Reference:BCI2000Remote Class]],&lt;br /&gt;
[[Technical Reference:Operator Library]],&lt;br /&gt;
[[User Reference:Operator Module Scripting]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12663</id>
		<title>User Reference:JSON Parameter Format</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12663"/>
		<updated>2026-10-12T16:30:25Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
The BCI2000 JSON parameter format defines how [[Technical Reference:Parameter Definition|BCI2000 parameters]] are represented when using JSON related parameter functions in the [[Programming Reference:BCI2000Remote Class]], the [[Technical Reference:Operator Library]], or [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
Due to the fact that a Python &#039;&#039;dict&#039;&#039; object may easily be represented in JSON format, the JSON parameter format is most useful when used with Python.&lt;br /&gt;
&lt;br /&gt;
This allows creating a &#039;&#039;dict&#039;&#039; object with the desired parameter properties, and then converting it to JSON representation using the &amp;lt;tt&amp;gt;json.dumps()&amp;lt;/tt&amp;gt; function. Similarly, a JSON string may be converted to a Python &#039;&#039;dict&#039;&#039; object using the &amp;lt;tt&amp;gt;json.loads()&amp;lt;/tt&amp;gt; function (see example below).&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
The following properties are used when reading a JSON string into a parameter object. Any other properties are ignored. The only mandatory properties are &amp;quot;Name&amp;quot; and &amp;quot;Values&amp;quot;. If the parameter is supposed to appear in the Operator module&#039;s parameter editor dialog, the &amp;quot;Section&amp;quot; property must be provided as well.&lt;br /&gt;
&lt;br /&gt;
===Name===&lt;br /&gt;
The parameter name, with an optional path, separated by slashes (&amp;quot;/&amp;quot;). The path does not refer to the filesystem but to the internal hierarchy of filters in the BCI2000 system. Typically, you will only provide a name here, or use a path obtained from one of the &amp;lt;tt&amp;gt;GetParameterJson()&amp;lt;/tt&amp;gt; call.&lt;br /&gt;
&lt;br /&gt;
===Type===&lt;br /&gt;
The parameter&#039;s type, which may indicate data type, such as &#039;&#039;string&#039;&#039;, &#039;&#039;float&#039;&#039;, &#039;&#039;int&#039;&#039;, and shape, such as &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039;. Data type is not enforced, and may be omitted for &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039; parameters.&lt;br /&gt;
&lt;br /&gt;
===Sections===&lt;br /&gt;
An array of strings which describe a hierarchy of sections, with the first one indicating the tab in the Operator module&#039;s parameter editor dialog, and the second one indicating the group box inside the tab. Any number of sections may be given but only the first two will be used in the current implementation of BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Values===&lt;br /&gt;
An array of parameter values. For matrix valued parameters, this array is counted first by row index, and then by column index, i.e. neighboring row indices correspond to neighboring indices in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; are given, the size of the &#039;&#039;Values&#039;&#039; array must be consistent with the sizes of the &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; arrays, i.e. the number of &#039;&#039;Values&#039;&#039; must equal the product of the numbers of &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If neither &#039;&#039;RowLabels&#039;&#039; nor &#039;&#039;ColumnLabels&#039;&#039; are given, &#039;&#039;ColumnLabels&#039;&#039; will be set to a single &amp;quot;1&amp;quot; entry, and &#039;&#039;RowLabels&#039;&#039; will be set to a list from &amp;quot;1&amp;quot; to the number of entries in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
Otherwise, reading the parameter from the JSON string will fail.&lt;br /&gt;
&lt;br /&gt;
===RowLabels, ColumnLabels===&lt;br /&gt;
Arrays of row resp. column labels. For single-valued and list parameters, you may omit &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; as described under &#039;&#039;Values&#039;&#039;.&lt;br /&gt;
For matrix parameters, the shape of the matrix is derived from the number of entries in row and column labels.&lt;br /&gt;
&lt;br /&gt;
If no textual labels are available for rows and columns, specify a string-valued list from &amp;quot;1&amp;quot; to the number of entries in each property (a so-called trivial label).&lt;br /&gt;
&lt;br /&gt;
===Comment===&lt;br /&gt;
An arbitrary text describing the parameter to the user. This is displayed in the Operator module&#039;s parameter editor, next to the parameter value.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;Comment&#039;&#039; property may also contain additional information about a parameter; see [[Technical Reference:Parameter Definition]] for details.&lt;br /&gt;
&lt;br /&gt;
===DefaultValue===&lt;br /&gt;
An example value that may be provided to show how a parameter may be used. This is typically omitted.&lt;br /&gt;
&lt;br /&gt;
===LowRange, HighRange===&lt;br /&gt;
Values that represent a numerical parameter&#039;s minimum and maximum values. In the context of JSON parameters, these are typically unused and thus omitted.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The following is an example in Python, using the [[Programming Reference:BCI2000Remote Class]].&lt;br /&gt;
&lt;br /&gt;
 import json&lt;br /&gt;
&lt;br /&gt;
 bci = BCI2000Remote()&lt;br /&gt;
 print(&amp;quot;Operator path: &amp;quot; + bci.OperatorPath)&lt;br /&gt;
 bci.WindowVisible = True&lt;br /&gt;
 bci.WindowTitle = &amp;quot;Python controlled&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 bci.SubjectID = &amp;quot;pysub&amp;quot;&lt;br /&gt;
 bci.Connect()&lt;br /&gt;
&lt;br /&gt;
 myparam = dict()&lt;br /&gt;
 myparam[&amp;quot;Name&amp;quot;] = &#039;foo&#039;&lt;br /&gt;
 myparam[&amp;quot;Sections&amp;quot;] = [&#039;blubb&#039;, &#039;blobb&#039;]&lt;br /&gt;
 myparam[&amp;quot;Type&amp;quot;] = &#039;string&#039;&lt;br /&gt;
 myparam[&amp;quot;Values&amp;quot;] = [&#039;bar&#039;]&lt;br /&gt;
 myparam[&amp;quot;Comment&amp;quot;] = &#039;This is a test parameter created from Python.&#039;&lt;br /&gt;
 bci.AddParameterJson(json.dumps(myparam))&lt;br /&gt;
&lt;br /&gt;
 myparam2 = json.loads(bci.GetParameterJson(&#039;foo&#039;))&lt;br /&gt;
 print(myparam2)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[Technical Reference:Parameter Definition]],&lt;br /&gt;
[[Programming Reference:BCI2000Remote Class]],&lt;br /&gt;
[[Technical Reference:Operator Library]],&lt;br /&gt;
[[User Reference:Operator Module Scripting]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12662</id>
		<title>User Reference:JSON Parameter Format</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12662"/>
		<updated>2026-10-12T16:28:49Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
The BCI2000 JSON parameter format defines how [[Technical Reference:Parameter Definition|BCI2000 parameters]] are represented when using JSON related parameter functions in the [[Programming Reference:BCI2000Remote Class]], the [[Technical Reference:Operator Library]], or [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
Due to the fact that a Python &#039;&#039;dict&#039;&#039; object may easily be represented in JSON format, the JSON parameter format is most useful when used with Python.&lt;br /&gt;
&lt;br /&gt;
This allows creating a &#039;&#039;dict&#039;&#039; object with the desired parameter properties, and then converting it to JSON representation using the &amp;lt;tt&amp;gt;json.dumps()&amp;lt;/tt&amp;gt; function. Similarly, a JSON string may be converted to a Python &#039;&#039;dict&#039;&#039; object using the &amp;lt;tt&amp;gt;json.loads()&amp;lt;/tt&amp;gt; function (see example below).&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
The following properties are used when reading a JSON string into a parameter object. Any other properties are ignored. The only mandatory properties are &amp;quot;Name&amp;quot; and &amp;quot;Values&amp;quot;. If the parameter is supposed to appear in the Operator module&#039;s parameter editor dialog, the &amp;quot;Section&amp;quot; property must be provided as well.&lt;br /&gt;
&lt;br /&gt;
===Name===&lt;br /&gt;
The parameter name, with an optional path, separated by slashes (&amp;quot;/&amp;quot;). The path does not refer to the filesystem but to the internal hierarchy of filters in the BCI2000 system. Typically, you will only provide a name here, or use a path obtained from one of the &amp;lt;tt&amp;gt;GetParameterJson()&amp;lt;/tt&amp;gt; call.&lt;br /&gt;
&lt;br /&gt;
===Type===&lt;br /&gt;
The parameter&#039;s type, which may indicate data type, such as &#039;&#039;string&#039;&#039;, &#039;&#039;float&#039;&#039;, &#039;&#039;int&#039;&#039;, and shape, such as &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039;. Data type is not enforced, and may be omitted for &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039; parameters.&lt;br /&gt;
&lt;br /&gt;
===Sections===&lt;br /&gt;
An array of strings which describe a hierarchy of sections, with the first one indicating the tab in the Operator module&#039;s parameter editor dialog, and the second one indicating the group box inside the tab. Any number of sections may be given but only the first two will be used in the current implementation of BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Values===&lt;br /&gt;
An array of parameter values. For matrix valued parameters, this array is counted first by row index, and then by column index, i.e. neighboring row indices correspond to neighboring indices in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; are given, the size of the &#039;&#039;Values&#039;&#039; array must be consistent with the sizes of the &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; arrays, i.e. the number of &#039;&#039;Values&#039;&#039; must equal the product of the numbers of &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If neither &#039;&#039;RowLabels&#039;&#039; nor &#039;&#039;ColumnLabels&#039;&#039; are given, &#039;&#039;ColumnLabels&#039;&#039; will be set to a single &amp;quot;1&amp;quot; entry, and &#039;&#039;RowLabels&#039;&#039; will be set to a list from &amp;quot;1&amp;quot; to the number of entries in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
Otherwise, reading the parameter from the JSON string will fail.&lt;br /&gt;
&lt;br /&gt;
===RowLabels, ColumnLabels===&lt;br /&gt;
Arrays of row resp. column labels. For single-valued and list parameters, you may omit &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; as described under &#039;&#039;Values&#039;&#039;.&lt;br /&gt;
For matrix parameters, the shape of the matrix is derived from the number of entries in row and column labels.&lt;br /&gt;
&lt;br /&gt;
If no textual labels are available for rows and columns, specify a string-valued list from &amp;quot;1&amp;quot; to the number of entries in each property (a so-called trivial label).&lt;br /&gt;
&lt;br /&gt;
===Comment===&lt;br /&gt;
An arbitrary text describing the parameter to the user. This is displayed in the Operator module&#039;s parameter editor, next to the parameter value.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;Comment&#039;&#039; property may also contain additional information about a parameter; see [[Technical Reference:Parameter Definition]] for details.&lt;br /&gt;
&lt;br /&gt;
===DefaultValue===&lt;br /&gt;
An example value that may be provided to show how a parameter may be used. This is typically omitted.&lt;br /&gt;
&lt;br /&gt;
===LowRange, HighRange===&lt;br /&gt;
Values that represent a numerical parameter&#039;s minimum and maximum values. In the context of JSON parameters, these are typically unused and thus omitted.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The following is an example in Python, using the [[Programming Reference:BCI2000Remote Class]].&lt;br /&gt;
&lt;br /&gt;
 import json&lt;br /&gt;
&lt;br /&gt;
 bci = BCI2000Remote()&lt;br /&gt;
 print(&amp;quot;Operator path: &amp;quot; + bci.OperatorPath)&lt;br /&gt;
 bci.WindowVisible = True&lt;br /&gt;
 bci.WindowTitle = &amp;quot;Python controlled&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 bci.SubjectID = &amp;quot;pysub&amp;quot;&lt;br /&gt;
 bci.Connect()&lt;br /&gt;
&lt;br /&gt;
 myparam = dict()&lt;br /&gt;
 myparam[&amp;quot;Name&amp;quot;] = &#039;foo&#039;&lt;br /&gt;
 myparam[&amp;quot;Sections&amp;quot;] = [&#039;blubb&#039;, &#039;blobb&#039;]&lt;br /&gt;
 myparam[&amp;quot;Type&amp;quot;] = &#039;string&#039;&lt;br /&gt;
 myparam[&amp;quot;Values&amp;quot;] = [&#039;bar&#039;]&lt;br /&gt;
 myparam[&amp;quot;Comment&amp;quot;] = &#039;This is a test parameter created from Python.&#039;&lt;br /&gt;
 bci.AddParameterJson(json.dumps(myparam))&lt;br /&gt;
&lt;br /&gt;
 myparam2 = json.loads(bci.GetParameterJson(&#039;foo&#039;))&lt;br /&gt;
 print(myparam2)&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12661</id>
		<title>User Reference:JSON Parameter Format</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12661"/>
		<updated>2026-10-12T16:23:17Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* RowLabels, ColumnLabels */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
The BCI2000 JSON parameter format defines how [[Technical Reference:Parameter Definition|BCI2000 parameters]] are represented when using JSON related parameter functions in the [[Programming Reference:BCI2000Remote Class]], the [[Technical Reference:Operator Library]], or [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
Due to the fact that a Python &#039;&#039;dict&#039;&#039; object may easily be represented in JSON format, the JSON parameter format is most useful when used with Python.&lt;br /&gt;
&lt;br /&gt;
This allows creating a &#039;&#039;dict&#039;&#039; object with the desired parameter properties, and then converting it to JSON representation using the &amp;lt;tt&amp;gt;json.dumps()&amp;lt;/tt&amp;gt; function. Similarly, a JSON string may be converted to a Python &#039;&#039;dict&#039;&#039; object using the &amp;lt;tt&amp;gt;json.loads()&amp;lt;/tt&amp;gt; function (see example below).&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
The following properties are used when reading a JSON string into a parameter object. Any other properties are ignored. The only mandatory properties are &amp;quot;Name&amp;quot; and &amp;quot;Values&amp;quot;. If the parameter is supposed to appear in the Operator module&#039;s parameter editor dialog, the &amp;quot;Section&amp;quot; property must be provided as well.&lt;br /&gt;
&lt;br /&gt;
===Name===&lt;br /&gt;
The parameter name, with an optional path, separated by slashes (&amp;quot;/&amp;quot;). The path does not refer to the filesystem but to the internal hierarchy of filters in the BCI2000 system. Typically, you will only provide a name here, or use a path obtained from one of the &amp;lt;tt&amp;gt;GetParameterJson()&amp;lt;/tt&amp;gt; call.&lt;br /&gt;
&lt;br /&gt;
===Type===&lt;br /&gt;
The parameter&#039;s type, which may indicate data type, such as &#039;&#039;string&#039;&#039;, &#039;&#039;float&#039;&#039;, &#039;&#039;int&#039;&#039;, and shape, such as &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039;. Data type is not enforced, and may be omitted for &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039; parameters.&lt;br /&gt;
&lt;br /&gt;
===Sections===&lt;br /&gt;
An array of strings which describe a hierarchy of sections, with the first one indicating the tab in the Operator module&#039;s parameter editor dialog, and the second one indicating the group box inside the tab. Any number of sections may be given but only the first two will be used in the current implementation of BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Values===&lt;br /&gt;
An array of parameter values. For matrix valued parameters, this array is counted first by row index, and then by column index, i.e. neighboring row indices correspond to neighboring indices in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; are given, the size of the &#039;&#039;Values&#039;&#039; array must be consistent with the sizes of the &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; arrays, i.e. the number of &#039;&#039;Values&#039;&#039; must equal the product of the numbers of &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If neither &#039;&#039;RowLabels&#039;&#039; nor &#039;&#039;ColumnLabels&#039;&#039; are given, &#039;&#039;ColumnLabels&#039;&#039; will be set to a single &amp;quot;1&amp;quot; entry, and &#039;&#039;RowLabels&#039;&#039; will be set to a list from &amp;quot;1&amp;quot; to the number of entries in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
Otherwise, reading the parameter from the JSON string will fail.&lt;br /&gt;
&lt;br /&gt;
===RowLabels, ColumnLabels===&lt;br /&gt;
Arrays of row resp. column labels. For single-valued and list parameters, you may omit &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; as described under &#039;&#039;Values&#039;&#039;.&lt;br /&gt;
For matrix parameters, the shape of the matrix is derived from the number of entries in row and column labels.&lt;br /&gt;
&lt;br /&gt;
If no textual labels are available for rows and columns, specify a string-valued list from &amp;quot;1&amp;quot; to the number of entries in each property (a so-called trivial label).&lt;br /&gt;
&lt;br /&gt;
===Comment===&lt;br /&gt;
An arbitrary text describing the parameter to the user. This is displayed in the Operator module&#039;s parameter editor, next to the parameter value.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;Comment&#039;&#039; property may also contain additional information about a parameter; see [[Technical Reference:Parameter Definition]] for details.&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12660</id>
		<title>User Reference:JSON Parameter Format</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12660"/>
		<updated>2026-10-12T16:20:22Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Values */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
The BCI2000 JSON parameter format defines how [[Technical Reference:Parameter Definition|BCI2000 parameters]] are represented when using JSON related parameter functions in the [[Programming Reference:BCI2000Remote Class]], the [[Technical Reference:Operator Library]], or [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
Due to the fact that a Python &#039;&#039;dict&#039;&#039; object may easily be represented in JSON format, the JSON parameter format is most useful when used with Python.&lt;br /&gt;
&lt;br /&gt;
This allows creating a &#039;&#039;dict&#039;&#039; object with the desired parameter properties, and then converting it to JSON representation using the &amp;lt;tt&amp;gt;json.dumps()&amp;lt;/tt&amp;gt; function. Similarly, a JSON string may be converted to a Python &#039;&#039;dict&#039;&#039; object using the &amp;lt;tt&amp;gt;json.loads()&amp;lt;/tt&amp;gt; function (see example below).&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
The following properties are used when reading a JSON string into a parameter object. Any other properties are ignored. The only mandatory properties are &amp;quot;Name&amp;quot; and &amp;quot;Values&amp;quot;. If the parameter is supposed to appear in the Operator module&#039;s parameter editor dialog, the &amp;quot;Section&amp;quot; property must be provided as well.&lt;br /&gt;
&lt;br /&gt;
===Name===&lt;br /&gt;
The parameter name, with an optional path, separated by slashes (&amp;quot;/&amp;quot;). The path does not refer to the filesystem but to the internal hierarchy of filters in the BCI2000 system. Typically, you will only provide a name here, or use a path obtained from one of the &amp;lt;tt&amp;gt;GetParameterJson()&amp;lt;/tt&amp;gt; call.&lt;br /&gt;
&lt;br /&gt;
===Type===&lt;br /&gt;
The parameter&#039;s type, which may indicate data type, such as &#039;&#039;string&#039;&#039;, &#039;&#039;float&#039;&#039;, &#039;&#039;int&#039;&#039;, and shape, such as &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039;. Data type is not enforced, and may be omitted for &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039; parameters.&lt;br /&gt;
&lt;br /&gt;
===Sections===&lt;br /&gt;
An array of strings which describe a hierarchy of sections, with the first one indicating the tab in the Operator module&#039;s parameter editor dialog, and the second one indicating the group box inside the tab. Any number of sections may be given but only the first two will be used in the current implementation of BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Values===&lt;br /&gt;
An array of parameter values. For matrix valued parameters, this array is counted first by row index, and then by column index, i.e. neighboring row indices correspond to neighboring indices in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; are given, the size of the &#039;&#039;Values&#039;&#039; array must be consistent with the sizes of the &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; arrays, i.e. the number of &#039;&#039;Values&#039;&#039; must equal the product of the numbers of &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If neither &#039;&#039;RowLabels&#039;&#039; nor &#039;&#039;ColumnLabels&#039;&#039; are given, &#039;&#039;ColumnLabels&#039;&#039; will be set to a single &amp;quot;1&amp;quot; entry, and &#039;&#039;RowLabels&#039;&#039; will be set to a list from &amp;quot;1&amp;quot; to the number of entries in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
Otherwise, reading the parameter from the JSON string will fail.&lt;br /&gt;
&lt;br /&gt;
===RowLabels, ColumnLabels===&lt;br /&gt;
Arrays of row resp. column labels. For single-valued and list parameters, you may omit &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; as described under &#039;&#039;Values&#039;&#039;.&lt;br /&gt;
For matrix parameters, the shape of the matrix is derived from the number of entries in row and column labels.&lt;br /&gt;
&lt;br /&gt;
If no textual labels are available for rows and columns, specify a string-valued list from &amp;quot;1&amp;quot; to the number of entries in each property (a so-called trivial label).&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12659</id>
		<title>User Reference:JSON Parameter Format</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12659"/>
		<updated>2026-10-12T16:14:32Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
The BCI2000 JSON parameter format defines how [[Technical Reference:Parameter Definition|BCI2000 parameters]] are represented when using JSON related parameter functions in the [[Programming Reference:BCI2000Remote Class]], the [[Technical Reference:Operator Library]], or [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
Due to the fact that a Python &#039;&#039;dict&#039;&#039; object may easily be represented in JSON format, the JSON parameter format is most useful when used with Python.&lt;br /&gt;
&lt;br /&gt;
This allows creating a &#039;&#039;dict&#039;&#039; object with the desired parameter properties, and then converting it to JSON representation using the &amp;lt;tt&amp;gt;json.dumps()&amp;lt;/tt&amp;gt; function. Similarly, a JSON string may be converted to a Python &#039;&#039;dict&#039;&#039; object using the &amp;lt;tt&amp;gt;json.loads()&amp;lt;/tt&amp;gt; function (see example below).&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
The following properties are used when reading a JSON string into a parameter object. Any other properties are ignored. The only mandatory properties are &amp;quot;Name&amp;quot; and &amp;quot;Values&amp;quot;. If the parameter is supposed to appear in the Operator module&#039;s parameter editor dialog, the &amp;quot;Section&amp;quot; property must be provided as well.&lt;br /&gt;
&lt;br /&gt;
===Name===&lt;br /&gt;
The parameter name, with an optional path, separated by slashes (&amp;quot;/&amp;quot;). The path does not refer to the filesystem but to the internal hierarchy of filters in the BCI2000 system. Typically, you will only provide a name here, or use a path obtained from one of the &amp;lt;tt&amp;gt;GetParameterJson()&amp;lt;/tt&amp;gt; call.&lt;br /&gt;
&lt;br /&gt;
===Type===&lt;br /&gt;
The parameter&#039;s type, which may indicate data type, such as &#039;&#039;string&#039;&#039;, &#039;&#039;float&#039;&#039;, &#039;&#039;int&#039;&#039;, and shape, such as &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039;. Data type is not enforced, and may be omitted for &#039;&#039;list&#039;&#039; or &#039;&#039;matrix&#039;&#039; parameters.&lt;br /&gt;
&lt;br /&gt;
===Sections===&lt;br /&gt;
An array of strings which describe a hierarchy of sections, with the first one indicating the tab in the Operator module&#039;s parameter editor dialog, and the second one indicating the group box inside the tab. Any number of sections may be given but only the first two will be used in the current implementation of BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Values===&lt;br /&gt;
An array of parameter values.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; are given, the size of the &#039;&#039;Values&#039;&#039; array must be consistent with the sizes of the &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039; arrays, i.e. the number of &#039;&#039;Values&#039;&#039; must equal the product of the numbers of &#039;&#039;RowLabels&#039;&#039; and &#039;&#039;ColumnLabels&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If neither &#039;&#039;RowLabels&#039;&#039; nor &#039;&#039;ColumnLabels&#039;&#039; are given, &#039;&#039;ColumnLabels&#039;&#039; will be set to a single &amp;quot;1&amp;quot; entry, and &#039;&#039;RowLabels&#039;&#039; will be set to a list from &amp;quot;1&amp;quot; to the number of entries in the &#039;&#039;Values&#039;&#039; array.&lt;br /&gt;
&lt;br /&gt;
Otherwise, reading the parameter from the JSON string will fail.&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12658</id>
		<title>User Reference:JSON Parameter Format</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=User_Reference:JSON_Parameter_Format&amp;diff=12658"/>
		<updated>2026-10-12T15:46:00Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: Created page with &amp;quot;==Synopsis== The BCI2000 JSON parameter format defines how BCI2000 parameters are represented when using JSON related parameter functions in the Programming Reference:BCI2000Remote Class, the Technical Reference:Operator Library, or User Reference:Operator Module Scripting.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
The BCI2000 JSON parameter format defines how [[Technical Reference:Parameter Definition|BCI2000 parameters]] are represented when using JSON related parameter functions in the [[Programming Reference:BCI2000Remote Class]], the [[Technical Reference:Operator Library]], or [[User Reference:Operator Module Scripting]].&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12657</id>
		<title>Programming Reference:BCI2000Remote Class</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12657"/>
		<updated>2026-10-12T13:36:00Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Parameters and system state */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends [[User Reference:Operator Module Scripting|Operator Scripting commands]] to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the [[#BCI2000RemoteLib|BCI2000RemoteLib]] library exist, such as Python, or MATLAB through the &amp;lt;tt&amp;gt;loadlibrary&amp;lt;/tt&amp;gt; command, specifying &amp;lt;tt&amp;gt;src/core/Operator/BCI2000Remote/BCI2000RemoteLib.h&amp;lt;/tt&amp;gt; as the header file associated with the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--For controlling BCI2000 under Windows from MATLAB, Windows Automation compatible scripting languages, or .NET languages, there exists a separate [[Contributions:BCI2000Automation|automation interface]].--&amp;gt;&lt;br /&gt;
For controlling BCI2000 from shell scripts (such as the Windows command interpreter, or Unix shells like bash), there exists a [[Contributions:BCI2000Command|BCI2000 command executable]] and the [[User_Reference:BCI2000Shell|BCI2000Shell]].&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
BCI2000/src/core/Operator/BCI2000Remote&lt;br /&gt;
&lt;br /&gt;
==Functional Description==&lt;br /&gt;
After instantiating a BCI2000Remote object, set its OperatorPath property to point to the desired BCI2000 Operator module. Then, call its Connect() method to start up that module, and connect to it. You may then use the StartupModules() method in order to start up BCI2000 core modules.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you may specify the path to a BCI2000 batch file in the BCI2000/batch directory. An appropriate batch file should start up Operator and core modules, and needs to forward its command line arguments to the Operator module. All batch files coming with BCI2000 fulfill this condition. When a batch file is specified, there is no need to call the StartupModules() method.&lt;br /&gt;
&lt;br /&gt;
As yet another option, you may connect to an Operator module that is already running, e.g., on a remote machine on the network. In this case, set the BCI2000Remote object&#039;s OperatorPath property to an empty string, and its TelnetAddress property to the address that the remote Operator module is listening on, i.e. the remote machine&#039;s IP address, followed with a colon, and the port specified when starting up the remote Operator module. The remote Operator module must have been started with the &amp;quot;--Telnet&amp;quot; command line option, followed with the address to listen on. On the remote machine, this would typically be &amp;quot;localhost:3999&amp;quot;. Don&#039;t use any of the ports between 4000 and 4002, as this will interfere with the communication between the Operator module, and BCI2000 core modules. Depending on whether the remote Operator module has been started up together with its core modules, or not, you may then call the StartupModules() method in order to start up BCI2000 core modules on the remote machine.&lt;br /&gt;
&lt;br /&gt;
Once all BCI2000 modules are running, you may load parameter files locally or remotely using the LoadParametersLocal() and LoadParametersRemote() methods. Subject ID, Session ID, and data directory are set using the respective BCI2000Remote properties.&lt;br /&gt;
&lt;br /&gt;
A recording may then be started by calling the Start() method. Depending on configuration, the recording will terminate automatically, or needs to be terminated by a call to the Stop() method.&lt;br /&gt;
&lt;br /&gt;
To run BCI2000 in a different configuration (i.e., with different core modules), it is not necessary to terminate the Operator module. Rather, you may execute StartupModules() multiple times in order to terminate currently running core modules, and start different ones.&lt;br /&gt;
&lt;br /&gt;
Once you are done using BCI2000, you may close the connection by calling the Disconnect() method, or by deleting the BCI2000Remote object. Depending on whether the Operator module was started up by the previous Connect() call, this will terminate the Operator module as well. When connection was made to an already running Operator module, local or remote, the connection will be closed but the Operator module will remain running.&lt;br /&gt;
&lt;br /&gt;
==BCI2000Remote Members==&lt;br /&gt;
The BCI2000Remote class has the following members:&lt;br /&gt;
===Properties===&lt;br /&gt;
====double Timeout=5 (rw)====&lt;br /&gt;
Timeout in seconds. Applies when establishing communication between BCI2000Remote and BCI2000.&lt;br /&gt;
&lt;br /&gt;
====string OperatorPath=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Path to Operator module, or batch file. When empty, BCI2000Remote tries to connect to an already running Operator module which may be on a different machine, depending on the &#039;&#039;TelnetAddress&#039;&#039; setting. When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module.&lt;br /&gt;
&lt;br /&gt;
====string TelnetAddress=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Telnet address to use for connection to a remote machine. To connect to a remote machine, specify the machine&#039;s IP address, followed with BCI2000&#039;s listening port. You should take care to avoid specifying a port that is used by BCI2000&#039;s internal connections between Operator and core modules. By default, these are 4000, 4001, and 4002.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module. This is preferable for security reasons.&lt;br /&gt;
&lt;br /&gt;
=====bool WindowVisible=2 (rw)=====&lt;br /&gt;
Visibility of the BCI2000 main window. 0: Invisible, 1: visible, 2: don&#039;t change.&lt;br /&gt;
&lt;br /&gt;
====string WindowTitle (rw)====&lt;br /&gt;
The title of the BCI2000 main window.&lt;br /&gt;
====string Result (r)====&lt;br /&gt;
Text output of the previously executed command, or an error message when the previously executed command failed.&lt;br /&gt;
====Recording information====&lt;br /&gt;
=====string SubjectID (rw)=====&lt;br /&gt;
The subject ID for the next recording. When this property is empty, the subject ID is taken from the current value of the SubjectName parameter.&lt;br /&gt;
=====string SessionID (rw)=====&lt;br /&gt;
The session ID for the next recording. When this property is empty, the session ID is taken from the SubjectSession parameter.&lt;br /&gt;
=====string DataDirectory (rw)=====&lt;br /&gt;
The data directory for the next recording. When a relative path is given, it is taken relative to BCI2000/data. When this property is empty, the data directory is taken from the DataDirectory parameter.&lt;br /&gt;
&lt;br /&gt;
===Connection methods===&lt;br /&gt;
====bool Connect()====&lt;br /&gt;
Connect to BCI2000. When OperatorPath is not empty, and no operator module is listening at TelnetAddress, this starts up the operator module before connecting. Will return true on success.&lt;br /&gt;
&lt;br /&gt;
====bool Connect( BCI2000Remote )====&lt;br /&gt;
Connects to the same Operator module as the BCI2000Remote instance given as an argument. This will not start BCI2000 when it is not running, thus it is necessary that the argument instance&#039;s Connect() method has been called before.&lt;br /&gt;
&lt;br /&gt;
====bool Disconnect()====&lt;br /&gt;
Disconnect from an existing connection. Terminates the running operator module if it was started by the previous Connect() call.&lt;br /&gt;
&lt;br /&gt;
===Control of operation===&lt;br /&gt;
====bool StartupModules( vector(string) modules )====&lt;br /&gt;
Start BCI2000 core modules, listed by executable name, including possible command line arguments. Each entry in the array corresponds to a single core module, given relative to the Operator module&#039;s working directory, which defaults to BCI2000/prog. You do not need to call this function if the OperatorPath property specifies a batch file rather than the Operator module itself.&lt;br /&gt;
====bool SetConfig()====&lt;br /&gt;
Applies the current set of parameters. Will be called from Start() automatically. Returns false if parameters could not be set, e.g. because the system was in running state, or because there was a preflight error when applying parameters. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Start()====&lt;br /&gt;
Starts a new run (recording) with current parameters. Returns false if the run could not be started. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Stop()====&lt;br /&gt;
Stops the current run (recording).&lt;br /&gt;
&lt;br /&gt;
===Parameters and system state===&lt;br /&gt;
====bool AddParameter( string paramdef )====&lt;br /&gt;
Constructs a parameter from the given parameter definition, and adds it to the parameter list.&lt;br /&gt;
Note that parameters may not be added outside the idle state, i.e. they may only be added before core modules have connected to the Operator.&lt;br /&gt;
&lt;br /&gt;
====bool GetParameter( string name, string&amp;amp; value )====&lt;br /&gt;
Copies the specified parameter&#039;s value into the &#039;&#039;value&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
====bool SetParameter( string name, string value )====&lt;br /&gt;
Sets the specified parameter to the given value. The parameter must exist in the system. To add a parameter, use the Execute() method in conjunction with the [[User Reference:Operator Module Scripting#ADD &amp;amp;#91;JSON&amp;amp;#93 PARAMETER &amp;lt;parameter definition&amp;gt;|ADD PARAMETER]] scripting command.&lt;br /&gt;
&lt;br /&gt;
====bool AddParameterJson( string json )====&lt;br /&gt;
Constructs a parameter from the given JSON representation, and adds it to the parameter list.&lt;br /&gt;
Note that parameters may not be added outside the idle state, i.e. they may only be added before core modules have connected to the Operator.&lt;br /&gt;
&lt;br /&gt;
The parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
====bool GetParameterJson( string name, string&amp;amp; json )====&lt;br /&gt;
Copies the specified parameter into the &#039;&#039;json&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
The parameter definition is provided in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
====bool SetParameterJson( string json )====&lt;br /&gt;
Constructs a parameter from the given JSON representation, and applies it to the parameter list.&lt;br /&gt;
The parameter must exist in the system.&lt;br /&gt;
&lt;br /&gt;
The parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
====bool LoadParametersLocal( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the calling application. This function returns false if the specified file was not found but will not provide information whether parameters were sent successfully. Rather, illegal parameter lines will be silently ignored.&lt;br /&gt;
====bool LoadParametersRemote( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the Operator module connected to. Unless explicitly changed, that working directory is the BCI2000/prog directory in which the Operator module resides.&lt;br /&gt;
&lt;br /&gt;
====bool AddStateVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds a [[Technical_Reference:State_Definition|state variable]] to the system. This is only possible before core modules have connected to the Operator module.&lt;br /&gt;
State variables added by &#039;&#039;AddStateVariable()&#039;&#039; are plain state variables (i.e., not event or stream state variables).&lt;br /&gt;
&lt;br /&gt;
====bool GetStateVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 state variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
&#039;&#039;GetStateVariable()&#039;&#039; will retrieve values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool SetStateVariable( string name, double value )====&lt;br /&gt;
Sets the value of the named BCI2000 state variable to the given value. Returns false on error.&lt;br /&gt;
&#039;&#039;SetStateVariable()&#039;&#039; can set values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool AddEventVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds an [[Technical_Reference:State_Definition#Events|event variable]] to the system. This is only possible before core modules have connected to the Operator module.	&lt;br /&gt;
====bool GetEventVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 event variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
====bool SetEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value. Returns false on error.&lt;br /&gt;
====bool PulseEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value, for the duration of a single sample.&lt;br /&gt;
Returns false on error.&lt;br /&gt;
&lt;br /&gt;
====bool GetSystemState( string&amp;amp; state )====&lt;br /&gt;
Gets the current system state (i.e., state of operation). If no error occurred, the &amp;quot;state&amp;quot; output variable will contain the name of the current system state, which will be one of the names listed at [[User Reference:Operator Module Scripting#GET_SYSTEM_STATE]].&lt;br /&gt;
====bool GetControlSignalChannels( double&amp;amp; channels )====&lt;br /&gt;
Copies the number of control signal channels into the &amp;quot;channels&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignalElements( double&amp;amp; elements )====&lt;br /&gt;
Copies the number of control signal elements into the &amp;quot;elements&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignal( int channel, int element, double&amp;amp; value )====&lt;br /&gt;
Copies the value of the control signal at the given indices into the &amp;quot;value&amp;quot; output variable. Indices are 1-based. Typically, the control signal has only a single element, and the number of output channels corresponds to the number of feedback dimensions in feedback experiments, or is 1 in evoked potential experiments.&lt;br /&gt;
&lt;br /&gt;
===Scripting methods===&lt;br /&gt;
====bool Execute( string command, int* exitCode = 0 )====&lt;br /&gt;
Execute an arbitrary BCI2000 scripting command. A return value of &amp;quot;true&amp;quot; does not indicate successful execution of the command; rather, it indicates that the command was sent, and its result was received. In general, the &#039;&#039;&#039;Result&#039;&#039;&#039; property needs to be examined in order to determine whether the command was executed successfully.&lt;br /&gt;
&lt;br /&gt;
In many cases, the optional &#039;&#039;exitCode&#039;&#039; argument may be specified to obtain the result status of a command in an integer variable that the &#039;&#039;exitCode&#039;&#039; pointer points to.&lt;br /&gt;
The exact meaning of the exit code depends on the command that has been executed, so it is necessary to be aware of a command&#039;s possible responses before evaluating an exit code.&lt;br /&gt;
&lt;br /&gt;
In detail, the exit code is determined as follows:&lt;br /&gt;
* When Execute() is used to execute a SYSTEM command, the exit code will match the exit code of the program that was run through the SYSTEM command. By convention, such exit codes are nonzero on failure, and zero on success.&lt;br /&gt;
* For other commands, the exit code is derived from the &#039;&#039;&#039;Result&#039;&#039;&#039; property as follows:&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; may be interpreted as a single floating point number, the exit code will be 0 for a nonzero number, and 1 if the number is zero.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot; (without considering case), the exit code will be 0 for &amp;quot;true&amp;quot;, and 1 for &amp;quot;false&amp;quot;.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is empty, the exit code will be 0.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; does not match any of the previous conditions, the exit code will be -1 to indicate that there was no obvious interpretation.&lt;br /&gt;
&lt;br /&gt;
This scheme is chosen to simplify client code for the most common cases:&lt;br /&gt;
* external programs run through the SYSTEM command,&lt;br /&gt;
* commands which do not have an output except in case of failure,&lt;br /&gt;
* functions returning binary values, such as the test command,&lt;br /&gt;
* expressions evaluated as logical conditions.&lt;br /&gt;
In all these cases, the exit code will be 0 on success, and 1 on failure.&lt;br /&gt;
&lt;br /&gt;
When executing a command that may return an arbitrary string (e.g., EXECUTE SCRIPT, or ECHO), the exit code should not be used. In this case, the &#039;&#039;exitCode&#039;&#039; argument may be omitted, or may be NULL.&lt;br /&gt;
&lt;br /&gt;
A full documentation of BCI2000 Operator scripting commands is available under [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
====bool SetScript( string handlers, string script )====&lt;br /&gt;
Associate a sequence of BCI2000 scripting commands with the specified events. Events are given by name, as defined in the [[User Reference:Operator Module Scripting|scripting reference]]. Multiple handler names may be specified, concatenated with a pipe &#039;|&#039; character.&lt;br /&gt;
&lt;br /&gt;
====bool GetScript( string handler, string&amp;amp; script )====&lt;br /&gt;
Copy the handler script into the &#039;&#039;script&#039;&#039; output variable.&lt;br /&gt;
&lt;br /&gt;
===Watches===&lt;br /&gt;
====Watch* NewWatch( string expression, WatchCallback, void* callbackData )====&lt;br /&gt;
Creates a new watch object that watches on the expression or expressions given, and calls the specified callback each time the expression value changes. CallbackData is arbitrary user data (e.g., a pointer to an object) required for processing the callback.&lt;br /&gt;
If multiple expressions are given, they must be separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
The watch object may be disposed of by calling an ordinary delete.&lt;br /&gt;
&lt;br /&gt;
====void WatchCallback( void* callbackData, const char* values )====&lt;br /&gt;
Signature of a user-defined callback function that receives expression values, along with the arbitrary user data stored in callbackData. The values string starts with millisecond timestamp, followed with one value for each expression, and a trailing CRLF. Values are separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
To facilitate the use of BCI2000Remote, it only depends on very few files from the BCI2000 framework. To use BCI2000Remote in a C++ project, you will need to add the following cpp files to the project, and their parent directories to the list of include paths:&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Remote.cpp&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Connection.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SockStream.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SelfPipe.cpp&lt;br /&gt;
Also, on Windows you will need to link against this additional library:&lt;br /&gt;
 WS2_32&lt;br /&gt;
&lt;br /&gt;
==[[Technical Reference:BCI2000Remote Library|BCI2000RemoteLib]]==&lt;br /&gt;
The BCI2000RemoteLib is a dynamic library that exports a C-style wrapper around the BCI2000Remote class, such that it may be used from scripting languages that support execution of library code. A C-style wrapper is required because no stable conventions exist regarding the export of classes and objects from dynamic libraries.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote member functions are directly mapped on C functions by adding an object handle as a first argument, and by replacing &amp;lt;tt&amp;gt;std::string&amp;lt;/tt&amp;gt; arguments with C string arguments. To instantiate a BCI2000Remote object, and obtain an object handle, call &amp;lt;tt&amp;gt;BCI2000Remote_New()&amp;lt;/tt&amp;gt;; specify this handle as a first argument to any BCI2000Remote member function you would like to call, and finally delete the object by specifying its handle as an argument to &amp;lt;tt&amp;gt;BCI2000Remote_Delete()&amp;lt;/tt&amp;gt;. An object handle should always be treated as an opaque reference, and never be cast to a pointer of type &amp;lt;tt&amp;gt;BCI2000Remote*&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Similarly, &amp;lt;tt&amp;gt;BCI20000Remote_NewWatch()&amp;lt;/tt&amp;gt; returns a reference to a watch object as a &amp;lt;tt&amp;gt;void*&amp;lt;/tt&amp;gt;. Once you are done with the watch object, call &amp;lt;tt&amp;gt;BCI2000Remote_DeleteWatch()&amp;lt;/tt&amp;gt; to dispose of it.&lt;br /&gt;
&lt;br /&gt;
Any function that returns a C string as a &amp;lt;tt&amp;gt;const char*&amp;lt;/tt&amp;gt; may return a zero pointer, indicating failure, or a valid pointer to a C string, indicating success. If a valid pointer is returned, the associated memory has been allocated by the library, and will be invalidated by the next call to a C string returning function. Earlier versions of BCI2000RemoteLib required to call &amp;lt;tt&amp;gt;BCI2000Release()&amp;lt;/tt&amp;gt; after receiving a C string. This is no longer the case. Instead, the memory allocated for the C string is deallocated on the next call that returns a C string.&lt;br /&gt;
&lt;br /&gt;
==Python Variations==&lt;br /&gt;
There is a wrapper to BCI2000RemoteLib in Python, which lets you call functions that are very similar to the BCI2000Remote class. Most of the members are documented above, however the syntax is different for some. There are a couple new functions as well, all of which will be highlighted here.&lt;br /&gt;
===Get &amp;lt;Variable&amp;gt;===&lt;br /&gt;
For the &amp;quot;Get&amp;quot; functions (e.g., GetState, GetParameter, GetEvent), instead of passing a variable by reference, the return value is set to the desired variable (e.g., the state, parameter, event). For example, the syntax is &amp;lt;code&amp;gt; state = bci.GetStateVariable(&amp;quot;StimulusCode&amp;quot;) &amp;lt;/code&amp;gt;, where &amp;lt;code&amp;gt;state&amp;lt;/code&amp;gt; is a c_double that is the value of the state.&lt;br /&gt;
===Additional functions===&lt;br /&gt;
*&amp;lt;b&amp;gt;Quit()&amp;lt;/b&amp;gt;: quits the system&lt;br /&gt;
*&amp;lt;b&amp;gt;GetListParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a list, this returns an array of the parameter values in the list&lt;br /&gt;
*&amp;lt;b&amp;gt;GetMatrixParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a matrix, this returns a 2d array of the matrix&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
See the [[User Tutorial:BCI2000Remote|user tutorial page]] for C++, Matlab, and Python examples!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Tutorial:BCI2000Remote]], &amp;lt;!--[[Contributions:BCI2000Automation]],--&amp;gt; [[Contributions:BCI2000PresentationLink]], [[Contributions:BCI2000Command]], [[Contributions:BCI2000PythonBindings]], [[Contributions:Applications]]&lt;br /&gt;
&lt;br /&gt;
[[Category:External Interfaces]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12656</id>
		<title>Programming Reference:BCI2000Remote Class</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12656"/>
		<updated>2026-10-12T13:31:29Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* bool PutParameterJson( string json ) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends [[User Reference:Operator Module Scripting|Operator Scripting commands]] to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the [[#BCI2000RemoteLib|BCI2000RemoteLib]] library exist, such as Python, or MATLAB through the &amp;lt;tt&amp;gt;loadlibrary&amp;lt;/tt&amp;gt; command, specifying &amp;lt;tt&amp;gt;src/core/Operator/BCI2000Remote/BCI2000RemoteLib.h&amp;lt;/tt&amp;gt; as the header file associated with the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--For controlling BCI2000 under Windows from MATLAB, Windows Automation compatible scripting languages, or .NET languages, there exists a separate [[Contributions:BCI2000Automation|automation interface]].--&amp;gt;&lt;br /&gt;
For controlling BCI2000 from shell scripts (such as the Windows command interpreter, or Unix shells like bash), there exists a [[Contributions:BCI2000Command|BCI2000 command executable]] and the [[User_Reference:BCI2000Shell|BCI2000Shell]].&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
BCI2000/src/core/Operator/BCI2000Remote&lt;br /&gt;
&lt;br /&gt;
==Functional Description==&lt;br /&gt;
After instantiating a BCI2000Remote object, set its OperatorPath property to point to the desired BCI2000 Operator module. Then, call its Connect() method to start up that module, and connect to it. You may then use the StartupModules() method in order to start up BCI2000 core modules.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you may specify the path to a BCI2000 batch file in the BCI2000/batch directory. An appropriate batch file should start up Operator and core modules, and needs to forward its command line arguments to the Operator module. All batch files coming with BCI2000 fulfill this condition. When a batch file is specified, there is no need to call the StartupModules() method.&lt;br /&gt;
&lt;br /&gt;
As yet another option, you may connect to an Operator module that is already running, e.g., on a remote machine on the network. In this case, set the BCI2000Remote object&#039;s OperatorPath property to an empty string, and its TelnetAddress property to the address that the remote Operator module is listening on, i.e. the remote machine&#039;s IP address, followed with a colon, and the port specified when starting up the remote Operator module. The remote Operator module must have been started with the &amp;quot;--Telnet&amp;quot; command line option, followed with the address to listen on. On the remote machine, this would typically be &amp;quot;localhost:3999&amp;quot;. Don&#039;t use any of the ports between 4000 and 4002, as this will interfere with the communication between the Operator module, and BCI2000 core modules. Depending on whether the remote Operator module has been started up together with its core modules, or not, you may then call the StartupModules() method in order to start up BCI2000 core modules on the remote machine.&lt;br /&gt;
&lt;br /&gt;
Once all BCI2000 modules are running, you may load parameter files locally or remotely using the LoadParametersLocal() and LoadParametersRemote() methods. Subject ID, Session ID, and data directory are set using the respective BCI2000Remote properties.&lt;br /&gt;
&lt;br /&gt;
A recording may then be started by calling the Start() method. Depending on configuration, the recording will terminate automatically, or needs to be terminated by a call to the Stop() method.&lt;br /&gt;
&lt;br /&gt;
To run BCI2000 in a different configuration (i.e., with different core modules), it is not necessary to terminate the Operator module. Rather, you may execute StartupModules() multiple times in order to terminate currently running core modules, and start different ones.&lt;br /&gt;
&lt;br /&gt;
Once you are done using BCI2000, you may close the connection by calling the Disconnect() method, or by deleting the BCI2000Remote object. Depending on whether the Operator module was started up by the previous Connect() call, this will terminate the Operator module as well. When connection was made to an already running Operator module, local or remote, the connection will be closed but the Operator module will remain running.&lt;br /&gt;
&lt;br /&gt;
==BCI2000Remote Members==&lt;br /&gt;
The BCI2000Remote class has the following members:&lt;br /&gt;
===Properties===&lt;br /&gt;
====double Timeout=5 (rw)====&lt;br /&gt;
Timeout in seconds. Applies when establishing communication between BCI2000Remote and BCI2000.&lt;br /&gt;
&lt;br /&gt;
====string OperatorPath=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Path to Operator module, or batch file. When empty, BCI2000Remote tries to connect to an already running Operator module which may be on a different machine, depending on the &#039;&#039;TelnetAddress&#039;&#039; setting. When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module.&lt;br /&gt;
&lt;br /&gt;
====string TelnetAddress=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Telnet address to use for connection to a remote machine. To connect to a remote machine, specify the machine&#039;s IP address, followed with BCI2000&#039;s listening port. You should take care to avoid specifying a port that is used by BCI2000&#039;s internal connections between Operator and core modules. By default, these are 4000, 4001, and 4002.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module. This is preferable for security reasons.&lt;br /&gt;
&lt;br /&gt;
=====bool WindowVisible=2 (rw)=====&lt;br /&gt;
Visibility of the BCI2000 main window. 0: Invisible, 1: visible, 2: don&#039;t change.&lt;br /&gt;
&lt;br /&gt;
====string WindowTitle (rw)====&lt;br /&gt;
The title of the BCI2000 main window.&lt;br /&gt;
====string Result (r)====&lt;br /&gt;
Text output of the previously executed command, or an error message when the previously executed command failed.&lt;br /&gt;
====Recording information====&lt;br /&gt;
=====string SubjectID (rw)=====&lt;br /&gt;
The subject ID for the next recording. When this property is empty, the subject ID is taken from the current value of the SubjectName parameter.&lt;br /&gt;
=====string SessionID (rw)=====&lt;br /&gt;
The session ID for the next recording. When this property is empty, the session ID is taken from the SubjectSession parameter.&lt;br /&gt;
=====string DataDirectory (rw)=====&lt;br /&gt;
The data directory for the next recording. When a relative path is given, it is taken relative to BCI2000/data. When this property is empty, the data directory is taken from the DataDirectory parameter.&lt;br /&gt;
&lt;br /&gt;
===Connection methods===&lt;br /&gt;
====bool Connect()====&lt;br /&gt;
Connect to BCI2000. When OperatorPath is not empty, and no operator module is listening at TelnetAddress, this starts up the operator module before connecting. Will return true on success.&lt;br /&gt;
&lt;br /&gt;
====bool Connect( BCI2000Remote )====&lt;br /&gt;
Connects to the same Operator module as the BCI2000Remote instance given as an argument. This will not start BCI2000 when it is not running, thus it is necessary that the argument instance&#039;s Connect() method has been called before.&lt;br /&gt;
&lt;br /&gt;
====bool Disconnect()====&lt;br /&gt;
Disconnect from an existing connection. Terminates the running operator module if it was started by the previous Connect() call.&lt;br /&gt;
&lt;br /&gt;
===Control of operation===&lt;br /&gt;
====bool StartupModules( vector(string) modules )====&lt;br /&gt;
Start BCI2000 core modules, listed by executable name, including possible command line arguments. Each entry in the array corresponds to a single core module, given relative to the Operator module&#039;s working directory, which defaults to BCI2000/prog. You do not need to call this function if the OperatorPath property specifies a batch file rather than the Operator module itself.&lt;br /&gt;
====bool SetConfig()====&lt;br /&gt;
Applies the current set of parameters. Will be called from Start() automatically. Returns false if parameters could not be set, e.g. because the system was in running state, or because there was a preflight error when applying parameters. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Start()====&lt;br /&gt;
Starts a new run (recording) with current parameters. Returns false if the run could not be started. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Stop()====&lt;br /&gt;
Stops the current run (recording).&lt;br /&gt;
&lt;br /&gt;
===Parameters and system state===&lt;br /&gt;
====bool GetParameter( string name, string&amp;amp; value )====&lt;br /&gt;
Copies the specified parameter&#039;s value into the &#039;&#039;value&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
====bool SetParameter( string name, string value )====&lt;br /&gt;
Sets the specified parameter to the given value. The parameter must exist in the system. To add a parameter, use the Execute() method in conjunction with the [[User Reference:Operator Module Scripting#ADD &amp;amp;#91;JSON&amp;amp;#93 PARAMETER &amp;lt;parameter definition&amp;gt;|ADD PARAMETER]] scripting command.&lt;br /&gt;
&lt;br /&gt;
====bool GetParameterJson( string name, string&amp;amp; json )====&lt;br /&gt;
Copies the specified parameter into the &#039;&#039;json&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
The parameter definition is provided in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
====bool SetParameterJson( string json )====&lt;br /&gt;
Constructs a parameter from the given JSON representation, and applies it to the parameter list.&lt;br /&gt;
The parameter must exist in the system.&lt;br /&gt;
&lt;br /&gt;
The parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
====bool LoadParametersLocal( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the calling application. This function returns false if the specified file was not found but will not provide information whether parameters were sent successfully. Rather, illegal parameter lines will be silently ignored.&lt;br /&gt;
====bool LoadParametersRemote( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the Operator module connected to. Unless explicitly changed, that working directory is the BCI2000/prog directory in which the Operator module resides.&lt;br /&gt;
&lt;br /&gt;
====bool AddStateVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds a [[Technical_Reference:State_Definition|state variable]] to the system. This is only possible before core modules have connected to the Operator module.&lt;br /&gt;
State variables added by &#039;&#039;AddStateVariable()&#039;&#039; are plain state variables (i.e., not event or stream state variables).&lt;br /&gt;
&lt;br /&gt;
====bool GetStateVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 state variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
&#039;&#039;GetStateVariable()&#039;&#039; will retrieve values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool SetStateVariable( string name, double value )====&lt;br /&gt;
Sets the value of the named BCI2000 state variable to the given value. Returns false on error.&lt;br /&gt;
&#039;&#039;SetStateVariable()&#039;&#039; can set values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool AddEventVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds an [[Technical_Reference:State_Definition#Events|event variable]] to the system. This is only possible before core modules have connected to the Operator module.	&lt;br /&gt;
====bool GetEventVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 event variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
====bool SetEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value. Returns false on error.&lt;br /&gt;
====bool PulseEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value, for the duration of a single sample.&lt;br /&gt;
Returns false on error.&lt;br /&gt;
&lt;br /&gt;
====bool GetSystemState( string&amp;amp; state )====&lt;br /&gt;
Gets the current system state (i.e., state of operation). If no error occurred, the &amp;quot;state&amp;quot; output variable will contain the name of the current system state, which will be one of the names listed at [[User Reference:Operator Module Scripting#GET_SYSTEM_STATE]].&lt;br /&gt;
====bool GetControlSignalChannels( double&amp;amp; channels )====&lt;br /&gt;
Copies the number of control signal channels into the &amp;quot;channels&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignalElements( double&amp;amp; elements )====&lt;br /&gt;
Copies the number of control signal elements into the &amp;quot;elements&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignal( int channel, int element, double&amp;amp; value )====&lt;br /&gt;
Copies the value of the control signal at the given indices into the &amp;quot;value&amp;quot; output variable. Indices are 1-based. Typically, the control signal has only a single element, and the number of output channels corresponds to the number of feedback dimensions in feedback experiments, or is 1 in evoked potential experiments.&lt;br /&gt;
&lt;br /&gt;
===Scripting methods===&lt;br /&gt;
====bool Execute( string command, int* exitCode = 0 )====&lt;br /&gt;
Execute an arbitrary BCI2000 scripting command. A return value of &amp;quot;true&amp;quot; does not indicate successful execution of the command; rather, it indicates that the command was sent, and its result was received. In general, the &#039;&#039;&#039;Result&#039;&#039;&#039; property needs to be examined in order to determine whether the command was executed successfully.&lt;br /&gt;
&lt;br /&gt;
In many cases, the optional &#039;&#039;exitCode&#039;&#039; argument may be specified to obtain the result status of a command in an integer variable that the &#039;&#039;exitCode&#039;&#039; pointer points to.&lt;br /&gt;
The exact meaning of the exit code depends on the command that has been executed, so it is necessary to be aware of a command&#039;s possible responses before evaluating an exit code.&lt;br /&gt;
&lt;br /&gt;
In detail, the exit code is determined as follows:&lt;br /&gt;
* When Execute() is used to execute a SYSTEM command, the exit code will match the exit code of the program that was run through the SYSTEM command. By convention, such exit codes are nonzero on failure, and zero on success.&lt;br /&gt;
* For other commands, the exit code is derived from the &#039;&#039;&#039;Result&#039;&#039;&#039; property as follows:&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; may be interpreted as a single floating point number, the exit code will be 0 for a nonzero number, and 1 if the number is zero.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot; (without considering case), the exit code will be 0 for &amp;quot;true&amp;quot;, and 1 for &amp;quot;false&amp;quot;.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is empty, the exit code will be 0.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; does not match any of the previous conditions, the exit code will be -1 to indicate that there was no obvious interpretation.&lt;br /&gt;
&lt;br /&gt;
This scheme is chosen to simplify client code for the most common cases:&lt;br /&gt;
* external programs run through the SYSTEM command,&lt;br /&gt;
* commands which do not have an output except in case of failure,&lt;br /&gt;
* functions returning binary values, such as the test command,&lt;br /&gt;
* expressions evaluated as logical conditions.&lt;br /&gt;
In all these cases, the exit code will be 0 on success, and 1 on failure.&lt;br /&gt;
&lt;br /&gt;
When executing a command that may return an arbitrary string (e.g., EXECUTE SCRIPT, or ECHO), the exit code should not be used. In this case, the &#039;&#039;exitCode&#039;&#039; argument may be omitted, or may be NULL.&lt;br /&gt;
&lt;br /&gt;
A full documentation of BCI2000 Operator scripting commands is available under [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
====bool SetScript( string handlers, string script )====&lt;br /&gt;
Associate a sequence of BCI2000 scripting commands with the specified events. Events are given by name, as defined in the [[User Reference:Operator Module Scripting|scripting reference]]. Multiple handler names may be specified, concatenated with a pipe &#039;|&#039; character.&lt;br /&gt;
&lt;br /&gt;
====bool GetScript( string handler, string&amp;amp; script )====&lt;br /&gt;
Copy the handler script into the &#039;&#039;script&#039;&#039; output variable.&lt;br /&gt;
&lt;br /&gt;
===Watches===&lt;br /&gt;
====Watch* NewWatch( string expression, WatchCallback, void* callbackData )====&lt;br /&gt;
Creates a new watch object that watches on the expression or expressions given, and calls the specified callback each time the expression value changes. CallbackData is arbitrary user data (e.g., a pointer to an object) required for processing the callback.&lt;br /&gt;
If multiple expressions are given, they must be separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
The watch object may be disposed of by calling an ordinary delete.&lt;br /&gt;
&lt;br /&gt;
====void WatchCallback( void* callbackData, const char* values )====&lt;br /&gt;
Signature of a user-defined callback function that receives expression values, along with the arbitrary user data stored in callbackData. The values string starts with millisecond timestamp, followed with one value for each expression, and a trailing CRLF. Values are separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
To facilitate the use of BCI2000Remote, it only depends on very few files from the BCI2000 framework. To use BCI2000Remote in a C++ project, you will need to add the following cpp files to the project, and their parent directories to the list of include paths:&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Remote.cpp&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Connection.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SockStream.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SelfPipe.cpp&lt;br /&gt;
Also, on Windows you will need to link against this additional library:&lt;br /&gt;
 WS2_32&lt;br /&gt;
&lt;br /&gt;
==[[Technical Reference:BCI2000Remote Library|BCI2000RemoteLib]]==&lt;br /&gt;
The BCI2000RemoteLib is a dynamic library that exports a C-style wrapper around the BCI2000Remote class, such that it may be used from scripting languages that support execution of library code. A C-style wrapper is required because no stable conventions exist regarding the export of classes and objects from dynamic libraries.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote member functions are directly mapped on C functions by adding an object handle as a first argument, and by replacing &amp;lt;tt&amp;gt;std::string&amp;lt;/tt&amp;gt; arguments with C string arguments. To instantiate a BCI2000Remote object, and obtain an object handle, call &amp;lt;tt&amp;gt;BCI2000Remote_New()&amp;lt;/tt&amp;gt;; specify this handle as a first argument to any BCI2000Remote member function you would like to call, and finally delete the object by specifying its handle as an argument to &amp;lt;tt&amp;gt;BCI2000Remote_Delete()&amp;lt;/tt&amp;gt;. An object handle should always be treated as an opaque reference, and never be cast to a pointer of type &amp;lt;tt&amp;gt;BCI2000Remote*&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Similarly, &amp;lt;tt&amp;gt;BCI20000Remote_NewWatch()&amp;lt;/tt&amp;gt; returns a reference to a watch object as a &amp;lt;tt&amp;gt;void*&amp;lt;/tt&amp;gt;. Once you are done with the watch object, call &amp;lt;tt&amp;gt;BCI2000Remote_DeleteWatch()&amp;lt;/tt&amp;gt; to dispose of it.&lt;br /&gt;
&lt;br /&gt;
Any function that returns a C string as a &amp;lt;tt&amp;gt;const char*&amp;lt;/tt&amp;gt; may return a zero pointer, indicating failure, or a valid pointer to a C string, indicating success. If a valid pointer is returned, the associated memory has been allocated by the library, and will be invalidated by the next call to a C string returning function. Earlier versions of BCI2000RemoteLib required to call &amp;lt;tt&amp;gt;BCI2000Release()&amp;lt;/tt&amp;gt; after receiving a C string. This is no longer the case. Instead, the memory allocated for the C string is deallocated on the next call that returns a C string.&lt;br /&gt;
&lt;br /&gt;
==Python Variations==&lt;br /&gt;
There is a wrapper to BCI2000RemoteLib in Python, which lets you call functions that are very similar to the BCI2000Remote class. Most of the members are documented above, however the syntax is different for some. There are a couple new functions as well, all of which will be highlighted here.&lt;br /&gt;
===Get &amp;lt;Variable&amp;gt;===&lt;br /&gt;
For the &amp;quot;Get&amp;quot; functions (e.g., GetState, GetParameter, GetEvent), instead of passing a variable by reference, the return value is set to the desired variable (e.g., the state, parameter, event). For example, the syntax is &amp;lt;code&amp;gt; state = bci.GetStateVariable(&amp;quot;StimulusCode&amp;quot;) &amp;lt;/code&amp;gt;, where &amp;lt;code&amp;gt;state&amp;lt;/code&amp;gt; is a c_double that is the value of the state.&lt;br /&gt;
===Additional functions===&lt;br /&gt;
*&amp;lt;b&amp;gt;Quit()&amp;lt;/b&amp;gt;: quits the system&lt;br /&gt;
*&amp;lt;b&amp;gt;GetListParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a list, this returns an array of the parameter values in the list&lt;br /&gt;
*&amp;lt;b&amp;gt;GetMatrixParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a matrix, this returns a 2d array of the matrix&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
See the [[User Tutorial:BCI2000Remote|user tutorial page]] for C++, Matlab, and Python examples!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Tutorial:BCI2000Remote]], &amp;lt;!--[[Contributions:BCI2000Automation]],--&amp;gt; [[Contributions:BCI2000PresentationLink]], [[Contributions:BCI2000Command]], [[Contributions:BCI2000PythonBindings]], [[Contributions:Applications]]&lt;br /&gt;
&lt;br /&gt;
[[Category:External Interfaces]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12655</id>
		<title>Programming Reference:BCI2000Remote Class</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12655"/>
		<updated>2026-10-12T13:30:44Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* bool ShowParameterJson( string name, string&amp;amp; json ) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends [[User Reference:Operator Module Scripting|Operator Scripting commands]] to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the [[#BCI2000RemoteLib|BCI2000RemoteLib]] library exist, such as Python, or MATLAB through the &amp;lt;tt&amp;gt;loadlibrary&amp;lt;/tt&amp;gt; command, specifying &amp;lt;tt&amp;gt;src/core/Operator/BCI2000Remote/BCI2000RemoteLib.h&amp;lt;/tt&amp;gt; as the header file associated with the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--For controlling BCI2000 under Windows from MATLAB, Windows Automation compatible scripting languages, or .NET languages, there exists a separate [[Contributions:BCI2000Automation|automation interface]].--&amp;gt;&lt;br /&gt;
For controlling BCI2000 from shell scripts (such as the Windows command interpreter, or Unix shells like bash), there exists a [[Contributions:BCI2000Command|BCI2000 command executable]] and the [[User_Reference:BCI2000Shell|BCI2000Shell]].&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
BCI2000/src/core/Operator/BCI2000Remote&lt;br /&gt;
&lt;br /&gt;
==Functional Description==&lt;br /&gt;
After instantiating a BCI2000Remote object, set its OperatorPath property to point to the desired BCI2000 Operator module. Then, call its Connect() method to start up that module, and connect to it. You may then use the StartupModules() method in order to start up BCI2000 core modules.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you may specify the path to a BCI2000 batch file in the BCI2000/batch directory. An appropriate batch file should start up Operator and core modules, and needs to forward its command line arguments to the Operator module. All batch files coming with BCI2000 fulfill this condition. When a batch file is specified, there is no need to call the StartupModules() method.&lt;br /&gt;
&lt;br /&gt;
As yet another option, you may connect to an Operator module that is already running, e.g., on a remote machine on the network. In this case, set the BCI2000Remote object&#039;s OperatorPath property to an empty string, and its TelnetAddress property to the address that the remote Operator module is listening on, i.e. the remote machine&#039;s IP address, followed with a colon, and the port specified when starting up the remote Operator module. The remote Operator module must have been started with the &amp;quot;--Telnet&amp;quot; command line option, followed with the address to listen on. On the remote machine, this would typically be &amp;quot;localhost:3999&amp;quot;. Don&#039;t use any of the ports between 4000 and 4002, as this will interfere with the communication between the Operator module, and BCI2000 core modules. Depending on whether the remote Operator module has been started up together with its core modules, or not, you may then call the StartupModules() method in order to start up BCI2000 core modules on the remote machine.&lt;br /&gt;
&lt;br /&gt;
Once all BCI2000 modules are running, you may load parameter files locally or remotely using the LoadParametersLocal() and LoadParametersRemote() methods. Subject ID, Session ID, and data directory are set using the respective BCI2000Remote properties.&lt;br /&gt;
&lt;br /&gt;
A recording may then be started by calling the Start() method. Depending on configuration, the recording will terminate automatically, or needs to be terminated by a call to the Stop() method.&lt;br /&gt;
&lt;br /&gt;
To run BCI2000 in a different configuration (i.e., with different core modules), it is not necessary to terminate the Operator module. Rather, you may execute StartupModules() multiple times in order to terminate currently running core modules, and start different ones.&lt;br /&gt;
&lt;br /&gt;
Once you are done using BCI2000, you may close the connection by calling the Disconnect() method, or by deleting the BCI2000Remote object. Depending on whether the Operator module was started up by the previous Connect() call, this will terminate the Operator module as well. When connection was made to an already running Operator module, local or remote, the connection will be closed but the Operator module will remain running.&lt;br /&gt;
&lt;br /&gt;
==BCI2000Remote Members==&lt;br /&gt;
The BCI2000Remote class has the following members:&lt;br /&gt;
===Properties===&lt;br /&gt;
====double Timeout=5 (rw)====&lt;br /&gt;
Timeout in seconds. Applies when establishing communication between BCI2000Remote and BCI2000.&lt;br /&gt;
&lt;br /&gt;
====string OperatorPath=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Path to Operator module, or batch file. When empty, BCI2000Remote tries to connect to an already running Operator module which may be on a different machine, depending on the &#039;&#039;TelnetAddress&#039;&#039; setting. When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module.&lt;br /&gt;
&lt;br /&gt;
====string TelnetAddress=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Telnet address to use for connection to a remote machine. To connect to a remote machine, specify the machine&#039;s IP address, followed with BCI2000&#039;s listening port. You should take care to avoid specifying a port that is used by BCI2000&#039;s internal connections between Operator and core modules. By default, these are 4000, 4001, and 4002.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module. This is preferable for security reasons.&lt;br /&gt;
&lt;br /&gt;
=====bool WindowVisible=2 (rw)=====&lt;br /&gt;
Visibility of the BCI2000 main window. 0: Invisible, 1: visible, 2: don&#039;t change.&lt;br /&gt;
&lt;br /&gt;
====string WindowTitle (rw)====&lt;br /&gt;
The title of the BCI2000 main window.&lt;br /&gt;
====string Result (r)====&lt;br /&gt;
Text output of the previously executed command, or an error message when the previously executed command failed.&lt;br /&gt;
====Recording information====&lt;br /&gt;
=====string SubjectID (rw)=====&lt;br /&gt;
The subject ID for the next recording. When this property is empty, the subject ID is taken from the current value of the SubjectName parameter.&lt;br /&gt;
=====string SessionID (rw)=====&lt;br /&gt;
The session ID for the next recording. When this property is empty, the session ID is taken from the SubjectSession parameter.&lt;br /&gt;
=====string DataDirectory (rw)=====&lt;br /&gt;
The data directory for the next recording. When a relative path is given, it is taken relative to BCI2000/data. When this property is empty, the data directory is taken from the DataDirectory parameter.&lt;br /&gt;
&lt;br /&gt;
===Connection methods===&lt;br /&gt;
====bool Connect()====&lt;br /&gt;
Connect to BCI2000. When OperatorPath is not empty, and no operator module is listening at TelnetAddress, this starts up the operator module before connecting. Will return true on success.&lt;br /&gt;
&lt;br /&gt;
====bool Connect( BCI2000Remote )====&lt;br /&gt;
Connects to the same Operator module as the BCI2000Remote instance given as an argument. This will not start BCI2000 when it is not running, thus it is necessary that the argument instance&#039;s Connect() method has been called before.&lt;br /&gt;
&lt;br /&gt;
====bool Disconnect()====&lt;br /&gt;
Disconnect from an existing connection. Terminates the running operator module if it was started by the previous Connect() call.&lt;br /&gt;
&lt;br /&gt;
===Control of operation===&lt;br /&gt;
====bool StartupModules( vector(string) modules )====&lt;br /&gt;
Start BCI2000 core modules, listed by executable name, including possible command line arguments. Each entry in the array corresponds to a single core module, given relative to the Operator module&#039;s working directory, which defaults to BCI2000/prog. You do not need to call this function if the OperatorPath property specifies a batch file rather than the Operator module itself.&lt;br /&gt;
====bool SetConfig()====&lt;br /&gt;
Applies the current set of parameters. Will be called from Start() automatically. Returns false if parameters could not be set, e.g. because the system was in running state, or because there was a preflight error when applying parameters. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Start()====&lt;br /&gt;
Starts a new run (recording) with current parameters. Returns false if the run could not be started. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Stop()====&lt;br /&gt;
Stops the current run (recording).&lt;br /&gt;
&lt;br /&gt;
===Parameters and system state===&lt;br /&gt;
====bool GetParameter( string name, string&amp;amp; value )====&lt;br /&gt;
Copies the specified parameter&#039;s value into the &#039;&#039;value&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
====bool SetParameter( string name, string value )====&lt;br /&gt;
Sets the specified parameter to the given value. The parameter must exist in the system. To add a parameter, use the Execute() method in conjunction with the [[User Reference:Operator Module Scripting#ADD &amp;amp;#91;JSON&amp;amp;#93 PARAMETER &amp;lt;parameter definition&amp;gt;|ADD PARAMETER]] scripting command.&lt;br /&gt;
&lt;br /&gt;
====bool GetParameterJson( string name, string&amp;amp; json )====&lt;br /&gt;
Copies the specified parameter into the &#039;&#039;json&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
The parameter definition is provided in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
====bool PutParameterJson( string json )====&lt;br /&gt;
Constructs a parameter from the given JSON representation, and applies it to the parameter list.&lt;br /&gt;
The parameter must exist in the system. To add a parameter, use the Execute() method in conjunction with the [[User Reference:Operator Module Scripting#ADD &amp;amp;#91;JSON&amp;amp;#93; PARAMETER &amp;lt;parameter definition&amp;gt;|ADD JSON PARAMETER]] scripting command.&lt;br /&gt;
&lt;br /&gt;
The parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
====bool LoadParametersLocal( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the calling application. This function returns false if the specified file was not found but will not provide information whether parameters were sent successfully. Rather, illegal parameter lines will be silently ignored.&lt;br /&gt;
====bool LoadParametersRemote( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the Operator module connected to. Unless explicitly changed, that working directory is the BCI2000/prog directory in which the Operator module resides.&lt;br /&gt;
&lt;br /&gt;
====bool AddStateVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds a [[Technical_Reference:State_Definition|state variable]] to the system. This is only possible before core modules have connected to the Operator module.&lt;br /&gt;
State variables added by &#039;&#039;AddStateVariable()&#039;&#039; are plain state variables (i.e., not event or stream state variables).&lt;br /&gt;
&lt;br /&gt;
====bool GetStateVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 state variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
&#039;&#039;GetStateVariable()&#039;&#039; will retrieve values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool SetStateVariable( string name, double value )====&lt;br /&gt;
Sets the value of the named BCI2000 state variable to the given value. Returns false on error.&lt;br /&gt;
&#039;&#039;SetStateVariable()&#039;&#039; can set values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool AddEventVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds an [[Technical_Reference:State_Definition#Events|event variable]] to the system. This is only possible before core modules have connected to the Operator module.	&lt;br /&gt;
====bool GetEventVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 event variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
====bool SetEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value. Returns false on error.&lt;br /&gt;
====bool PulseEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value, for the duration of a single sample.&lt;br /&gt;
Returns false on error.&lt;br /&gt;
&lt;br /&gt;
====bool GetSystemState( string&amp;amp; state )====&lt;br /&gt;
Gets the current system state (i.e., state of operation). If no error occurred, the &amp;quot;state&amp;quot; output variable will contain the name of the current system state, which will be one of the names listed at [[User Reference:Operator Module Scripting#GET_SYSTEM_STATE]].&lt;br /&gt;
====bool GetControlSignalChannels( double&amp;amp; channels )====&lt;br /&gt;
Copies the number of control signal channels into the &amp;quot;channels&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignalElements( double&amp;amp; elements )====&lt;br /&gt;
Copies the number of control signal elements into the &amp;quot;elements&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignal( int channel, int element, double&amp;amp; value )====&lt;br /&gt;
Copies the value of the control signal at the given indices into the &amp;quot;value&amp;quot; output variable. Indices are 1-based. Typically, the control signal has only a single element, and the number of output channels corresponds to the number of feedback dimensions in feedback experiments, or is 1 in evoked potential experiments.&lt;br /&gt;
&lt;br /&gt;
===Scripting methods===&lt;br /&gt;
====bool Execute( string command, int* exitCode = 0 )====&lt;br /&gt;
Execute an arbitrary BCI2000 scripting command. A return value of &amp;quot;true&amp;quot; does not indicate successful execution of the command; rather, it indicates that the command was sent, and its result was received. In general, the &#039;&#039;&#039;Result&#039;&#039;&#039; property needs to be examined in order to determine whether the command was executed successfully.&lt;br /&gt;
&lt;br /&gt;
In many cases, the optional &#039;&#039;exitCode&#039;&#039; argument may be specified to obtain the result status of a command in an integer variable that the &#039;&#039;exitCode&#039;&#039; pointer points to.&lt;br /&gt;
The exact meaning of the exit code depends on the command that has been executed, so it is necessary to be aware of a command&#039;s possible responses before evaluating an exit code.&lt;br /&gt;
&lt;br /&gt;
In detail, the exit code is determined as follows:&lt;br /&gt;
* When Execute() is used to execute a SYSTEM command, the exit code will match the exit code of the program that was run through the SYSTEM command. By convention, such exit codes are nonzero on failure, and zero on success.&lt;br /&gt;
* For other commands, the exit code is derived from the &#039;&#039;&#039;Result&#039;&#039;&#039; property as follows:&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; may be interpreted as a single floating point number, the exit code will be 0 for a nonzero number, and 1 if the number is zero.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot; (without considering case), the exit code will be 0 for &amp;quot;true&amp;quot;, and 1 for &amp;quot;false&amp;quot;.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is empty, the exit code will be 0.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; does not match any of the previous conditions, the exit code will be -1 to indicate that there was no obvious interpretation.&lt;br /&gt;
&lt;br /&gt;
This scheme is chosen to simplify client code for the most common cases:&lt;br /&gt;
* external programs run through the SYSTEM command,&lt;br /&gt;
* commands which do not have an output except in case of failure,&lt;br /&gt;
* functions returning binary values, such as the test command,&lt;br /&gt;
* expressions evaluated as logical conditions.&lt;br /&gt;
In all these cases, the exit code will be 0 on success, and 1 on failure.&lt;br /&gt;
&lt;br /&gt;
When executing a command that may return an arbitrary string (e.g., EXECUTE SCRIPT, or ECHO), the exit code should not be used. In this case, the &#039;&#039;exitCode&#039;&#039; argument may be omitted, or may be NULL.&lt;br /&gt;
&lt;br /&gt;
A full documentation of BCI2000 Operator scripting commands is available under [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
====bool SetScript( string handlers, string script )====&lt;br /&gt;
Associate a sequence of BCI2000 scripting commands with the specified events. Events are given by name, as defined in the [[User Reference:Operator Module Scripting|scripting reference]]. Multiple handler names may be specified, concatenated with a pipe &#039;|&#039; character.&lt;br /&gt;
&lt;br /&gt;
====bool GetScript( string handler, string&amp;amp; script )====&lt;br /&gt;
Copy the handler script into the &#039;&#039;script&#039;&#039; output variable.&lt;br /&gt;
&lt;br /&gt;
===Watches===&lt;br /&gt;
====Watch* NewWatch( string expression, WatchCallback, void* callbackData )====&lt;br /&gt;
Creates a new watch object that watches on the expression or expressions given, and calls the specified callback each time the expression value changes. CallbackData is arbitrary user data (e.g., a pointer to an object) required for processing the callback.&lt;br /&gt;
If multiple expressions are given, they must be separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
The watch object may be disposed of by calling an ordinary delete.&lt;br /&gt;
&lt;br /&gt;
====void WatchCallback( void* callbackData, const char* values )====&lt;br /&gt;
Signature of a user-defined callback function that receives expression values, along with the arbitrary user data stored in callbackData. The values string starts with millisecond timestamp, followed with one value for each expression, and a trailing CRLF. Values are separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
To facilitate the use of BCI2000Remote, it only depends on very few files from the BCI2000 framework. To use BCI2000Remote in a C++ project, you will need to add the following cpp files to the project, and their parent directories to the list of include paths:&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Remote.cpp&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Connection.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SockStream.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SelfPipe.cpp&lt;br /&gt;
Also, on Windows you will need to link against this additional library:&lt;br /&gt;
 WS2_32&lt;br /&gt;
&lt;br /&gt;
==[[Technical Reference:BCI2000Remote Library|BCI2000RemoteLib]]==&lt;br /&gt;
The BCI2000RemoteLib is a dynamic library that exports a C-style wrapper around the BCI2000Remote class, such that it may be used from scripting languages that support execution of library code. A C-style wrapper is required because no stable conventions exist regarding the export of classes and objects from dynamic libraries.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote member functions are directly mapped on C functions by adding an object handle as a first argument, and by replacing &amp;lt;tt&amp;gt;std::string&amp;lt;/tt&amp;gt; arguments with C string arguments. To instantiate a BCI2000Remote object, and obtain an object handle, call &amp;lt;tt&amp;gt;BCI2000Remote_New()&amp;lt;/tt&amp;gt;; specify this handle as a first argument to any BCI2000Remote member function you would like to call, and finally delete the object by specifying its handle as an argument to &amp;lt;tt&amp;gt;BCI2000Remote_Delete()&amp;lt;/tt&amp;gt;. An object handle should always be treated as an opaque reference, and never be cast to a pointer of type &amp;lt;tt&amp;gt;BCI2000Remote*&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Similarly, &amp;lt;tt&amp;gt;BCI20000Remote_NewWatch()&amp;lt;/tt&amp;gt; returns a reference to a watch object as a &amp;lt;tt&amp;gt;void*&amp;lt;/tt&amp;gt;. Once you are done with the watch object, call &amp;lt;tt&amp;gt;BCI2000Remote_DeleteWatch()&amp;lt;/tt&amp;gt; to dispose of it.&lt;br /&gt;
&lt;br /&gt;
Any function that returns a C string as a &amp;lt;tt&amp;gt;const char*&amp;lt;/tt&amp;gt; may return a zero pointer, indicating failure, or a valid pointer to a C string, indicating success. If a valid pointer is returned, the associated memory has been allocated by the library, and will be invalidated by the next call to a C string returning function. Earlier versions of BCI2000RemoteLib required to call &amp;lt;tt&amp;gt;BCI2000Release()&amp;lt;/tt&amp;gt; after receiving a C string. This is no longer the case. Instead, the memory allocated for the C string is deallocated on the next call that returns a C string.&lt;br /&gt;
&lt;br /&gt;
==Python Variations==&lt;br /&gt;
There is a wrapper to BCI2000RemoteLib in Python, which lets you call functions that are very similar to the BCI2000Remote class. Most of the members are documented above, however the syntax is different for some. There are a couple new functions as well, all of which will be highlighted here.&lt;br /&gt;
===Get &amp;lt;Variable&amp;gt;===&lt;br /&gt;
For the &amp;quot;Get&amp;quot; functions (e.g., GetState, GetParameter, GetEvent), instead of passing a variable by reference, the return value is set to the desired variable (e.g., the state, parameter, event). For example, the syntax is &amp;lt;code&amp;gt; state = bci.GetStateVariable(&amp;quot;StimulusCode&amp;quot;) &amp;lt;/code&amp;gt;, where &amp;lt;code&amp;gt;state&amp;lt;/code&amp;gt; is a c_double that is the value of the state.&lt;br /&gt;
===Additional functions===&lt;br /&gt;
*&amp;lt;b&amp;gt;Quit()&amp;lt;/b&amp;gt;: quits the system&lt;br /&gt;
*&amp;lt;b&amp;gt;GetListParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a list, this returns an array of the parameter values in the list&lt;br /&gt;
*&amp;lt;b&amp;gt;GetMatrixParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a matrix, this returns a 2d array of the matrix&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
See the [[User Tutorial:BCI2000Remote|user tutorial page]] for C++, Matlab, and Python examples!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Tutorial:BCI2000Remote]], &amp;lt;!--[[Contributions:BCI2000Automation]],--&amp;gt; [[Contributions:BCI2000PresentationLink]], [[Contributions:BCI2000Command]], [[Contributions:BCI2000PythonBindings]], [[Contributions:Applications]]&lt;br /&gt;
&lt;br /&gt;
[[Category:External Interfaces]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:WebcamLogger&amp;diff=12654</id>
		<title>Contributions:WebcamLogger</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:WebcamLogger&amp;diff=12654"/>
		<updated>2026-10-09T11:07:38Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Functional Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
An extension that records video from one or more webcams to an mp4 file, and stores frame numbers as (event-type) state variables.&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
http://{{SERVERNAME}}/svn/trunk/src/contrib/Extensions/WebcamLogger&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
===Authors===&lt;br /&gt;
*Adam Wilson (adam.wilson@uc.edu) &lt;br /&gt;
*Alexander Belsten (belsten@neurotechcenter.org)&lt;br /&gt;
*Juergen Mellinger (mellinger@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
07/06/2011 - Full commit with support for MSVC and MinGW.&lt;br /&gt;
&lt;br /&gt;
07/13/2011 - Bugfixes&lt;br /&gt;
&lt;br /&gt;
11/28/2018 - Updated openCV library to v2.4.3 for x86/x64 Windows and added functionality for recording from multiple cameras&lt;br /&gt;
&lt;br /&gt;
3/16/2021 - Updated openCV library to v4.5.1 for x86/x64 Windows.&lt;br /&gt;
&lt;br /&gt;
2/2/2022 - Rewrote WebcamLogger to use a helper app that records camera data to a file and allows previewing&lt;br /&gt;
&lt;br /&gt;
2/28/2023 - Added support for Webcam URLs.&lt;br /&gt;
&lt;br /&gt;
10/9/2026 - Replaced WebcamLogger with previous WebcamLogger2, providing Linux and macOS support through ffmpeg&#039;s libAVDevice, dropped helper app&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: --&lt;br /&gt;
*Tested under: 9592&lt;br /&gt;
*Known to compile under: 9592&lt;br /&gt;
*Broken since: 5828 for MinGW&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
==Functional Description==&lt;br /&gt;
For many experiments, visual information about how a subject is behaving during an experiment is desired. This extension acquires video from most webcams, and writes to an MP4 video file. It also records the current frame number as a state variable, so that the video can be synchronized with brain data at sample resolution (max. 1ms). Other options include the ability to overlay the date and time directly on the video (useful for long-term monitoring), and time decimation (i.e., save every Nth frame).&lt;br /&gt;
&lt;br /&gt;
The video file bears the name of the BCI2000 data file, with the extension removed and &amp;lt;tt&amp;gt;_M_video.mp4&amp;lt;/tt&amp;gt; appended where &amp;lt;tt&amp;gt;M&amp;lt;/tt&amp;gt; is the index of the camera in question.&lt;br /&gt;
For the format of the video file, see [[Contributions:WebcamLogger#Format_of_the_Video_File|the notes below]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; This module can also be used to perform screen capture with a virtual screencast webcam driver.&lt;br /&gt;
This functionality is however superseded by the [[Contributions:ScreenCaptureLogger|ScreenCaptureLogger extension]].&lt;br /&gt;
&lt;br /&gt;
==Integration into BCI2000==&lt;br /&gt;
Compile the extension into your source module by enabling contributed extensions in your CMake configuration. In your root build folder, run &amp;lt;tt&amp;gt;Configure.sh.cmd&amp;lt;/tt&amp;gt; in order to bring up the CMake GUI; there, enable EXTENSIONS_WEBCAMLOGGER.&lt;br /&gt;
&lt;br /&gt;
Once the extension is built into the source module, enable it by starting the source module with the &amp;lt;code&amp;gt;--LogWebcam=1&amp;lt;/code&amp;gt; command line argument.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
Webcams should be installed and configured per the device instructions. On Windows, the Webcam logger uses the Windows Media Foundation (WMF) library for display and saving. Desired resolution may be chosen per webcam, and will be matched agains available resolutions.&lt;br /&gt;
&lt;br /&gt;
Camera options are found in the &#039;&#039;Source&#039;&#039; tab of the Configuration window.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
The Webcam logger is configured in the &#039;&#039;Source&#039;&#039; tab within the WebcamLogger section.  The configurable parameters are:&lt;br /&gt;
&lt;br /&gt;
===LogWebcam===&lt;br /&gt;
Enables/Disables logging of Webcam states.&lt;br /&gt;
===CameraNumber===&lt;br /&gt;
Used to select one camera to record from on systems with multiple cameras. Use value 0 for the default camera.&lt;br /&gt;
===RecordAll===&lt;br /&gt;
Enables the recording of cameras from &amp;lt;code&amp;gt;StartIndex&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;EndIndex&amp;lt;/code&amp;gt;.&lt;br /&gt;
Note that, unlike other indices in BCI2000, camera indices are 0-based rather than 1-based.&lt;br /&gt;
&lt;br /&gt;
===StartIndex===&lt;br /&gt;
Index to start searching for cameras at.&lt;br /&gt;
===EndIndex===&lt;br /&gt;
Index to stop searching for cameras at.&lt;br /&gt;
===Decimation===&lt;br /&gt;
The decimation factor for saving and viewing video; the logger saves/displays every Nth frame.&lt;br /&gt;
===DateTimeLocation===&lt;br /&gt;
The location of the date/time overlay in saved video (0: none, 1: UpperRight, 2: UpperLeft, 3: LowerRight, 4: LowerLeft).&lt;br /&gt;
If &#039;&#039;&#039;DateTimeLocation&#039;&#039;&#039; is 5, the current frame number will be displayed in the upper right corner.&lt;br /&gt;
&lt;br /&gt;
===DisplayStream===&lt;br /&gt;
Display the video stream from each connected camera. Display stream is identical to what is being recorded in the .mp4 file.&lt;br /&gt;
===WebcamFormat===&lt;br /&gt;
For each camera index, you may specify a video width, height, and fps. These are matched against the formats provided by the&lt;br /&gt;
camera, and the closest one is chosen. The &#039;&#039;encoding profile&#039;&#039; column allows you to choose a H.264 encoding profile for video output, which may be a number from 1 to 3. &#039;&#039;&#039;1&#039;&#039;&#039; corresponds to the &amp;quot;baseline&amp;quot; profile, &#039;&#039;&#039;2&#039;&#039;&#039; corresponds to the &amp;quot;main&amp;quot; profile, and &#039;&#039;&#039;3&#039;&#039;&#039; corresponds to the &amp;quot;high&amp;quot; profile as defined in the &#039;&#039;ITU-T H.264&#039;&#039; standard.&lt;br /&gt;
&lt;br /&gt;
===WebcamURL===&lt;br /&gt;
In the first column of the &#039;&#039;WebcamURL&#039;&#039; matrix parameter, you may specify a camera index, and a corresponding URL in the second column. If a URL is given for a certain index, video data will be acquired from the URL rather than a webcam with the specified index attached to the machine.&lt;br /&gt;
&lt;br /&gt;
When reading video data from an URL, only streaming formats supported by the Microsoft Media Foundation library are supported. This includes MPEG4, h.264, and h.265 codecs.&lt;br /&gt;
&lt;br /&gt;
For URL-based video streams, the Microsoft Media Foundation library allows to configure both an initial buffering time (MFNETSOURCE_BUFFERINGTIME), and a maximum buffer-ahead time (MFNETSOURCE_MAXBUFFERTIMEMS). In the &#039;&#039;WebcamURL&#039;&#039; matrix parameter, these are represented by the &#039;&#039;BufferingTime&#039;&#039; and &#039;&#039;MaxBufferTime&#039;&#039; columns. For clarity, these values must be entered as time values with a trailing &amp;quot;s&amp;quot; or &amp;quot;ms&amp;quot;. Note that &#039;&#039;BufferingTime&#039;&#039; will be rounded to full seconds, whereas &#039;&#039;MaxBufferTime&#039;&#039; will be rounded to full milliseconds.&lt;br /&gt;
&lt;br /&gt;
For typical streaming webcams, it seems not possible to obtain a delay below 1s. Also, setting &#039;&#039;MaxBufferTime&#039;&#039; to values below 200ms &lt;br /&gt;
will typically result in unstable connections.&lt;br /&gt;
&lt;br /&gt;
==Event Variables==&lt;br /&gt;
&lt;br /&gt;
===WebcamFrame&amp;lt;0-n&amp;gt;===&lt;br /&gt;
The frame number of the video recorded on camera with index i. i must be less than or equal to n due to the nature of event declarations. The default value of n is 3, allowing for the recording of up to 4 cameras. To record from more cameras, change the &amp;lt;code&amp;gt;NUM_OF_WEBCAM_EVENTS&amp;lt;/code&amp;gt; macro in WebcamLogger.cpp to the number of cameras you want to record from and recompile. Event values can be used to synchronize the video with the recorded neural data. It is a 32-bit value, allowing 4294967295 frames before overflowing. If the webcam can capture at 30 frames/sec, this allows more than four years of video before it will go back to frame 0. In other words, this should not be an issue for most users.&lt;br /&gt;
&lt;br /&gt;
==Format of the Video File==&lt;br /&gt;
Each camera writes its own video file. For most webcams, actual video frame rate may deviate considerably from nominal video frame rate. Also, video frame rate is often not constant but may change over the recording. What makes things even more difficult is that files in mp4 format (and related formats) do not allow to seek to locations that represent original frames when writing the file. Rather, the file&#039;s nominal frame rate and length are used in conjunction with interpolation to construct a frame at an ideal location.&lt;br /&gt;
Thus, it is not possible to write individual frames using the camera&#039;s original timestamp, at the original frame rate.&lt;br /&gt;
&lt;br /&gt;
Instead, the file is written with a simplified framerate as close as possible to the camera&#039;s nominal framerate, with differences between frame timestamps matching ideal frame duration.&lt;br /&gt;
This way, loading the video into e.g. Matlab, you will obtain a sequence of frames where each frame index corresponds to the frame index in the &amp;lt;tt&amp;gt;WebcamFrameN&amp;lt;/tt&amp;gt; state (minus 1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: Do not expect nominal framerate and/or nominal duration of the video file to correspond to the camera&#039;s actual framerate or duration. Also, in case of variable framerate cameras, video display may be jerky when playing back the video in a standard video player such as VLC. This is &#039;&#039;not&#039;&#039; an error but an artifact of how video frames are stored.&lt;br /&gt;
&lt;br /&gt;
For a strategy how to synchronize video with brain signal data, and possibly audio data, see [[User_Reference:BCI2000Viewer#AV_Synchronization_Strategies|this page]].&lt;br /&gt;
&lt;br /&gt;
==Troubleshooting==&lt;br /&gt;
You may experience an error code stating that the remote procedure call failed when trying to launch the webcam logger. This is likely a driver issue. To fix this, try rolling back the camera driver in the device manager by following this [https://support.microsoft.com/en-us/windows/camera-doesn-t-work-in-windows-32adb016-b29c-a928-0073-53d31da0dad5 tutorial].&lt;br /&gt;
&lt;br /&gt;
Webcam Driver Error&lt;br /&gt;
&lt;br /&gt;
[[File:WebcamDriverError.png|400px|alt=&amp;quot;Webcam driver error&amp;quot;|Webcam Driver Error]]&lt;br /&gt;
&lt;br /&gt;
Roll Back Driver&lt;br /&gt;
&lt;br /&gt;
[[File:WebcamRollbackDriver.png|400px|alt=&amp;quot;Webcam rollback driver&amp;quot;|Webcam Rollback Driver]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Logging Input]], [[Contributions:Extensions]], [[Programming Reference:Events]], [[User Reference:BCI2000Viewer]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Extension]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:WebcamLogger&amp;diff=12653</id>
		<title>Contributions:WebcamLogger</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:WebcamLogger&amp;diff=12653"/>
		<updated>2026-10-09T11:05:11Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Source Code Revisions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
An extension that records video from one or more webcams to an mp4 file, and stores frame numbers as (event-type) state variables.&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
http://{{SERVERNAME}}/svn/trunk/src/contrib/Extensions/WebcamLogger&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
===Authors===&lt;br /&gt;
*Adam Wilson (adam.wilson@uc.edu) &lt;br /&gt;
*Alexander Belsten (belsten@neurotechcenter.org)&lt;br /&gt;
*Juergen Mellinger (mellinger@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
07/06/2011 - Full commit with support for MSVC and MinGW.&lt;br /&gt;
&lt;br /&gt;
07/13/2011 - Bugfixes&lt;br /&gt;
&lt;br /&gt;
11/28/2018 - Updated openCV library to v2.4.3 for x86/x64 Windows and added functionality for recording from multiple cameras&lt;br /&gt;
&lt;br /&gt;
3/16/2021 - Updated openCV library to v4.5.1 for x86/x64 Windows.&lt;br /&gt;
&lt;br /&gt;
2/2/2022 - Rewrote WebcamLogger to use a helper app that records camera data to a file and allows previewing&lt;br /&gt;
&lt;br /&gt;
2/28/2023 - Added support for Webcam URLs.&lt;br /&gt;
&lt;br /&gt;
10/9/2026 - Replaced WebcamLogger with previous WebcamLogger2, providing Linux and macOS support through ffmpeg&#039;s libAVDevice, dropped helper app&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: --&lt;br /&gt;
*Tested under: 9592&lt;br /&gt;
*Known to compile under: 9592&lt;br /&gt;
*Broken since: 5828 for MinGW&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
==Functional Description==&lt;br /&gt;
For many experiments, visual information about how a subject is behaving during an experiment is desired. This extension acquires video from most webcams, and writes to an MP4 video file. It also records the current frame number as a state variable, so that the video can be synchronized with brain data at sample resolution (max. 1ms). Other options include the ability to overlay the date and time directly on the video (useful for long-term monitoring), and time decimation (i.e., save every Nth frame).&lt;br /&gt;
&lt;br /&gt;
The video file bears the name of the BCI2000 data file, with the extension removed and &amp;lt;tt&amp;gt;_M_video.mp4&amp;lt;/tt&amp;gt; appended where &amp;lt;tt&amp;gt;M&amp;lt;/tt&amp;gt; is the index of the camera in question.&lt;br /&gt;
For the format of the video file, see [[Contributions:WebcamLogger#Format_of_the_Video_File|the notes below]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; This module can also be used to perform screen capture with a virtual screencast webcam driver.&lt;br /&gt;
&lt;br /&gt;
==Integration into BCI2000==&lt;br /&gt;
Compile the extension into your source module by enabling contributed extensions in your CMake configuration. In your root build folder, run &amp;lt;tt&amp;gt;Configure.sh.cmd&amp;lt;/tt&amp;gt; in order to bring up the CMake GUI; there, enable EXTENSIONS_WEBCAMLOGGER.&lt;br /&gt;
&lt;br /&gt;
Once the extension is built into the source module, enable it by starting the source module with the &amp;lt;code&amp;gt;--LogWebcam=1&amp;lt;/code&amp;gt; command line argument.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
Webcams should be installed and configured per the device instructions. On Windows, the Webcam logger uses the Windows Media Foundation (WMF) library for display and saving. Desired resolution may be chosen per webcam, and will be matched agains available resolutions.&lt;br /&gt;
&lt;br /&gt;
Camera options are found in the &#039;&#039;Source&#039;&#039; tab of the Configuration window.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
The Webcam logger is configured in the &#039;&#039;Source&#039;&#039; tab within the WebcamLogger section.  The configurable parameters are:&lt;br /&gt;
&lt;br /&gt;
===LogWebcam===&lt;br /&gt;
Enables/Disables logging of Webcam states.&lt;br /&gt;
===CameraNumber===&lt;br /&gt;
Used to select one camera to record from on systems with multiple cameras. Use value 0 for the default camera.&lt;br /&gt;
===RecordAll===&lt;br /&gt;
Enables the recording of cameras from &amp;lt;code&amp;gt;StartIndex&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;EndIndex&amp;lt;/code&amp;gt;.&lt;br /&gt;
Note that, unlike other indices in BCI2000, camera indices are 0-based rather than 1-based.&lt;br /&gt;
&lt;br /&gt;
===StartIndex===&lt;br /&gt;
Index to start searching for cameras at.&lt;br /&gt;
===EndIndex===&lt;br /&gt;
Index to stop searching for cameras at.&lt;br /&gt;
===Decimation===&lt;br /&gt;
The decimation factor for saving and viewing video; the logger saves/displays every Nth frame.&lt;br /&gt;
===DateTimeLocation===&lt;br /&gt;
The location of the date/time overlay in saved video (0: none, 1: UpperRight, 2: UpperLeft, 3: LowerRight, 4: LowerLeft).&lt;br /&gt;
If &#039;&#039;&#039;DateTimeLocation&#039;&#039;&#039; is 5, the current frame number will be displayed in the upper right corner.&lt;br /&gt;
&lt;br /&gt;
===DisplayStream===&lt;br /&gt;
Display the video stream from each connected camera. Display stream is identical to what is being recorded in the .mp4 file.&lt;br /&gt;
===WebcamFormat===&lt;br /&gt;
For each camera index, you may specify a video width, height, and fps. These are matched against the formats provided by the&lt;br /&gt;
camera, and the closest one is chosen. The &#039;&#039;encoding profile&#039;&#039; column allows you to choose a H.264 encoding profile for video output, which may be a number from 1 to 3. &#039;&#039;&#039;1&#039;&#039;&#039; corresponds to the &amp;quot;baseline&amp;quot; profile, &#039;&#039;&#039;2&#039;&#039;&#039; corresponds to the &amp;quot;main&amp;quot; profile, and &#039;&#039;&#039;3&#039;&#039;&#039; corresponds to the &amp;quot;high&amp;quot; profile as defined in the &#039;&#039;ITU-T H.264&#039;&#039; standard.&lt;br /&gt;
&lt;br /&gt;
===WebcamURL===&lt;br /&gt;
In the first column of the &#039;&#039;WebcamURL&#039;&#039; matrix parameter, you may specify a camera index, and a corresponding URL in the second column. If a URL is given for a certain index, video data will be acquired from the URL rather than a webcam with the specified index attached to the machine.&lt;br /&gt;
&lt;br /&gt;
When reading video data from an URL, only streaming formats supported by the Microsoft Media Foundation library are supported. This includes MPEG4, h.264, and h.265 codecs.&lt;br /&gt;
&lt;br /&gt;
For URL-based video streams, the Microsoft Media Foundation library allows to configure both an initial buffering time (MFNETSOURCE_BUFFERINGTIME), and a maximum buffer-ahead time (MFNETSOURCE_MAXBUFFERTIMEMS). In the &#039;&#039;WebcamURL&#039;&#039; matrix parameter, these are represented by the &#039;&#039;BufferingTime&#039;&#039; and &#039;&#039;MaxBufferTime&#039;&#039; columns. For clarity, these values must be entered as time values with a trailing &amp;quot;s&amp;quot; or &amp;quot;ms&amp;quot;. Note that &#039;&#039;BufferingTime&#039;&#039; will be rounded to full seconds, whereas &#039;&#039;MaxBufferTime&#039;&#039; will be rounded to full milliseconds.&lt;br /&gt;
&lt;br /&gt;
For typical streaming webcams, it seems not possible to obtain a delay below 1s. Also, setting &#039;&#039;MaxBufferTime&#039;&#039; to values below 200ms &lt;br /&gt;
will typically result in unstable connections.&lt;br /&gt;
&lt;br /&gt;
==Event Variables==&lt;br /&gt;
&lt;br /&gt;
===WebcamFrame&amp;lt;0-n&amp;gt;===&lt;br /&gt;
The frame number of the video recorded on camera with index i. i must be less than or equal to n due to the nature of event declarations. The default value of n is 3, allowing for the recording of up to 4 cameras. To record from more cameras, change the &amp;lt;code&amp;gt;NUM_OF_WEBCAM_EVENTS&amp;lt;/code&amp;gt; macro in WebcamLogger.cpp to the number of cameras you want to record from and recompile. Event values can be used to synchronize the video with the recorded neural data. It is a 32-bit value, allowing 4294967295 frames before overflowing. If the webcam can capture at 30 frames/sec, this allows more than four years of video before it will go back to frame 0. In other words, this should not be an issue for most users.&lt;br /&gt;
&lt;br /&gt;
==Format of the Video File==&lt;br /&gt;
Each camera writes its own video file. For most webcams, actual video frame rate may deviate considerably from nominal video frame rate. Also, video frame rate is often not constant but may change over the recording. What makes things even more difficult is that files in mp4 format (and related formats) do not allow to seek to locations that represent original frames when writing the file. Rather, the file&#039;s nominal frame rate and length are used in conjunction with interpolation to construct a frame at an ideal location.&lt;br /&gt;
Thus, it is not possible to write individual frames using the camera&#039;s original timestamp, at the original frame rate.&lt;br /&gt;
&lt;br /&gt;
Instead, the file is written with a simplified framerate as close as possible to the camera&#039;s nominal framerate, with differences between frame timestamps matching ideal frame duration.&lt;br /&gt;
This way, loading the video into e.g. Matlab, you will obtain a sequence of frames where each frame index corresponds to the frame index in the &amp;lt;tt&amp;gt;WebcamFrameN&amp;lt;/tt&amp;gt; state (minus 1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: Do not expect nominal framerate and/or nominal duration of the video file to correspond to the camera&#039;s actual framerate or duration. Also, in case of variable framerate cameras, video display may be jerky when playing back the video in a standard video player such as VLC. This is &#039;&#039;not&#039;&#039; an error but an artifact of how video frames are stored.&lt;br /&gt;
&lt;br /&gt;
For a strategy how to synchronize video with brain signal data, and possibly audio data, see [[User_Reference:BCI2000Viewer#AV_Synchronization_Strategies|this page]].&lt;br /&gt;
&lt;br /&gt;
==Troubleshooting==&lt;br /&gt;
You may experience an error code stating that the remote procedure call failed when trying to launch the webcam logger. This is likely a driver issue. To fix this, try rolling back the camera driver in the device manager by following this [https://support.microsoft.com/en-us/windows/camera-doesn-t-work-in-windows-32adb016-b29c-a928-0073-53d31da0dad5 tutorial].&lt;br /&gt;
&lt;br /&gt;
Webcam Driver Error&lt;br /&gt;
&lt;br /&gt;
[[File:WebcamDriverError.png|400px|alt=&amp;quot;Webcam driver error&amp;quot;|Webcam Driver Error]]&lt;br /&gt;
&lt;br /&gt;
Roll Back Driver&lt;br /&gt;
&lt;br /&gt;
[[File:WebcamRollbackDriver.png|400px|alt=&amp;quot;Webcam rollback driver&amp;quot;|Webcam Rollback Driver]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Logging Input]], [[Contributions:Extensions]], [[Programming Reference:Events]], [[User Reference:BCI2000Viewer]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Extension]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:WebcamLogger&amp;diff=12652</id>
		<title>Contributions:WebcamLogger</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:WebcamLogger&amp;diff=12652"/>
		<updated>2026-10-09T11:04:08Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* Version History */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
An extension that records video from one or more webcams to an mp4 file, and stores frame numbers as (event-type) state variables.&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
http://{{SERVERNAME}}/svn/trunk/src/contrib/Extensions/WebcamLogger&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
===Authors===&lt;br /&gt;
*Adam Wilson (adam.wilson@uc.edu) &lt;br /&gt;
*Alexander Belsten (belsten@neurotechcenter.org)&lt;br /&gt;
*Juergen Mellinger (mellinger@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
07/06/2011 - Full commit with support for MSVC and MinGW.&lt;br /&gt;
&lt;br /&gt;
07/13/2011 - Bugfixes&lt;br /&gt;
&lt;br /&gt;
11/28/2018 - Updated openCV library to v2.4.3 for x86/x64 Windows and added functionality for recording from multiple cameras&lt;br /&gt;
&lt;br /&gt;
3/16/2021 - Updated openCV library to v4.5.1 for x86/x64 Windows.&lt;br /&gt;
&lt;br /&gt;
2/2/2022 - Rewrote WebcamLogger to use a helper app that records camera data to a file and allows previewing&lt;br /&gt;
&lt;br /&gt;
2/28/2023 - Added support for Webcam URLs.&lt;br /&gt;
&lt;br /&gt;
10/9/2026 - Replaced WebcamLogger with previous WebcamLogger2, providing Linux and macOS support through ffmpeg&#039;s libAVDevice, dropped helper app&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: --&lt;br /&gt;
*Tested under: 7227&lt;br /&gt;
*Known to compile under: 7227&lt;br /&gt;
*Broken since: 5828 for MinGW&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
==Functional Description==&lt;br /&gt;
For many experiments, visual information about how a subject is behaving during an experiment is desired. This extension acquires video from most webcams, and writes to an MP4 video file. It also records the current frame number as a state variable, so that the video can be synchronized with brain data at sample resolution (max. 1ms). Other options include the ability to overlay the date and time directly on the video (useful for long-term monitoring), and time decimation (i.e., save every Nth frame).&lt;br /&gt;
&lt;br /&gt;
The video file bears the name of the BCI2000 data file, with the extension removed and &amp;lt;tt&amp;gt;_M_video.mp4&amp;lt;/tt&amp;gt; appended where &amp;lt;tt&amp;gt;M&amp;lt;/tt&amp;gt; is the index of the camera in question.&lt;br /&gt;
For the format of the video file, see [[Contributions:WebcamLogger#Format_of_the_Video_File|the notes below]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; This module can also be used to perform screen capture with a virtual screencast webcam driver.&lt;br /&gt;
&lt;br /&gt;
==Integration into BCI2000==&lt;br /&gt;
Compile the extension into your source module by enabling contributed extensions in your CMake configuration. In your root build folder, run &amp;lt;tt&amp;gt;Configure.sh.cmd&amp;lt;/tt&amp;gt; in order to bring up the CMake GUI; there, enable EXTENSIONS_WEBCAMLOGGER.&lt;br /&gt;
&lt;br /&gt;
Once the extension is built into the source module, enable it by starting the source module with the &amp;lt;code&amp;gt;--LogWebcam=1&amp;lt;/code&amp;gt; command line argument.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
Webcams should be installed and configured per the device instructions. On Windows, the Webcam logger uses the Windows Media Foundation (WMF) library for display and saving. Desired resolution may be chosen per webcam, and will be matched agains available resolutions.&lt;br /&gt;
&lt;br /&gt;
Camera options are found in the &#039;&#039;Source&#039;&#039; tab of the Configuration window.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
The Webcam logger is configured in the &#039;&#039;Source&#039;&#039; tab within the WebcamLogger section.  The configurable parameters are:&lt;br /&gt;
&lt;br /&gt;
===LogWebcam===&lt;br /&gt;
Enables/Disables logging of Webcam states.&lt;br /&gt;
===CameraNumber===&lt;br /&gt;
Used to select one camera to record from on systems with multiple cameras. Use value 0 for the default camera.&lt;br /&gt;
===RecordAll===&lt;br /&gt;
Enables the recording of cameras from &amp;lt;code&amp;gt;StartIndex&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;EndIndex&amp;lt;/code&amp;gt;.&lt;br /&gt;
Note that, unlike other indices in BCI2000, camera indices are 0-based rather than 1-based.&lt;br /&gt;
&lt;br /&gt;
===StartIndex===&lt;br /&gt;
Index to start searching for cameras at.&lt;br /&gt;
===EndIndex===&lt;br /&gt;
Index to stop searching for cameras at.&lt;br /&gt;
===Decimation===&lt;br /&gt;
The decimation factor for saving and viewing video; the logger saves/displays every Nth frame.&lt;br /&gt;
===DateTimeLocation===&lt;br /&gt;
The location of the date/time overlay in saved video (0: none, 1: UpperRight, 2: UpperLeft, 3: LowerRight, 4: LowerLeft).&lt;br /&gt;
If &#039;&#039;&#039;DateTimeLocation&#039;&#039;&#039; is 5, the current frame number will be displayed in the upper right corner.&lt;br /&gt;
&lt;br /&gt;
===DisplayStream===&lt;br /&gt;
Display the video stream from each connected camera. Display stream is identical to what is being recorded in the .mp4 file.&lt;br /&gt;
===WebcamFormat===&lt;br /&gt;
For each camera index, you may specify a video width, height, and fps. These are matched against the formats provided by the&lt;br /&gt;
camera, and the closest one is chosen. The &#039;&#039;encoding profile&#039;&#039; column allows you to choose a H.264 encoding profile for video output, which may be a number from 1 to 3. &#039;&#039;&#039;1&#039;&#039;&#039; corresponds to the &amp;quot;baseline&amp;quot; profile, &#039;&#039;&#039;2&#039;&#039;&#039; corresponds to the &amp;quot;main&amp;quot; profile, and &#039;&#039;&#039;3&#039;&#039;&#039; corresponds to the &amp;quot;high&amp;quot; profile as defined in the &#039;&#039;ITU-T H.264&#039;&#039; standard.&lt;br /&gt;
&lt;br /&gt;
===WebcamURL===&lt;br /&gt;
In the first column of the &#039;&#039;WebcamURL&#039;&#039; matrix parameter, you may specify a camera index, and a corresponding URL in the second column. If a URL is given for a certain index, video data will be acquired from the URL rather than a webcam with the specified index attached to the machine.&lt;br /&gt;
&lt;br /&gt;
When reading video data from an URL, only streaming formats supported by the Microsoft Media Foundation library are supported. This includes MPEG4, h.264, and h.265 codecs.&lt;br /&gt;
&lt;br /&gt;
For URL-based video streams, the Microsoft Media Foundation library allows to configure both an initial buffering time (MFNETSOURCE_BUFFERINGTIME), and a maximum buffer-ahead time (MFNETSOURCE_MAXBUFFERTIMEMS). In the &#039;&#039;WebcamURL&#039;&#039; matrix parameter, these are represented by the &#039;&#039;BufferingTime&#039;&#039; and &#039;&#039;MaxBufferTime&#039;&#039; columns. For clarity, these values must be entered as time values with a trailing &amp;quot;s&amp;quot; or &amp;quot;ms&amp;quot;. Note that &#039;&#039;BufferingTime&#039;&#039; will be rounded to full seconds, whereas &#039;&#039;MaxBufferTime&#039;&#039; will be rounded to full milliseconds.&lt;br /&gt;
&lt;br /&gt;
For typical streaming webcams, it seems not possible to obtain a delay below 1s. Also, setting &#039;&#039;MaxBufferTime&#039;&#039; to values below 200ms &lt;br /&gt;
will typically result in unstable connections.&lt;br /&gt;
&lt;br /&gt;
==Event Variables==&lt;br /&gt;
&lt;br /&gt;
===WebcamFrame&amp;lt;0-n&amp;gt;===&lt;br /&gt;
The frame number of the video recorded on camera with index i. i must be less than or equal to n due to the nature of event declarations. The default value of n is 3, allowing for the recording of up to 4 cameras. To record from more cameras, change the &amp;lt;code&amp;gt;NUM_OF_WEBCAM_EVENTS&amp;lt;/code&amp;gt; macro in WebcamLogger.cpp to the number of cameras you want to record from and recompile. Event values can be used to synchronize the video with the recorded neural data. It is a 32-bit value, allowing 4294967295 frames before overflowing. If the webcam can capture at 30 frames/sec, this allows more than four years of video before it will go back to frame 0. In other words, this should not be an issue for most users.&lt;br /&gt;
&lt;br /&gt;
==Format of the Video File==&lt;br /&gt;
Each camera writes its own video file. For most webcams, actual video frame rate may deviate considerably from nominal video frame rate. Also, video frame rate is often not constant but may change over the recording. What makes things even more difficult is that files in mp4 format (and related formats) do not allow to seek to locations that represent original frames when writing the file. Rather, the file&#039;s nominal frame rate and length are used in conjunction with interpolation to construct a frame at an ideal location.&lt;br /&gt;
Thus, it is not possible to write individual frames using the camera&#039;s original timestamp, at the original frame rate.&lt;br /&gt;
&lt;br /&gt;
Instead, the file is written with a simplified framerate as close as possible to the camera&#039;s nominal framerate, with differences between frame timestamps matching ideal frame duration.&lt;br /&gt;
This way, loading the video into e.g. Matlab, you will obtain a sequence of frames where each frame index corresponds to the frame index in the &amp;lt;tt&amp;gt;WebcamFrameN&amp;lt;/tt&amp;gt; state (minus 1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: Do not expect nominal framerate and/or nominal duration of the video file to correspond to the camera&#039;s actual framerate or duration. Also, in case of variable framerate cameras, video display may be jerky when playing back the video in a standard video player such as VLC. This is &#039;&#039;not&#039;&#039; an error but an artifact of how video frames are stored.&lt;br /&gt;
&lt;br /&gt;
For a strategy how to synchronize video with brain signal data, and possibly audio data, see [[User_Reference:BCI2000Viewer#AV_Synchronization_Strategies|this page]].&lt;br /&gt;
&lt;br /&gt;
==Troubleshooting==&lt;br /&gt;
You may experience an error code stating that the remote procedure call failed when trying to launch the webcam logger. This is likely a driver issue. To fix this, try rolling back the camera driver in the device manager by following this [https://support.microsoft.com/en-us/windows/camera-doesn-t-work-in-windows-32adb016-b29c-a928-0073-53d31da0dad5 tutorial].&lt;br /&gt;
&lt;br /&gt;
Webcam Driver Error&lt;br /&gt;
&lt;br /&gt;
[[File:WebcamDriverError.png|400px|alt=&amp;quot;Webcam driver error&amp;quot;|Webcam Driver Error]]&lt;br /&gt;
&lt;br /&gt;
Roll Back Driver&lt;br /&gt;
&lt;br /&gt;
[[File:WebcamRollbackDriver.png|400px|alt=&amp;quot;Webcam rollback driver&amp;quot;|Webcam Rollback Driver]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Logging Input]], [[Contributions:Extensions]], [[Programming Reference:Events]], [[User Reference:BCI2000Viewer]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Extension]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12620</id>
		<title>Programming Reference:BCI2000Remote Class</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12620"/>
		<updated>2026-10-08T17:31:51Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* bool ShowParameterJson( string name, string&amp;amp; json ) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends [[User Reference:Operator Module Scripting|Operator Scripting commands]] to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the [[#BCI2000RemoteLib|BCI2000RemoteLib]] library exist, such as Python, or MATLAB through the &amp;lt;tt&amp;gt;loadlibrary&amp;lt;/tt&amp;gt; command, specifying &amp;lt;tt&amp;gt;src/core/Operator/BCI2000Remote/BCI2000RemoteLib.h&amp;lt;/tt&amp;gt; as the header file associated with the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--For controlling BCI2000 under Windows from MATLAB, Windows Automation compatible scripting languages, or .NET languages, there exists a separate [[Contributions:BCI2000Automation|automation interface]].--&amp;gt;&lt;br /&gt;
For controlling BCI2000 from shell scripts (such as the Windows command interpreter, or Unix shells like bash), there exists a [[Contributions:BCI2000Command|BCI2000 command executable]] and the [[User_Reference:BCI2000Shell|BCI2000Shell]].&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
BCI2000/src/core/Operator/BCI2000Remote&lt;br /&gt;
&lt;br /&gt;
==Functional Description==&lt;br /&gt;
After instantiating a BCI2000Remote object, set its OperatorPath property to point to the desired BCI2000 Operator module. Then, call its Connect() method to start up that module, and connect to it. You may then use the StartupModules() method in order to start up BCI2000 core modules.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you may specify the path to a BCI2000 batch file in the BCI2000/batch directory. An appropriate batch file should start up Operator and core modules, and needs to forward its command line arguments to the Operator module. All batch files coming with BCI2000 fulfill this condition. When a batch file is specified, there is no need to call the StartupModules() method.&lt;br /&gt;
&lt;br /&gt;
As yet another option, you may connect to an Operator module that is already running, e.g., on a remote machine on the network. In this case, set the BCI2000Remote object&#039;s OperatorPath property to an empty string, and its TelnetAddress property to the address that the remote Operator module is listening on, i.e. the remote machine&#039;s IP address, followed with a colon, and the port specified when starting up the remote Operator module. The remote Operator module must have been started with the &amp;quot;--Telnet&amp;quot; command line option, followed with the address to listen on. On the remote machine, this would typically be &amp;quot;localhost:3999&amp;quot;. Don&#039;t use any of the ports between 4000 and 4002, as this will interfere with the communication between the Operator module, and BCI2000 core modules. Depending on whether the remote Operator module has been started up together with its core modules, or not, you may then call the StartupModules() method in order to start up BCI2000 core modules on the remote machine.&lt;br /&gt;
&lt;br /&gt;
Once all BCI2000 modules are running, you may load parameter files locally or remotely using the LoadParametersLocal() and LoadParametersRemote() methods. Subject ID, Session ID, and data directory are set using the respective BCI2000Remote properties.&lt;br /&gt;
&lt;br /&gt;
A recording may then be started by calling the Start() method. Depending on configuration, the recording will terminate automatically, or needs to be terminated by a call to the Stop() method.&lt;br /&gt;
&lt;br /&gt;
To run BCI2000 in a different configuration (i.e., with different core modules), it is not necessary to terminate the Operator module. Rather, you may execute StartupModules() multiple times in order to terminate currently running core modules, and start different ones.&lt;br /&gt;
&lt;br /&gt;
Once you are done using BCI2000, you may close the connection by calling the Disconnect() method, or by deleting the BCI2000Remote object. Depending on whether the Operator module was started up by the previous Connect() call, this will terminate the Operator module as well. When connection was made to an already running Operator module, local or remote, the connection will be closed but the Operator module will remain running.&lt;br /&gt;
&lt;br /&gt;
==BCI2000Remote Members==&lt;br /&gt;
The BCI2000Remote class has the following members:&lt;br /&gt;
===Properties===&lt;br /&gt;
====double Timeout=5 (rw)====&lt;br /&gt;
Timeout in seconds. Applies when establishing communication between BCI2000Remote and BCI2000.&lt;br /&gt;
&lt;br /&gt;
====string OperatorPath=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Path to Operator module, or batch file. When empty, BCI2000Remote tries to connect to an already running Operator module which may be on a different machine, depending on the &#039;&#039;TelnetAddress&#039;&#039; setting. When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module.&lt;br /&gt;
&lt;br /&gt;
====string TelnetAddress=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Telnet address to use for connection to a remote machine. To connect to a remote machine, specify the machine&#039;s IP address, followed with BCI2000&#039;s listening port. You should take care to avoid specifying a port that is used by BCI2000&#039;s internal connections between Operator and core modules. By default, these are 4000, 4001, and 4002.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module. This is preferable for security reasons.&lt;br /&gt;
&lt;br /&gt;
=====bool WindowVisible=2 (rw)=====&lt;br /&gt;
Visibility of the BCI2000 main window. 0: Invisible, 1: visible, 2: don&#039;t change.&lt;br /&gt;
&lt;br /&gt;
====string WindowTitle (rw)====&lt;br /&gt;
The title of the BCI2000 main window.&lt;br /&gt;
====string Result (r)====&lt;br /&gt;
Text output of the previously executed command, or an error message when the previously executed command failed.&lt;br /&gt;
====Recording information====&lt;br /&gt;
=====string SubjectID (rw)=====&lt;br /&gt;
The subject ID for the next recording. When this property is empty, the subject ID is taken from the current value of the SubjectName parameter.&lt;br /&gt;
=====string SessionID (rw)=====&lt;br /&gt;
The session ID for the next recording. When this property is empty, the session ID is taken from the SubjectSession parameter.&lt;br /&gt;
=====string DataDirectory (rw)=====&lt;br /&gt;
The data directory for the next recording. When a relative path is given, it is taken relative to BCI2000/data. When this property is empty, the data directory is taken from the DataDirectory parameter.&lt;br /&gt;
&lt;br /&gt;
===Connection methods===&lt;br /&gt;
====bool Connect()====&lt;br /&gt;
Connect to BCI2000. When OperatorPath is not empty, and no operator module is listening at TelnetAddress, this starts up the operator module before connecting. Will return true on success.&lt;br /&gt;
&lt;br /&gt;
====bool Connect( BCI2000Remote )====&lt;br /&gt;
Connects to the same Operator module as the BCI2000Remote instance given as an argument. This will not start BCI2000 when it is not running, thus it is necessary that the argument instance&#039;s Connect() method has been called before.&lt;br /&gt;
&lt;br /&gt;
====bool Disconnect()====&lt;br /&gt;
Disconnect from an existing connection. Terminates the running operator module if it was started by the previous Connect() call.&lt;br /&gt;
&lt;br /&gt;
===Control of operation===&lt;br /&gt;
====bool StartupModules( vector(string) modules )====&lt;br /&gt;
Start BCI2000 core modules, listed by executable name, including possible command line arguments. Each entry in the array corresponds to a single core module, given relative to the Operator module&#039;s working directory, which defaults to BCI2000/prog. You do not need to call this function if the OperatorPath property specifies a batch file rather than the Operator module itself.&lt;br /&gt;
====bool SetConfig()====&lt;br /&gt;
Applies the current set of parameters. Will be called from Start() automatically. Returns false if parameters could not be set, e.g. because the system was in running state, or because there was a preflight error when applying parameters. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Start()====&lt;br /&gt;
Starts a new run (recording) with current parameters. Returns false if the run could not be started. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Stop()====&lt;br /&gt;
Stops the current run (recording).&lt;br /&gt;
&lt;br /&gt;
===Parameters and system state===&lt;br /&gt;
====bool GetParameter( string name, string&amp;amp; value )====&lt;br /&gt;
Copies the specified parameter&#039;s value into the &#039;&#039;value&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
====bool SetParameter( string name, string value )====&lt;br /&gt;
Sets the specified parameter to the given value. The parameter must exist in the system. To add a parameter, use the Execute() method in conjunction with the [[User Reference:Operator Module Scripting#ADD &amp;amp;#91;JSON&amp;amp;#93 PARAMETER &amp;lt;parameter definition&amp;gt;|ADD PARAMETER]] scripting command.&lt;br /&gt;
&lt;br /&gt;
====bool ShowParameterJson( string name, string&amp;amp; json )====&lt;br /&gt;
Copies the specified parameter into the &#039;&#039;json&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
The parameter definition is provided in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
====bool PutParameterJson( string json )====&lt;br /&gt;
Constructs a parameter from the given JSON representation, and applies it to the parameter list.&lt;br /&gt;
The parameter must exist in the system. To add a parameter, use the Execute() method in conjunction with the [[User Reference:Operator Module Scripting#ADD &amp;amp;#91;JSON&amp;amp;#93; PARAMETER &amp;lt;parameter definition&amp;gt;|ADD JSON PARAMETER]] scripting command.&lt;br /&gt;
&lt;br /&gt;
The parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
====bool LoadParametersLocal( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the calling application. This function returns false if the specified file was not found but will not provide information whether parameters were sent successfully. Rather, illegal parameter lines will be silently ignored.&lt;br /&gt;
====bool LoadParametersRemote( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the Operator module connected to. Unless explicitly changed, that working directory is the BCI2000/prog directory in which the Operator module resides.&lt;br /&gt;
&lt;br /&gt;
====bool AddStateVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds a [[Technical_Reference:State_Definition|state variable]] to the system. This is only possible before core modules have connected to the Operator module.&lt;br /&gt;
State variables added by &#039;&#039;AddStateVariable()&#039;&#039; are plain state variables (i.e., not event or stream state variables).&lt;br /&gt;
&lt;br /&gt;
====bool GetStateVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 state variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
&#039;&#039;GetStateVariable()&#039;&#039; will retrieve values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool SetStateVariable( string name, double value )====&lt;br /&gt;
Sets the value of the named BCI2000 state variable to the given value. Returns false on error.&lt;br /&gt;
&#039;&#039;SetStateVariable()&#039;&#039; can set values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool AddEventVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds an [[Technical_Reference:State_Definition#Events|event variable]] to the system. This is only possible before core modules have connected to the Operator module.	&lt;br /&gt;
====bool GetEventVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 event variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
====bool SetEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value. Returns false on error.&lt;br /&gt;
====bool PulseEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value, for the duration of a single sample.&lt;br /&gt;
Returns false on error.&lt;br /&gt;
&lt;br /&gt;
====bool GetSystemState( string&amp;amp; state )====&lt;br /&gt;
Gets the current system state (i.e., state of operation). If no error occurred, the &amp;quot;state&amp;quot; output variable will contain the name of the current system state, which will be one of the names listed at [[User Reference:Operator Module Scripting#GET_SYSTEM_STATE]].&lt;br /&gt;
====bool GetControlSignalChannels( double&amp;amp; channels )====&lt;br /&gt;
Copies the number of control signal channels into the &amp;quot;channels&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignalElements( double&amp;amp; elements )====&lt;br /&gt;
Copies the number of control signal elements into the &amp;quot;elements&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignal( int channel, int element, double&amp;amp; value )====&lt;br /&gt;
Copies the value of the control signal at the given indices into the &amp;quot;value&amp;quot; output variable. Indices are 1-based. Typically, the control signal has only a single element, and the number of output channels corresponds to the number of feedback dimensions in feedback experiments, or is 1 in evoked potential experiments.&lt;br /&gt;
&lt;br /&gt;
===Scripting methods===&lt;br /&gt;
====bool Execute( string command, int* exitCode = 0 )====&lt;br /&gt;
Execute an arbitrary BCI2000 scripting command. A return value of &amp;quot;true&amp;quot; does not indicate successful execution of the command; rather, it indicates that the command was sent, and its result was received. In general, the &#039;&#039;&#039;Result&#039;&#039;&#039; property needs to be examined in order to determine whether the command was executed successfully.&lt;br /&gt;
&lt;br /&gt;
In many cases, the optional &#039;&#039;exitCode&#039;&#039; argument may be specified to obtain the result status of a command in an integer variable that the &#039;&#039;exitCode&#039;&#039; pointer points to.&lt;br /&gt;
The exact meaning of the exit code depends on the command that has been executed, so it is necessary to be aware of a command&#039;s possible responses before evaluating an exit code.&lt;br /&gt;
&lt;br /&gt;
In detail, the exit code is determined as follows:&lt;br /&gt;
* When Execute() is used to execute a SYSTEM command, the exit code will match the exit code of the program that was run through the SYSTEM command. By convention, such exit codes are nonzero on failure, and zero on success.&lt;br /&gt;
* For other commands, the exit code is derived from the &#039;&#039;&#039;Result&#039;&#039;&#039; property as follows:&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; may be interpreted as a single floating point number, the exit code will be 0 for a nonzero number, and 1 if the number is zero.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot; (without considering case), the exit code will be 0 for &amp;quot;true&amp;quot;, and 1 for &amp;quot;false&amp;quot;.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is empty, the exit code will be 0.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; does not match any of the previous conditions, the exit code will be -1 to indicate that there was no obvious interpretation.&lt;br /&gt;
&lt;br /&gt;
This scheme is chosen to simplify client code for the most common cases:&lt;br /&gt;
* external programs run through the SYSTEM command,&lt;br /&gt;
* commands which do not have an output except in case of failure,&lt;br /&gt;
* functions returning binary values, such as the test command,&lt;br /&gt;
* expressions evaluated as logical conditions.&lt;br /&gt;
In all these cases, the exit code will be 0 on success, and 1 on failure.&lt;br /&gt;
&lt;br /&gt;
When executing a command that may return an arbitrary string (e.g., EXECUTE SCRIPT, or ECHO), the exit code should not be used. In this case, the &#039;&#039;exitCode&#039;&#039; argument may be omitted, or may be NULL.&lt;br /&gt;
&lt;br /&gt;
A full documentation of BCI2000 Operator scripting commands is available under [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
====bool SetScript( string handlers, string script )====&lt;br /&gt;
Associate a sequence of BCI2000 scripting commands with the specified events. Events are given by name, as defined in the [[User Reference:Operator Module Scripting|scripting reference]]. Multiple handler names may be specified, concatenated with a pipe &#039;|&#039; character.&lt;br /&gt;
&lt;br /&gt;
====bool GetScript( string handler, string&amp;amp; script )====&lt;br /&gt;
Copy the handler script into the &#039;&#039;script&#039;&#039; output variable.&lt;br /&gt;
&lt;br /&gt;
===Watches===&lt;br /&gt;
====Watch* NewWatch( string expression, WatchCallback, void* callbackData )====&lt;br /&gt;
Creates a new watch object that watches on the expression or expressions given, and calls the specified callback each time the expression value changes. CallbackData is arbitrary user data (e.g., a pointer to an object) required for processing the callback.&lt;br /&gt;
If multiple expressions are given, they must be separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
The watch object may be disposed of by calling an ordinary delete.&lt;br /&gt;
&lt;br /&gt;
====void WatchCallback( void* callbackData, const char* values )====&lt;br /&gt;
Signature of a user-defined callback function that receives expression values, along with the arbitrary user data stored in callbackData. The values string starts with millisecond timestamp, followed with one value for each expression, and a trailing CRLF. Values are separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
To facilitate the use of BCI2000Remote, it only depends on very few files from the BCI2000 framework. To use BCI2000Remote in a C++ project, you will need to add the following cpp files to the project, and their parent directories to the list of include paths:&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Remote.cpp&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Connection.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SockStream.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SelfPipe.cpp&lt;br /&gt;
Also, on Windows you will need to link against this additional library:&lt;br /&gt;
 WS2_32&lt;br /&gt;
&lt;br /&gt;
==[[Technical Reference:BCI2000Remote Library|BCI2000RemoteLib]]==&lt;br /&gt;
The BCI2000RemoteLib is a dynamic library that exports a C-style wrapper around the BCI2000Remote class, such that it may be used from scripting languages that support execution of library code. A C-style wrapper is required because no stable conventions exist regarding the export of classes and objects from dynamic libraries.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote member functions are directly mapped on C functions by adding an object handle as a first argument, and by replacing &amp;lt;tt&amp;gt;std::string&amp;lt;/tt&amp;gt; arguments with C string arguments. To instantiate a BCI2000Remote object, and obtain an object handle, call &amp;lt;tt&amp;gt;BCI2000Remote_New()&amp;lt;/tt&amp;gt;; specify this handle as a first argument to any BCI2000Remote member function you would like to call, and finally delete the object by specifying its handle as an argument to &amp;lt;tt&amp;gt;BCI2000Remote_Delete()&amp;lt;/tt&amp;gt;. An object handle should always be treated as an opaque reference, and never be cast to a pointer of type &amp;lt;tt&amp;gt;BCI2000Remote*&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Similarly, &amp;lt;tt&amp;gt;BCI20000Remote_NewWatch()&amp;lt;/tt&amp;gt; returns a reference to a watch object as a &amp;lt;tt&amp;gt;void*&amp;lt;/tt&amp;gt;. Once you are done with the watch object, call &amp;lt;tt&amp;gt;BCI2000Remote_DeleteWatch()&amp;lt;/tt&amp;gt; to dispose of it.&lt;br /&gt;
&lt;br /&gt;
Any function that returns a C string as a &amp;lt;tt&amp;gt;const char*&amp;lt;/tt&amp;gt; may return a zero pointer, indicating failure, or a valid pointer to a C string, indicating success. If a valid pointer is returned, the associated memory has been allocated by the library, and will be invalidated by the next call to a C string returning function. Earlier versions of BCI2000RemoteLib required to call &amp;lt;tt&amp;gt;BCI2000Release()&amp;lt;/tt&amp;gt; after receiving a C string. This is no longer the case. Instead, the memory allocated for the C string is deallocated on the next call that returns a C string.&lt;br /&gt;
&lt;br /&gt;
==Python Variations==&lt;br /&gt;
There is a wrapper to BCI2000RemoteLib in Python, which lets you call functions that are very similar to the BCI2000Remote class. Most of the members are documented above, however the syntax is different for some. There are a couple new functions as well, all of which will be highlighted here.&lt;br /&gt;
===Get &amp;lt;Variable&amp;gt;===&lt;br /&gt;
For the &amp;quot;Get&amp;quot; functions (e.g., GetState, GetParameter, GetEvent), instead of passing a variable by reference, the return value is set to the desired variable (e.g., the state, parameter, event). For example, the syntax is &amp;lt;code&amp;gt; state = bci.GetStateVariable(&amp;quot;StimulusCode&amp;quot;) &amp;lt;/code&amp;gt;, where &amp;lt;code&amp;gt;state&amp;lt;/code&amp;gt; is a c_double that is the value of the state.&lt;br /&gt;
===Additional functions===&lt;br /&gt;
*&amp;lt;b&amp;gt;Quit()&amp;lt;/b&amp;gt;: quits the system&lt;br /&gt;
*&amp;lt;b&amp;gt;GetListParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a list, this returns an array of the parameter values in the list&lt;br /&gt;
*&amp;lt;b&amp;gt;GetMatrixParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a matrix, this returns a 2d array of the matrix&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
See the [[User Tutorial:BCI2000Remote|user tutorial page]] for C++, Matlab, and Python examples!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Tutorial:BCI2000Remote]], &amp;lt;!--[[Contributions:BCI2000Automation]],--&amp;gt; [[Contributions:BCI2000PresentationLink]], [[Contributions:BCI2000Command]], [[Contributions:BCI2000PythonBindings]], [[Contributions:Applications]]&lt;br /&gt;
&lt;br /&gt;
[[Category:External Interfaces]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12619</id>
		<title>Programming Reference:BCI2000Remote Class</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12619"/>
		<updated>2026-10-08T17:31:31Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* bool PutParameterJson( string json ) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends [[User Reference:Operator Module Scripting|Operator Scripting commands]] to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the [[#BCI2000RemoteLib|BCI2000RemoteLib]] library exist, such as Python, or MATLAB through the &amp;lt;tt&amp;gt;loadlibrary&amp;lt;/tt&amp;gt; command, specifying &amp;lt;tt&amp;gt;src/core/Operator/BCI2000Remote/BCI2000RemoteLib.h&amp;lt;/tt&amp;gt; as the header file associated with the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--For controlling BCI2000 under Windows from MATLAB, Windows Automation compatible scripting languages, or .NET languages, there exists a separate [[Contributions:BCI2000Automation|automation interface]].--&amp;gt;&lt;br /&gt;
For controlling BCI2000 from shell scripts (such as the Windows command interpreter, or Unix shells like bash), there exists a [[Contributions:BCI2000Command|BCI2000 command executable]] and the [[User_Reference:BCI2000Shell|BCI2000Shell]].&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
BCI2000/src/core/Operator/BCI2000Remote&lt;br /&gt;
&lt;br /&gt;
==Functional Description==&lt;br /&gt;
After instantiating a BCI2000Remote object, set its OperatorPath property to point to the desired BCI2000 Operator module. Then, call its Connect() method to start up that module, and connect to it. You may then use the StartupModules() method in order to start up BCI2000 core modules.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you may specify the path to a BCI2000 batch file in the BCI2000/batch directory. An appropriate batch file should start up Operator and core modules, and needs to forward its command line arguments to the Operator module. All batch files coming with BCI2000 fulfill this condition. When a batch file is specified, there is no need to call the StartupModules() method.&lt;br /&gt;
&lt;br /&gt;
As yet another option, you may connect to an Operator module that is already running, e.g., on a remote machine on the network. In this case, set the BCI2000Remote object&#039;s OperatorPath property to an empty string, and its TelnetAddress property to the address that the remote Operator module is listening on, i.e. the remote machine&#039;s IP address, followed with a colon, and the port specified when starting up the remote Operator module. The remote Operator module must have been started with the &amp;quot;--Telnet&amp;quot; command line option, followed with the address to listen on. On the remote machine, this would typically be &amp;quot;localhost:3999&amp;quot;. Don&#039;t use any of the ports between 4000 and 4002, as this will interfere with the communication between the Operator module, and BCI2000 core modules. Depending on whether the remote Operator module has been started up together with its core modules, or not, you may then call the StartupModules() method in order to start up BCI2000 core modules on the remote machine.&lt;br /&gt;
&lt;br /&gt;
Once all BCI2000 modules are running, you may load parameter files locally or remotely using the LoadParametersLocal() and LoadParametersRemote() methods. Subject ID, Session ID, and data directory are set using the respective BCI2000Remote properties.&lt;br /&gt;
&lt;br /&gt;
A recording may then be started by calling the Start() method. Depending on configuration, the recording will terminate automatically, or needs to be terminated by a call to the Stop() method.&lt;br /&gt;
&lt;br /&gt;
To run BCI2000 in a different configuration (i.e., with different core modules), it is not necessary to terminate the Operator module. Rather, you may execute StartupModules() multiple times in order to terminate currently running core modules, and start different ones.&lt;br /&gt;
&lt;br /&gt;
Once you are done using BCI2000, you may close the connection by calling the Disconnect() method, or by deleting the BCI2000Remote object. Depending on whether the Operator module was started up by the previous Connect() call, this will terminate the Operator module as well. When connection was made to an already running Operator module, local or remote, the connection will be closed but the Operator module will remain running.&lt;br /&gt;
&lt;br /&gt;
==BCI2000Remote Members==&lt;br /&gt;
The BCI2000Remote class has the following members:&lt;br /&gt;
===Properties===&lt;br /&gt;
====double Timeout=5 (rw)====&lt;br /&gt;
Timeout in seconds. Applies when establishing communication between BCI2000Remote and BCI2000.&lt;br /&gt;
&lt;br /&gt;
====string OperatorPath=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Path to Operator module, or batch file. When empty, BCI2000Remote tries to connect to an already running Operator module which may be on a different machine, depending on the &#039;&#039;TelnetAddress&#039;&#039; setting. When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module.&lt;br /&gt;
&lt;br /&gt;
====string TelnetAddress=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Telnet address to use for connection to a remote machine. To connect to a remote machine, specify the machine&#039;s IP address, followed with BCI2000&#039;s listening port. You should take care to avoid specifying a port that is used by BCI2000&#039;s internal connections between Operator and core modules. By default, these are 4000, 4001, and 4002.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module. This is preferable for security reasons.&lt;br /&gt;
&lt;br /&gt;
=====bool WindowVisible=2 (rw)=====&lt;br /&gt;
Visibility of the BCI2000 main window. 0: Invisible, 1: visible, 2: don&#039;t change.&lt;br /&gt;
&lt;br /&gt;
====string WindowTitle (rw)====&lt;br /&gt;
The title of the BCI2000 main window.&lt;br /&gt;
====string Result (r)====&lt;br /&gt;
Text output of the previously executed command, or an error message when the previously executed command failed.&lt;br /&gt;
====Recording information====&lt;br /&gt;
=====string SubjectID (rw)=====&lt;br /&gt;
The subject ID for the next recording. When this property is empty, the subject ID is taken from the current value of the SubjectName parameter.&lt;br /&gt;
=====string SessionID (rw)=====&lt;br /&gt;
The session ID for the next recording. When this property is empty, the session ID is taken from the SubjectSession parameter.&lt;br /&gt;
=====string DataDirectory (rw)=====&lt;br /&gt;
The data directory for the next recording. When a relative path is given, it is taken relative to BCI2000/data. When this property is empty, the data directory is taken from the DataDirectory parameter.&lt;br /&gt;
&lt;br /&gt;
===Connection methods===&lt;br /&gt;
====bool Connect()====&lt;br /&gt;
Connect to BCI2000. When OperatorPath is not empty, and no operator module is listening at TelnetAddress, this starts up the operator module before connecting. Will return true on success.&lt;br /&gt;
&lt;br /&gt;
====bool Connect( BCI2000Remote )====&lt;br /&gt;
Connects to the same Operator module as the BCI2000Remote instance given as an argument. This will not start BCI2000 when it is not running, thus it is necessary that the argument instance&#039;s Connect() method has been called before.&lt;br /&gt;
&lt;br /&gt;
====bool Disconnect()====&lt;br /&gt;
Disconnect from an existing connection. Terminates the running operator module if it was started by the previous Connect() call.&lt;br /&gt;
&lt;br /&gt;
===Control of operation===&lt;br /&gt;
====bool StartupModules( vector(string) modules )====&lt;br /&gt;
Start BCI2000 core modules, listed by executable name, including possible command line arguments. Each entry in the array corresponds to a single core module, given relative to the Operator module&#039;s working directory, which defaults to BCI2000/prog. You do not need to call this function if the OperatorPath property specifies a batch file rather than the Operator module itself.&lt;br /&gt;
====bool SetConfig()====&lt;br /&gt;
Applies the current set of parameters. Will be called from Start() automatically. Returns false if parameters could not be set, e.g. because the system was in running state, or because there was a preflight error when applying parameters. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Start()====&lt;br /&gt;
Starts a new run (recording) with current parameters. Returns false if the run could not be started. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Stop()====&lt;br /&gt;
Stops the current run (recording).&lt;br /&gt;
&lt;br /&gt;
===Parameters and system state===&lt;br /&gt;
====bool GetParameter( string name, string&amp;amp; value )====&lt;br /&gt;
Copies the specified parameter&#039;s value into the &#039;&#039;value&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
====bool SetParameter( string name, string value )====&lt;br /&gt;
Sets the specified parameter to the given value. The parameter must exist in the system. To add a parameter, use the Execute() method in conjunction with the [[User Reference:Operator Module Scripting#ADD &amp;amp;#91;JSON&amp;amp;#93 PARAMETER &amp;lt;parameter definition&amp;gt;|ADD PARAMETER]] scripting command.&lt;br /&gt;
&lt;br /&gt;
====bool ShowParameterJson( string name, string&amp;amp; json )====&lt;br /&gt;
Copies the specified parameter into the &#039;&#039;json&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
====bool PutParameterJson( string json )====&lt;br /&gt;
Constructs a parameter from the given JSON representation, and applies it to the parameter list.&lt;br /&gt;
The parameter must exist in the system. To add a parameter, use the Execute() method in conjunction with the [[User Reference:Operator Module Scripting#ADD &amp;amp;#91;JSON&amp;amp;#93; PARAMETER &amp;lt;parameter definition&amp;gt;|ADD JSON PARAMETER]] scripting command.&lt;br /&gt;
&lt;br /&gt;
The parameter definition is expected in [[User Reference:JSON Parameter Format|JSON parameter format]].&lt;br /&gt;
&lt;br /&gt;
====bool LoadParametersLocal( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the calling application. This function returns false if the specified file was not found but will not provide information whether parameters were sent successfully. Rather, illegal parameter lines will be silently ignored.&lt;br /&gt;
====bool LoadParametersRemote( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the Operator module connected to. Unless explicitly changed, that working directory is the BCI2000/prog directory in which the Operator module resides.&lt;br /&gt;
&lt;br /&gt;
====bool AddStateVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds a [[Technical_Reference:State_Definition|state variable]] to the system. This is only possible before core modules have connected to the Operator module.&lt;br /&gt;
State variables added by &#039;&#039;AddStateVariable()&#039;&#039; are plain state variables (i.e., not event or stream state variables).&lt;br /&gt;
&lt;br /&gt;
====bool GetStateVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 state variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
&#039;&#039;GetStateVariable()&#039;&#039; will retrieve values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool SetStateVariable( string name, double value )====&lt;br /&gt;
Sets the value of the named BCI2000 state variable to the given value. Returns false on error.&lt;br /&gt;
&#039;&#039;SetStateVariable()&#039;&#039; can set values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool AddEventVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds an [[Technical_Reference:State_Definition#Events|event variable]] to the system. This is only possible before core modules have connected to the Operator module.	&lt;br /&gt;
====bool GetEventVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 event variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
====bool SetEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value. Returns false on error.&lt;br /&gt;
====bool PulseEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value, for the duration of a single sample.&lt;br /&gt;
Returns false on error.&lt;br /&gt;
&lt;br /&gt;
====bool GetSystemState( string&amp;amp; state )====&lt;br /&gt;
Gets the current system state (i.e., state of operation). If no error occurred, the &amp;quot;state&amp;quot; output variable will contain the name of the current system state, which will be one of the names listed at [[User Reference:Operator Module Scripting#GET_SYSTEM_STATE]].&lt;br /&gt;
====bool GetControlSignalChannels( double&amp;amp; channels )====&lt;br /&gt;
Copies the number of control signal channels into the &amp;quot;channels&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignalElements( double&amp;amp; elements )====&lt;br /&gt;
Copies the number of control signal elements into the &amp;quot;elements&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignal( int channel, int element, double&amp;amp; value )====&lt;br /&gt;
Copies the value of the control signal at the given indices into the &amp;quot;value&amp;quot; output variable. Indices are 1-based. Typically, the control signal has only a single element, and the number of output channels corresponds to the number of feedback dimensions in feedback experiments, or is 1 in evoked potential experiments.&lt;br /&gt;
&lt;br /&gt;
===Scripting methods===&lt;br /&gt;
====bool Execute( string command, int* exitCode = 0 )====&lt;br /&gt;
Execute an arbitrary BCI2000 scripting command. A return value of &amp;quot;true&amp;quot; does not indicate successful execution of the command; rather, it indicates that the command was sent, and its result was received. In general, the &#039;&#039;&#039;Result&#039;&#039;&#039; property needs to be examined in order to determine whether the command was executed successfully.&lt;br /&gt;
&lt;br /&gt;
In many cases, the optional &#039;&#039;exitCode&#039;&#039; argument may be specified to obtain the result status of a command in an integer variable that the &#039;&#039;exitCode&#039;&#039; pointer points to.&lt;br /&gt;
The exact meaning of the exit code depends on the command that has been executed, so it is necessary to be aware of a command&#039;s possible responses before evaluating an exit code.&lt;br /&gt;
&lt;br /&gt;
In detail, the exit code is determined as follows:&lt;br /&gt;
* When Execute() is used to execute a SYSTEM command, the exit code will match the exit code of the program that was run through the SYSTEM command. By convention, such exit codes are nonzero on failure, and zero on success.&lt;br /&gt;
* For other commands, the exit code is derived from the &#039;&#039;&#039;Result&#039;&#039;&#039; property as follows:&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; may be interpreted as a single floating point number, the exit code will be 0 for a nonzero number, and 1 if the number is zero.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot; (without considering case), the exit code will be 0 for &amp;quot;true&amp;quot;, and 1 for &amp;quot;false&amp;quot;.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is empty, the exit code will be 0.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; does not match any of the previous conditions, the exit code will be -1 to indicate that there was no obvious interpretation.&lt;br /&gt;
&lt;br /&gt;
This scheme is chosen to simplify client code for the most common cases:&lt;br /&gt;
* external programs run through the SYSTEM command,&lt;br /&gt;
* commands which do not have an output except in case of failure,&lt;br /&gt;
* functions returning binary values, such as the test command,&lt;br /&gt;
* expressions evaluated as logical conditions.&lt;br /&gt;
In all these cases, the exit code will be 0 on success, and 1 on failure.&lt;br /&gt;
&lt;br /&gt;
When executing a command that may return an arbitrary string (e.g., EXECUTE SCRIPT, or ECHO), the exit code should not be used. In this case, the &#039;&#039;exitCode&#039;&#039; argument may be omitted, or may be NULL.&lt;br /&gt;
&lt;br /&gt;
A full documentation of BCI2000 Operator scripting commands is available under [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
====bool SetScript( string handlers, string script )====&lt;br /&gt;
Associate a sequence of BCI2000 scripting commands with the specified events. Events are given by name, as defined in the [[User Reference:Operator Module Scripting|scripting reference]]. Multiple handler names may be specified, concatenated with a pipe &#039;|&#039; character.&lt;br /&gt;
&lt;br /&gt;
====bool GetScript( string handler, string&amp;amp; script )====&lt;br /&gt;
Copy the handler script into the &#039;&#039;script&#039;&#039; output variable.&lt;br /&gt;
&lt;br /&gt;
===Watches===&lt;br /&gt;
====Watch* NewWatch( string expression, WatchCallback, void* callbackData )====&lt;br /&gt;
Creates a new watch object that watches on the expression or expressions given, and calls the specified callback each time the expression value changes. CallbackData is arbitrary user data (e.g., a pointer to an object) required for processing the callback.&lt;br /&gt;
If multiple expressions are given, they must be separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
The watch object may be disposed of by calling an ordinary delete.&lt;br /&gt;
&lt;br /&gt;
====void WatchCallback( void* callbackData, const char* values )====&lt;br /&gt;
Signature of a user-defined callback function that receives expression values, along with the arbitrary user data stored in callbackData. The values string starts with millisecond timestamp, followed with one value for each expression, and a trailing CRLF. Values are separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
To facilitate the use of BCI2000Remote, it only depends on very few files from the BCI2000 framework. To use BCI2000Remote in a C++ project, you will need to add the following cpp files to the project, and their parent directories to the list of include paths:&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Remote.cpp&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Connection.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SockStream.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SelfPipe.cpp&lt;br /&gt;
Also, on Windows you will need to link against this additional library:&lt;br /&gt;
 WS2_32&lt;br /&gt;
&lt;br /&gt;
==[[Technical Reference:BCI2000Remote Library|BCI2000RemoteLib]]==&lt;br /&gt;
The BCI2000RemoteLib is a dynamic library that exports a C-style wrapper around the BCI2000Remote class, such that it may be used from scripting languages that support execution of library code. A C-style wrapper is required because no stable conventions exist regarding the export of classes and objects from dynamic libraries.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote member functions are directly mapped on C functions by adding an object handle as a first argument, and by replacing &amp;lt;tt&amp;gt;std::string&amp;lt;/tt&amp;gt; arguments with C string arguments. To instantiate a BCI2000Remote object, and obtain an object handle, call &amp;lt;tt&amp;gt;BCI2000Remote_New()&amp;lt;/tt&amp;gt;; specify this handle as a first argument to any BCI2000Remote member function you would like to call, and finally delete the object by specifying its handle as an argument to &amp;lt;tt&amp;gt;BCI2000Remote_Delete()&amp;lt;/tt&amp;gt;. An object handle should always be treated as an opaque reference, and never be cast to a pointer of type &amp;lt;tt&amp;gt;BCI2000Remote*&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Similarly, &amp;lt;tt&amp;gt;BCI20000Remote_NewWatch()&amp;lt;/tt&amp;gt; returns a reference to a watch object as a &amp;lt;tt&amp;gt;void*&amp;lt;/tt&amp;gt;. Once you are done with the watch object, call &amp;lt;tt&amp;gt;BCI2000Remote_DeleteWatch()&amp;lt;/tt&amp;gt; to dispose of it.&lt;br /&gt;
&lt;br /&gt;
Any function that returns a C string as a &amp;lt;tt&amp;gt;const char*&amp;lt;/tt&amp;gt; may return a zero pointer, indicating failure, or a valid pointer to a C string, indicating success. If a valid pointer is returned, the associated memory has been allocated by the library, and will be invalidated by the next call to a C string returning function. Earlier versions of BCI2000RemoteLib required to call &amp;lt;tt&amp;gt;BCI2000Release()&amp;lt;/tt&amp;gt; after receiving a C string. This is no longer the case. Instead, the memory allocated for the C string is deallocated on the next call that returns a C string.&lt;br /&gt;
&lt;br /&gt;
==Python Variations==&lt;br /&gt;
There is a wrapper to BCI2000RemoteLib in Python, which lets you call functions that are very similar to the BCI2000Remote class. Most of the members are documented above, however the syntax is different for some. There are a couple new functions as well, all of which will be highlighted here.&lt;br /&gt;
===Get &amp;lt;Variable&amp;gt;===&lt;br /&gt;
For the &amp;quot;Get&amp;quot; functions (e.g., GetState, GetParameter, GetEvent), instead of passing a variable by reference, the return value is set to the desired variable (e.g., the state, parameter, event). For example, the syntax is &amp;lt;code&amp;gt; state = bci.GetStateVariable(&amp;quot;StimulusCode&amp;quot;) &amp;lt;/code&amp;gt;, where &amp;lt;code&amp;gt;state&amp;lt;/code&amp;gt; is a c_double that is the value of the state.&lt;br /&gt;
===Additional functions===&lt;br /&gt;
*&amp;lt;b&amp;gt;Quit()&amp;lt;/b&amp;gt;: quits the system&lt;br /&gt;
*&amp;lt;b&amp;gt;GetListParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a list, this returns an array of the parameter values in the list&lt;br /&gt;
*&amp;lt;b&amp;gt;GetMatrixParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a matrix, this returns a 2d array of the matrix&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
See the [[User Tutorial:BCI2000Remote|user tutorial page]] for C++, Matlab, and Python examples!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Tutorial:BCI2000Remote]], &amp;lt;!--[[Contributions:BCI2000Automation]],--&amp;gt; [[Contributions:BCI2000PresentationLink]], [[Contributions:BCI2000Command]], [[Contributions:BCI2000PythonBindings]], [[Contributions:Applications]]&lt;br /&gt;
&lt;br /&gt;
[[Category:External Interfaces]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12618</id>
		<title>Programming Reference:BCI2000Remote Class</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12618"/>
		<updated>2026-10-08T17:30:32Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* bool PutParameterJson( string json ) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends [[User Reference:Operator Module Scripting|Operator Scripting commands]] to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the [[#BCI2000RemoteLib|BCI2000RemoteLib]] library exist, such as Python, or MATLAB through the &amp;lt;tt&amp;gt;loadlibrary&amp;lt;/tt&amp;gt; command, specifying &amp;lt;tt&amp;gt;src/core/Operator/BCI2000Remote/BCI2000RemoteLib.h&amp;lt;/tt&amp;gt; as the header file associated with the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--For controlling BCI2000 under Windows from MATLAB, Windows Automation compatible scripting languages, or .NET languages, there exists a separate [[Contributions:BCI2000Automation|automation interface]].--&amp;gt;&lt;br /&gt;
For controlling BCI2000 from shell scripts (such as the Windows command interpreter, or Unix shells like bash), there exists a [[Contributions:BCI2000Command|BCI2000 command executable]] and the [[User_Reference:BCI2000Shell|BCI2000Shell]].&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
BCI2000/src/core/Operator/BCI2000Remote&lt;br /&gt;
&lt;br /&gt;
==Functional Description==&lt;br /&gt;
After instantiating a BCI2000Remote object, set its OperatorPath property to point to the desired BCI2000 Operator module. Then, call its Connect() method to start up that module, and connect to it. You may then use the StartupModules() method in order to start up BCI2000 core modules.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you may specify the path to a BCI2000 batch file in the BCI2000/batch directory. An appropriate batch file should start up Operator and core modules, and needs to forward its command line arguments to the Operator module. All batch files coming with BCI2000 fulfill this condition. When a batch file is specified, there is no need to call the StartupModules() method.&lt;br /&gt;
&lt;br /&gt;
As yet another option, you may connect to an Operator module that is already running, e.g., on a remote machine on the network. In this case, set the BCI2000Remote object&#039;s OperatorPath property to an empty string, and its TelnetAddress property to the address that the remote Operator module is listening on, i.e. the remote machine&#039;s IP address, followed with a colon, and the port specified when starting up the remote Operator module. The remote Operator module must have been started with the &amp;quot;--Telnet&amp;quot; command line option, followed with the address to listen on. On the remote machine, this would typically be &amp;quot;localhost:3999&amp;quot;. Don&#039;t use any of the ports between 4000 and 4002, as this will interfere with the communication between the Operator module, and BCI2000 core modules. Depending on whether the remote Operator module has been started up together with its core modules, or not, you may then call the StartupModules() method in order to start up BCI2000 core modules on the remote machine.&lt;br /&gt;
&lt;br /&gt;
Once all BCI2000 modules are running, you may load parameter files locally or remotely using the LoadParametersLocal() and LoadParametersRemote() methods. Subject ID, Session ID, and data directory are set using the respective BCI2000Remote properties.&lt;br /&gt;
&lt;br /&gt;
A recording may then be started by calling the Start() method. Depending on configuration, the recording will terminate automatically, or needs to be terminated by a call to the Stop() method.&lt;br /&gt;
&lt;br /&gt;
To run BCI2000 in a different configuration (i.e., with different core modules), it is not necessary to terminate the Operator module. Rather, you may execute StartupModules() multiple times in order to terminate currently running core modules, and start different ones.&lt;br /&gt;
&lt;br /&gt;
Once you are done using BCI2000, you may close the connection by calling the Disconnect() method, or by deleting the BCI2000Remote object. Depending on whether the Operator module was started up by the previous Connect() call, this will terminate the Operator module as well. When connection was made to an already running Operator module, local or remote, the connection will be closed but the Operator module will remain running.&lt;br /&gt;
&lt;br /&gt;
==BCI2000Remote Members==&lt;br /&gt;
The BCI2000Remote class has the following members:&lt;br /&gt;
===Properties===&lt;br /&gt;
====double Timeout=5 (rw)====&lt;br /&gt;
Timeout in seconds. Applies when establishing communication between BCI2000Remote and BCI2000.&lt;br /&gt;
&lt;br /&gt;
====string OperatorPath=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Path to Operator module, or batch file. When empty, BCI2000Remote tries to connect to an already running Operator module which may be on a different machine, depending on the &#039;&#039;TelnetAddress&#039;&#039; setting. When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module.&lt;br /&gt;
&lt;br /&gt;
====string TelnetAddress=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Telnet address to use for connection to a remote machine. To connect to a remote machine, specify the machine&#039;s IP address, followed with BCI2000&#039;s listening port. You should take care to avoid specifying a port that is used by BCI2000&#039;s internal connections between Operator and core modules. By default, these are 4000, 4001, and 4002.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module. This is preferable for security reasons.&lt;br /&gt;
&lt;br /&gt;
=====bool WindowVisible=2 (rw)=====&lt;br /&gt;
Visibility of the BCI2000 main window. 0: Invisible, 1: visible, 2: don&#039;t change.&lt;br /&gt;
&lt;br /&gt;
====string WindowTitle (rw)====&lt;br /&gt;
The title of the BCI2000 main window.&lt;br /&gt;
====string Result (r)====&lt;br /&gt;
Text output of the previously executed command, or an error message when the previously executed command failed.&lt;br /&gt;
====Recording information====&lt;br /&gt;
=====string SubjectID (rw)=====&lt;br /&gt;
The subject ID for the next recording. When this property is empty, the subject ID is taken from the current value of the SubjectName parameter.&lt;br /&gt;
=====string SessionID (rw)=====&lt;br /&gt;
The session ID for the next recording. When this property is empty, the session ID is taken from the SubjectSession parameter.&lt;br /&gt;
=====string DataDirectory (rw)=====&lt;br /&gt;
The data directory for the next recording. When a relative path is given, it is taken relative to BCI2000/data. When this property is empty, the data directory is taken from the DataDirectory parameter.&lt;br /&gt;
&lt;br /&gt;
===Connection methods===&lt;br /&gt;
====bool Connect()====&lt;br /&gt;
Connect to BCI2000. When OperatorPath is not empty, and no operator module is listening at TelnetAddress, this starts up the operator module before connecting. Will return true on success.&lt;br /&gt;
&lt;br /&gt;
====bool Connect( BCI2000Remote )====&lt;br /&gt;
Connects to the same Operator module as the BCI2000Remote instance given as an argument. This will not start BCI2000 when it is not running, thus it is necessary that the argument instance&#039;s Connect() method has been called before.&lt;br /&gt;
&lt;br /&gt;
====bool Disconnect()====&lt;br /&gt;
Disconnect from an existing connection. Terminates the running operator module if it was started by the previous Connect() call.&lt;br /&gt;
&lt;br /&gt;
===Control of operation===&lt;br /&gt;
====bool StartupModules( vector(string) modules )====&lt;br /&gt;
Start BCI2000 core modules, listed by executable name, including possible command line arguments. Each entry in the array corresponds to a single core module, given relative to the Operator module&#039;s working directory, which defaults to BCI2000/prog. You do not need to call this function if the OperatorPath property specifies a batch file rather than the Operator module itself.&lt;br /&gt;
====bool SetConfig()====&lt;br /&gt;
Applies the current set of parameters. Will be called from Start() automatically. Returns false if parameters could not be set, e.g. because the system was in running state, or because there was a preflight error when applying parameters. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Start()====&lt;br /&gt;
Starts a new run (recording) with current parameters. Returns false if the run could not be started. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Stop()====&lt;br /&gt;
Stops the current run (recording).&lt;br /&gt;
&lt;br /&gt;
===Parameters and system state===&lt;br /&gt;
====bool GetParameter( string name, string&amp;amp; value )====&lt;br /&gt;
Copies the specified parameter&#039;s value into the &#039;&#039;value&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
====bool SetParameter( string name, string value )====&lt;br /&gt;
Sets the specified parameter to the given value. The parameter must exist in the system. To add a parameter, use the Execute() method in conjunction with the [[User Reference:Operator Module Scripting#ADD &amp;amp;#91;JSON&amp;amp;#93 PARAMETER &amp;lt;parameter definition&amp;gt;|ADD PARAMETER]] scripting command.&lt;br /&gt;
&lt;br /&gt;
====bool ShowParameterJson( string name, string&amp;amp; json )====&lt;br /&gt;
Copies the specified parameter into the &#039;&#039;json&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
====bool PutParameterJson( string json )====&lt;br /&gt;
Constructs a parameter from the given JSON representation, and applies it to the parameter list.&lt;br /&gt;
The parameter must exist in the system. To add a parameter, use the Execute() method in conjunction with the [[User Reference:Operator Module Scripting#ADD &amp;amp;#91;JSON&amp;amp;#93; PARAMETER &amp;lt;parameter definition&amp;gt;|ADD JSON PARAMETER]] scripting command.&lt;br /&gt;
&lt;br /&gt;
====bool LoadParametersLocal( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the calling application. This function returns false if the specified file was not found but will not provide information whether parameters were sent successfully. Rather, illegal parameter lines will be silently ignored.&lt;br /&gt;
====bool LoadParametersRemote( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the Operator module connected to. Unless explicitly changed, that working directory is the BCI2000/prog directory in which the Operator module resides.&lt;br /&gt;
&lt;br /&gt;
====bool AddStateVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds a [[Technical_Reference:State_Definition|state variable]] to the system. This is only possible before core modules have connected to the Operator module.&lt;br /&gt;
State variables added by &#039;&#039;AddStateVariable()&#039;&#039; are plain state variables (i.e., not event or stream state variables).&lt;br /&gt;
&lt;br /&gt;
====bool GetStateVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 state variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
&#039;&#039;GetStateVariable()&#039;&#039; will retrieve values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool SetStateVariable( string name, double value )====&lt;br /&gt;
Sets the value of the named BCI2000 state variable to the given value. Returns false on error.&lt;br /&gt;
&#039;&#039;SetStateVariable()&#039;&#039; can set values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool AddEventVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds an [[Technical_Reference:State_Definition#Events|event variable]] to the system. This is only possible before core modules have connected to the Operator module.	&lt;br /&gt;
====bool GetEventVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 event variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
====bool SetEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value. Returns false on error.&lt;br /&gt;
====bool PulseEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value, for the duration of a single sample.&lt;br /&gt;
Returns false on error.&lt;br /&gt;
&lt;br /&gt;
====bool GetSystemState( string&amp;amp; state )====&lt;br /&gt;
Gets the current system state (i.e., state of operation). If no error occurred, the &amp;quot;state&amp;quot; output variable will contain the name of the current system state, which will be one of the names listed at [[User Reference:Operator Module Scripting#GET_SYSTEM_STATE]].&lt;br /&gt;
====bool GetControlSignalChannels( double&amp;amp; channels )====&lt;br /&gt;
Copies the number of control signal channels into the &amp;quot;channels&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignalElements( double&amp;amp; elements )====&lt;br /&gt;
Copies the number of control signal elements into the &amp;quot;elements&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignal( int channel, int element, double&amp;amp; value )====&lt;br /&gt;
Copies the value of the control signal at the given indices into the &amp;quot;value&amp;quot; output variable. Indices are 1-based. Typically, the control signal has only a single element, and the number of output channels corresponds to the number of feedback dimensions in feedback experiments, or is 1 in evoked potential experiments.&lt;br /&gt;
&lt;br /&gt;
===Scripting methods===&lt;br /&gt;
====bool Execute( string command, int* exitCode = 0 )====&lt;br /&gt;
Execute an arbitrary BCI2000 scripting command. A return value of &amp;quot;true&amp;quot; does not indicate successful execution of the command; rather, it indicates that the command was sent, and its result was received. In general, the &#039;&#039;&#039;Result&#039;&#039;&#039; property needs to be examined in order to determine whether the command was executed successfully.&lt;br /&gt;
&lt;br /&gt;
In many cases, the optional &#039;&#039;exitCode&#039;&#039; argument may be specified to obtain the result status of a command in an integer variable that the &#039;&#039;exitCode&#039;&#039; pointer points to.&lt;br /&gt;
The exact meaning of the exit code depends on the command that has been executed, so it is necessary to be aware of a command&#039;s possible responses before evaluating an exit code.&lt;br /&gt;
&lt;br /&gt;
In detail, the exit code is determined as follows:&lt;br /&gt;
* When Execute() is used to execute a SYSTEM command, the exit code will match the exit code of the program that was run through the SYSTEM command. By convention, such exit codes are nonzero on failure, and zero on success.&lt;br /&gt;
* For other commands, the exit code is derived from the &#039;&#039;&#039;Result&#039;&#039;&#039; property as follows:&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; may be interpreted as a single floating point number, the exit code will be 0 for a nonzero number, and 1 if the number is zero.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot; (without considering case), the exit code will be 0 for &amp;quot;true&amp;quot;, and 1 for &amp;quot;false&amp;quot;.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is empty, the exit code will be 0.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; does not match any of the previous conditions, the exit code will be -1 to indicate that there was no obvious interpretation.&lt;br /&gt;
&lt;br /&gt;
This scheme is chosen to simplify client code for the most common cases:&lt;br /&gt;
* external programs run through the SYSTEM command,&lt;br /&gt;
* commands which do not have an output except in case of failure,&lt;br /&gt;
* functions returning binary values, such as the test command,&lt;br /&gt;
* expressions evaluated as logical conditions.&lt;br /&gt;
In all these cases, the exit code will be 0 on success, and 1 on failure.&lt;br /&gt;
&lt;br /&gt;
When executing a command that may return an arbitrary string (e.g., EXECUTE SCRIPT, or ECHO), the exit code should not be used. In this case, the &#039;&#039;exitCode&#039;&#039; argument may be omitted, or may be NULL.&lt;br /&gt;
&lt;br /&gt;
A full documentation of BCI2000 Operator scripting commands is available under [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
====bool SetScript( string handlers, string script )====&lt;br /&gt;
Associate a sequence of BCI2000 scripting commands with the specified events. Events are given by name, as defined in the [[User Reference:Operator Module Scripting|scripting reference]]. Multiple handler names may be specified, concatenated with a pipe &#039;|&#039; character.&lt;br /&gt;
&lt;br /&gt;
====bool GetScript( string handler, string&amp;amp; script )====&lt;br /&gt;
Copy the handler script into the &#039;&#039;script&#039;&#039; output variable.&lt;br /&gt;
&lt;br /&gt;
===Watches===&lt;br /&gt;
====Watch* NewWatch( string expression, WatchCallback, void* callbackData )====&lt;br /&gt;
Creates a new watch object that watches on the expression or expressions given, and calls the specified callback each time the expression value changes. CallbackData is arbitrary user data (e.g., a pointer to an object) required for processing the callback.&lt;br /&gt;
If multiple expressions are given, they must be separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
The watch object may be disposed of by calling an ordinary delete.&lt;br /&gt;
&lt;br /&gt;
====void WatchCallback( void* callbackData, const char* values )====&lt;br /&gt;
Signature of a user-defined callback function that receives expression values, along with the arbitrary user data stored in callbackData. The values string starts with millisecond timestamp, followed with one value for each expression, and a trailing CRLF. Values are separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
To facilitate the use of BCI2000Remote, it only depends on very few files from the BCI2000 framework. To use BCI2000Remote in a C++ project, you will need to add the following cpp files to the project, and their parent directories to the list of include paths:&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Remote.cpp&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Connection.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SockStream.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SelfPipe.cpp&lt;br /&gt;
Also, on Windows you will need to link against this additional library:&lt;br /&gt;
 WS2_32&lt;br /&gt;
&lt;br /&gt;
==[[Technical Reference:BCI2000Remote Library|BCI2000RemoteLib]]==&lt;br /&gt;
The BCI2000RemoteLib is a dynamic library that exports a C-style wrapper around the BCI2000Remote class, such that it may be used from scripting languages that support execution of library code. A C-style wrapper is required because no stable conventions exist regarding the export of classes and objects from dynamic libraries.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote member functions are directly mapped on C functions by adding an object handle as a first argument, and by replacing &amp;lt;tt&amp;gt;std::string&amp;lt;/tt&amp;gt; arguments with C string arguments. To instantiate a BCI2000Remote object, and obtain an object handle, call &amp;lt;tt&amp;gt;BCI2000Remote_New()&amp;lt;/tt&amp;gt;; specify this handle as a first argument to any BCI2000Remote member function you would like to call, and finally delete the object by specifying its handle as an argument to &amp;lt;tt&amp;gt;BCI2000Remote_Delete()&amp;lt;/tt&amp;gt;. An object handle should always be treated as an opaque reference, and never be cast to a pointer of type &amp;lt;tt&amp;gt;BCI2000Remote*&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Similarly, &amp;lt;tt&amp;gt;BCI20000Remote_NewWatch()&amp;lt;/tt&amp;gt; returns a reference to a watch object as a &amp;lt;tt&amp;gt;void*&amp;lt;/tt&amp;gt;. Once you are done with the watch object, call &amp;lt;tt&amp;gt;BCI2000Remote_DeleteWatch()&amp;lt;/tt&amp;gt; to dispose of it.&lt;br /&gt;
&lt;br /&gt;
Any function that returns a C string as a &amp;lt;tt&amp;gt;const char*&amp;lt;/tt&amp;gt; may return a zero pointer, indicating failure, or a valid pointer to a C string, indicating success. If a valid pointer is returned, the associated memory has been allocated by the library, and will be invalidated by the next call to a C string returning function. Earlier versions of BCI2000RemoteLib required to call &amp;lt;tt&amp;gt;BCI2000Release()&amp;lt;/tt&amp;gt; after receiving a C string. This is no longer the case. Instead, the memory allocated for the C string is deallocated on the next call that returns a C string.&lt;br /&gt;
&lt;br /&gt;
==Python Variations==&lt;br /&gt;
There is a wrapper to BCI2000RemoteLib in Python, which lets you call functions that are very similar to the BCI2000Remote class. Most of the members are documented above, however the syntax is different for some. There are a couple new functions as well, all of which will be highlighted here.&lt;br /&gt;
===Get &amp;lt;Variable&amp;gt;===&lt;br /&gt;
For the &amp;quot;Get&amp;quot; functions (e.g., GetState, GetParameter, GetEvent), instead of passing a variable by reference, the return value is set to the desired variable (e.g., the state, parameter, event). For example, the syntax is &amp;lt;code&amp;gt; state = bci.GetStateVariable(&amp;quot;StimulusCode&amp;quot;) &amp;lt;/code&amp;gt;, where &amp;lt;code&amp;gt;state&amp;lt;/code&amp;gt; is a c_double that is the value of the state.&lt;br /&gt;
===Additional functions===&lt;br /&gt;
*&amp;lt;b&amp;gt;Quit()&amp;lt;/b&amp;gt;: quits the system&lt;br /&gt;
*&amp;lt;b&amp;gt;GetListParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a list, this returns an array of the parameter values in the list&lt;br /&gt;
*&amp;lt;b&amp;gt;GetMatrixParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a matrix, this returns a 2d array of the matrix&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
See the [[User Tutorial:BCI2000Remote|user tutorial page]] for C++, Matlab, and Python examples!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Tutorial:BCI2000Remote]], &amp;lt;!--[[Contributions:BCI2000Automation]],--&amp;gt; [[Contributions:BCI2000PresentationLink]], [[Contributions:BCI2000Command]], [[Contributions:BCI2000PythonBindings]], [[Contributions:Applications]]&lt;br /&gt;
&lt;br /&gt;
[[Category:External Interfaces]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12617</id>
		<title>Programming Reference:BCI2000Remote Class</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12617"/>
		<updated>2026-10-08T17:29:54Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* bool SetParameter( string name, string value ) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends [[User Reference:Operator Module Scripting|Operator Scripting commands]] to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the [[#BCI2000RemoteLib|BCI2000RemoteLib]] library exist, such as Python, or MATLAB through the &amp;lt;tt&amp;gt;loadlibrary&amp;lt;/tt&amp;gt; command, specifying &amp;lt;tt&amp;gt;src/core/Operator/BCI2000Remote/BCI2000RemoteLib.h&amp;lt;/tt&amp;gt; as the header file associated with the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--For controlling BCI2000 under Windows from MATLAB, Windows Automation compatible scripting languages, or .NET languages, there exists a separate [[Contributions:BCI2000Automation|automation interface]].--&amp;gt;&lt;br /&gt;
For controlling BCI2000 from shell scripts (such as the Windows command interpreter, or Unix shells like bash), there exists a [[Contributions:BCI2000Command|BCI2000 command executable]] and the [[User_Reference:BCI2000Shell|BCI2000Shell]].&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
BCI2000/src/core/Operator/BCI2000Remote&lt;br /&gt;
&lt;br /&gt;
==Functional Description==&lt;br /&gt;
After instantiating a BCI2000Remote object, set its OperatorPath property to point to the desired BCI2000 Operator module. Then, call its Connect() method to start up that module, and connect to it. You may then use the StartupModules() method in order to start up BCI2000 core modules.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you may specify the path to a BCI2000 batch file in the BCI2000/batch directory. An appropriate batch file should start up Operator and core modules, and needs to forward its command line arguments to the Operator module. All batch files coming with BCI2000 fulfill this condition. When a batch file is specified, there is no need to call the StartupModules() method.&lt;br /&gt;
&lt;br /&gt;
As yet another option, you may connect to an Operator module that is already running, e.g., on a remote machine on the network. In this case, set the BCI2000Remote object&#039;s OperatorPath property to an empty string, and its TelnetAddress property to the address that the remote Operator module is listening on, i.e. the remote machine&#039;s IP address, followed with a colon, and the port specified when starting up the remote Operator module. The remote Operator module must have been started with the &amp;quot;--Telnet&amp;quot; command line option, followed with the address to listen on. On the remote machine, this would typically be &amp;quot;localhost:3999&amp;quot;. Don&#039;t use any of the ports between 4000 and 4002, as this will interfere with the communication between the Operator module, and BCI2000 core modules. Depending on whether the remote Operator module has been started up together with its core modules, or not, you may then call the StartupModules() method in order to start up BCI2000 core modules on the remote machine.&lt;br /&gt;
&lt;br /&gt;
Once all BCI2000 modules are running, you may load parameter files locally or remotely using the LoadParametersLocal() and LoadParametersRemote() methods. Subject ID, Session ID, and data directory are set using the respective BCI2000Remote properties.&lt;br /&gt;
&lt;br /&gt;
A recording may then be started by calling the Start() method. Depending on configuration, the recording will terminate automatically, or needs to be terminated by a call to the Stop() method.&lt;br /&gt;
&lt;br /&gt;
To run BCI2000 in a different configuration (i.e., with different core modules), it is not necessary to terminate the Operator module. Rather, you may execute StartupModules() multiple times in order to terminate currently running core modules, and start different ones.&lt;br /&gt;
&lt;br /&gt;
Once you are done using BCI2000, you may close the connection by calling the Disconnect() method, or by deleting the BCI2000Remote object. Depending on whether the Operator module was started up by the previous Connect() call, this will terminate the Operator module as well. When connection was made to an already running Operator module, local or remote, the connection will be closed but the Operator module will remain running.&lt;br /&gt;
&lt;br /&gt;
==BCI2000Remote Members==&lt;br /&gt;
The BCI2000Remote class has the following members:&lt;br /&gt;
===Properties===&lt;br /&gt;
====double Timeout=5 (rw)====&lt;br /&gt;
Timeout in seconds. Applies when establishing communication between BCI2000Remote and BCI2000.&lt;br /&gt;
&lt;br /&gt;
====string OperatorPath=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Path to Operator module, or batch file. When empty, BCI2000Remote tries to connect to an already running Operator module which may be on a different machine, depending on the &#039;&#039;TelnetAddress&#039;&#039; setting. When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module.&lt;br /&gt;
&lt;br /&gt;
====string TelnetAddress=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Telnet address to use for connection to a remote machine. To connect to a remote machine, specify the machine&#039;s IP address, followed with BCI2000&#039;s listening port. You should take care to avoid specifying a port that is used by BCI2000&#039;s internal connections between Operator and core modules. By default, these are 4000, 4001, and 4002.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module. This is preferable for security reasons.&lt;br /&gt;
&lt;br /&gt;
=====bool WindowVisible=2 (rw)=====&lt;br /&gt;
Visibility of the BCI2000 main window. 0: Invisible, 1: visible, 2: don&#039;t change.&lt;br /&gt;
&lt;br /&gt;
====string WindowTitle (rw)====&lt;br /&gt;
The title of the BCI2000 main window.&lt;br /&gt;
====string Result (r)====&lt;br /&gt;
Text output of the previously executed command, or an error message when the previously executed command failed.&lt;br /&gt;
====Recording information====&lt;br /&gt;
=====string SubjectID (rw)=====&lt;br /&gt;
The subject ID for the next recording. When this property is empty, the subject ID is taken from the current value of the SubjectName parameter.&lt;br /&gt;
=====string SessionID (rw)=====&lt;br /&gt;
The session ID for the next recording. When this property is empty, the session ID is taken from the SubjectSession parameter.&lt;br /&gt;
=====string DataDirectory (rw)=====&lt;br /&gt;
The data directory for the next recording. When a relative path is given, it is taken relative to BCI2000/data. When this property is empty, the data directory is taken from the DataDirectory parameter.&lt;br /&gt;
&lt;br /&gt;
===Connection methods===&lt;br /&gt;
====bool Connect()====&lt;br /&gt;
Connect to BCI2000. When OperatorPath is not empty, and no operator module is listening at TelnetAddress, this starts up the operator module before connecting. Will return true on success.&lt;br /&gt;
&lt;br /&gt;
====bool Connect( BCI2000Remote )====&lt;br /&gt;
Connects to the same Operator module as the BCI2000Remote instance given as an argument. This will not start BCI2000 when it is not running, thus it is necessary that the argument instance&#039;s Connect() method has been called before.&lt;br /&gt;
&lt;br /&gt;
====bool Disconnect()====&lt;br /&gt;
Disconnect from an existing connection. Terminates the running operator module if it was started by the previous Connect() call.&lt;br /&gt;
&lt;br /&gt;
===Control of operation===&lt;br /&gt;
====bool StartupModules( vector(string) modules )====&lt;br /&gt;
Start BCI2000 core modules, listed by executable name, including possible command line arguments. Each entry in the array corresponds to a single core module, given relative to the Operator module&#039;s working directory, which defaults to BCI2000/prog. You do not need to call this function if the OperatorPath property specifies a batch file rather than the Operator module itself.&lt;br /&gt;
====bool SetConfig()====&lt;br /&gt;
Applies the current set of parameters. Will be called from Start() automatically. Returns false if parameters could not be set, e.g. because the system was in running state, or because there was a preflight error when applying parameters. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Start()====&lt;br /&gt;
Starts a new run (recording) with current parameters. Returns false if the run could not be started. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Stop()====&lt;br /&gt;
Stops the current run (recording).&lt;br /&gt;
&lt;br /&gt;
===Parameters and system state===&lt;br /&gt;
====bool GetParameter( string name, string&amp;amp; value )====&lt;br /&gt;
Copies the specified parameter&#039;s value into the &#039;&#039;value&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
====bool SetParameter( string name, string value )====&lt;br /&gt;
Sets the specified parameter to the given value. The parameter must exist in the system. To add a parameter, use the Execute() method in conjunction with the [[User Reference:Operator Module Scripting#ADD &amp;amp;#91;JSON&amp;amp;#93 PARAMETER &amp;lt;parameter definition&amp;gt;|ADD PARAMETER]] scripting command.&lt;br /&gt;
&lt;br /&gt;
====bool ShowParameterJson( string name, string&amp;amp; json )====&lt;br /&gt;
Copies the specified parameter into the &#039;&#039;json&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
====bool PutParameterJson( string json )====&lt;br /&gt;
Constructs a parameter from the given JSON representation, and applies it to the parameter list.&lt;br /&gt;
The parameter must exist in the system. To add a parameter, use the Execute() method in conjunction with the [[User Reference:Operator Module Scripting#ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;|ADD JSON PARAMETER]] scripting command.&lt;br /&gt;
&lt;br /&gt;
====bool LoadParametersLocal( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the calling application. This function returns false if the specified file was not found but will not provide information whether parameters were sent successfully. Rather, illegal parameter lines will be silently ignored.&lt;br /&gt;
====bool LoadParametersRemote( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the Operator module connected to. Unless explicitly changed, that working directory is the BCI2000/prog directory in which the Operator module resides.&lt;br /&gt;
&lt;br /&gt;
====bool AddStateVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds a [[Technical_Reference:State_Definition|state variable]] to the system. This is only possible before core modules have connected to the Operator module.&lt;br /&gt;
State variables added by &#039;&#039;AddStateVariable()&#039;&#039; are plain state variables (i.e., not event or stream state variables).&lt;br /&gt;
&lt;br /&gt;
====bool GetStateVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 state variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
&#039;&#039;GetStateVariable()&#039;&#039; will retrieve values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool SetStateVariable( string name, double value )====&lt;br /&gt;
Sets the value of the named BCI2000 state variable to the given value. Returns false on error.&lt;br /&gt;
&#039;&#039;SetStateVariable()&#039;&#039; can set values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool AddEventVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds an [[Technical_Reference:State_Definition#Events|event variable]] to the system. This is only possible before core modules have connected to the Operator module.	&lt;br /&gt;
====bool GetEventVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 event variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
====bool SetEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value. Returns false on error.&lt;br /&gt;
====bool PulseEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value, for the duration of a single sample.&lt;br /&gt;
Returns false on error.&lt;br /&gt;
&lt;br /&gt;
====bool GetSystemState( string&amp;amp; state )====&lt;br /&gt;
Gets the current system state (i.e., state of operation). If no error occurred, the &amp;quot;state&amp;quot; output variable will contain the name of the current system state, which will be one of the names listed at [[User Reference:Operator Module Scripting#GET_SYSTEM_STATE]].&lt;br /&gt;
====bool GetControlSignalChannels( double&amp;amp; channels )====&lt;br /&gt;
Copies the number of control signal channels into the &amp;quot;channels&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignalElements( double&amp;amp; elements )====&lt;br /&gt;
Copies the number of control signal elements into the &amp;quot;elements&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignal( int channel, int element, double&amp;amp; value )====&lt;br /&gt;
Copies the value of the control signal at the given indices into the &amp;quot;value&amp;quot; output variable. Indices are 1-based. Typically, the control signal has only a single element, and the number of output channels corresponds to the number of feedback dimensions in feedback experiments, or is 1 in evoked potential experiments.&lt;br /&gt;
&lt;br /&gt;
===Scripting methods===&lt;br /&gt;
====bool Execute( string command, int* exitCode = 0 )====&lt;br /&gt;
Execute an arbitrary BCI2000 scripting command. A return value of &amp;quot;true&amp;quot; does not indicate successful execution of the command; rather, it indicates that the command was sent, and its result was received. In general, the &#039;&#039;&#039;Result&#039;&#039;&#039; property needs to be examined in order to determine whether the command was executed successfully.&lt;br /&gt;
&lt;br /&gt;
In many cases, the optional &#039;&#039;exitCode&#039;&#039; argument may be specified to obtain the result status of a command in an integer variable that the &#039;&#039;exitCode&#039;&#039; pointer points to.&lt;br /&gt;
The exact meaning of the exit code depends on the command that has been executed, so it is necessary to be aware of a command&#039;s possible responses before evaluating an exit code.&lt;br /&gt;
&lt;br /&gt;
In detail, the exit code is determined as follows:&lt;br /&gt;
* When Execute() is used to execute a SYSTEM command, the exit code will match the exit code of the program that was run through the SYSTEM command. By convention, such exit codes are nonzero on failure, and zero on success.&lt;br /&gt;
* For other commands, the exit code is derived from the &#039;&#039;&#039;Result&#039;&#039;&#039; property as follows:&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; may be interpreted as a single floating point number, the exit code will be 0 for a nonzero number, and 1 if the number is zero.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot; (without considering case), the exit code will be 0 for &amp;quot;true&amp;quot;, and 1 for &amp;quot;false&amp;quot;.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is empty, the exit code will be 0.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; does not match any of the previous conditions, the exit code will be -1 to indicate that there was no obvious interpretation.&lt;br /&gt;
&lt;br /&gt;
This scheme is chosen to simplify client code for the most common cases:&lt;br /&gt;
* external programs run through the SYSTEM command,&lt;br /&gt;
* commands which do not have an output except in case of failure,&lt;br /&gt;
* functions returning binary values, such as the test command,&lt;br /&gt;
* expressions evaluated as logical conditions.&lt;br /&gt;
In all these cases, the exit code will be 0 on success, and 1 on failure.&lt;br /&gt;
&lt;br /&gt;
When executing a command that may return an arbitrary string (e.g., EXECUTE SCRIPT, or ECHO), the exit code should not be used. In this case, the &#039;&#039;exitCode&#039;&#039; argument may be omitted, or may be NULL.&lt;br /&gt;
&lt;br /&gt;
A full documentation of BCI2000 Operator scripting commands is available under [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
====bool SetScript( string handlers, string script )====&lt;br /&gt;
Associate a sequence of BCI2000 scripting commands with the specified events. Events are given by name, as defined in the [[User Reference:Operator Module Scripting|scripting reference]]. Multiple handler names may be specified, concatenated with a pipe &#039;|&#039; character.&lt;br /&gt;
&lt;br /&gt;
====bool GetScript( string handler, string&amp;amp; script )====&lt;br /&gt;
Copy the handler script into the &#039;&#039;script&#039;&#039; output variable.&lt;br /&gt;
&lt;br /&gt;
===Watches===&lt;br /&gt;
====Watch* NewWatch( string expression, WatchCallback, void* callbackData )====&lt;br /&gt;
Creates a new watch object that watches on the expression or expressions given, and calls the specified callback each time the expression value changes. CallbackData is arbitrary user data (e.g., a pointer to an object) required for processing the callback.&lt;br /&gt;
If multiple expressions are given, they must be separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
The watch object may be disposed of by calling an ordinary delete.&lt;br /&gt;
&lt;br /&gt;
====void WatchCallback( void* callbackData, const char* values )====&lt;br /&gt;
Signature of a user-defined callback function that receives expression values, along with the arbitrary user data stored in callbackData. The values string starts with millisecond timestamp, followed with one value for each expression, and a trailing CRLF. Values are separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
To facilitate the use of BCI2000Remote, it only depends on very few files from the BCI2000 framework. To use BCI2000Remote in a C++ project, you will need to add the following cpp files to the project, and their parent directories to the list of include paths:&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Remote.cpp&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Connection.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SockStream.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SelfPipe.cpp&lt;br /&gt;
Also, on Windows you will need to link against this additional library:&lt;br /&gt;
 WS2_32&lt;br /&gt;
&lt;br /&gt;
==[[Technical Reference:BCI2000Remote Library|BCI2000RemoteLib]]==&lt;br /&gt;
The BCI2000RemoteLib is a dynamic library that exports a C-style wrapper around the BCI2000Remote class, such that it may be used from scripting languages that support execution of library code. A C-style wrapper is required because no stable conventions exist regarding the export of classes and objects from dynamic libraries.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote member functions are directly mapped on C functions by adding an object handle as a first argument, and by replacing &amp;lt;tt&amp;gt;std::string&amp;lt;/tt&amp;gt; arguments with C string arguments. To instantiate a BCI2000Remote object, and obtain an object handle, call &amp;lt;tt&amp;gt;BCI2000Remote_New()&amp;lt;/tt&amp;gt;; specify this handle as a first argument to any BCI2000Remote member function you would like to call, and finally delete the object by specifying its handle as an argument to &amp;lt;tt&amp;gt;BCI2000Remote_Delete()&amp;lt;/tt&amp;gt;. An object handle should always be treated as an opaque reference, and never be cast to a pointer of type &amp;lt;tt&amp;gt;BCI2000Remote*&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Similarly, &amp;lt;tt&amp;gt;BCI20000Remote_NewWatch()&amp;lt;/tt&amp;gt; returns a reference to a watch object as a &amp;lt;tt&amp;gt;void*&amp;lt;/tt&amp;gt;. Once you are done with the watch object, call &amp;lt;tt&amp;gt;BCI2000Remote_DeleteWatch()&amp;lt;/tt&amp;gt; to dispose of it.&lt;br /&gt;
&lt;br /&gt;
Any function that returns a C string as a &amp;lt;tt&amp;gt;const char*&amp;lt;/tt&amp;gt; may return a zero pointer, indicating failure, or a valid pointer to a C string, indicating success. If a valid pointer is returned, the associated memory has been allocated by the library, and will be invalidated by the next call to a C string returning function. Earlier versions of BCI2000RemoteLib required to call &amp;lt;tt&amp;gt;BCI2000Release()&amp;lt;/tt&amp;gt; after receiving a C string. This is no longer the case. Instead, the memory allocated for the C string is deallocated on the next call that returns a C string.&lt;br /&gt;
&lt;br /&gt;
==Python Variations==&lt;br /&gt;
There is a wrapper to BCI2000RemoteLib in Python, which lets you call functions that are very similar to the BCI2000Remote class. Most of the members are documented above, however the syntax is different for some. There are a couple new functions as well, all of which will be highlighted here.&lt;br /&gt;
===Get &amp;lt;Variable&amp;gt;===&lt;br /&gt;
For the &amp;quot;Get&amp;quot; functions (e.g., GetState, GetParameter, GetEvent), instead of passing a variable by reference, the return value is set to the desired variable (e.g., the state, parameter, event). For example, the syntax is &amp;lt;code&amp;gt; state = bci.GetStateVariable(&amp;quot;StimulusCode&amp;quot;) &amp;lt;/code&amp;gt;, where &amp;lt;code&amp;gt;state&amp;lt;/code&amp;gt; is a c_double that is the value of the state.&lt;br /&gt;
===Additional functions===&lt;br /&gt;
*&amp;lt;b&amp;gt;Quit()&amp;lt;/b&amp;gt;: quits the system&lt;br /&gt;
*&amp;lt;b&amp;gt;GetListParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a list, this returns an array of the parameter values in the list&lt;br /&gt;
*&amp;lt;b&amp;gt;GetMatrixParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a matrix, this returns a 2d array of the matrix&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
See the [[User Tutorial:BCI2000Remote|user tutorial page]] for C++, Matlab, and Python examples!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Tutorial:BCI2000Remote]], &amp;lt;!--[[Contributions:BCI2000Automation]],--&amp;gt; [[Contributions:BCI2000PresentationLink]], [[Contributions:BCI2000Command]], [[Contributions:BCI2000PythonBindings]], [[Contributions:Applications]]&lt;br /&gt;
&lt;br /&gt;
[[Category:External Interfaces]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12616</id>
		<title>Programming Reference:BCI2000Remote Class</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:BCI2000Remote_Class&amp;diff=12616"/>
		<updated>2026-10-08T17:26:35Z</updated>

		<summary type="html">&lt;p&gt;Mellinger: /* bool PutParameterJson( string json ) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synopsis==&lt;br /&gt;
BCI2000Remote is a proxy interface class to the BCI2000 Operator module, and allows to start up, configure, and control BCI2000 from other applications. Internally, it maintains a telnet connection to the Operator module, and sends [[User Reference:Operator Module Scripting|Operator Scripting commands]] to control it. However, no knowledge of these scripting commands is required in order to use the BCI2000Remote class from your own application.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote is most useful when writing applications in C++, or in another language for which bindings to the [[#BCI2000RemoteLib|BCI2000RemoteLib]] library exist, such as Python, or MATLAB through the &amp;lt;tt&amp;gt;loadlibrary&amp;lt;/tt&amp;gt; command, specifying &amp;lt;tt&amp;gt;src/core/Operator/BCI2000Remote/BCI2000RemoteLib.h&amp;lt;/tt&amp;gt; as the header file associated with the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--For controlling BCI2000 under Windows from MATLAB, Windows Automation compatible scripting languages, or .NET languages, there exists a separate [[Contributions:BCI2000Automation|automation interface]].--&amp;gt;&lt;br /&gt;
For controlling BCI2000 from shell scripts (such as the Windows command interpreter, or Unix shells like bash), there exists a [[Contributions:BCI2000Command|BCI2000 command executable]] and the [[User_Reference:BCI2000Shell|BCI2000Shell]].&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
BCI2000/src/core/Operator/BCI2000Remote&lt;br /&gt;
&lt;br /&gt;
==Functional Description==&lt;br /&gt;
After instantiating a BCI2000Remote object, set its OperatorPath property to point to the desired BCI2000 Operator module. Then, call its Connect() method to start up that module, and connect to it. You may then use the StartupModules() method in order to start up BCI2000 core modules.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you may specify the path to a BCI2000 batch file in the BCI2000/batch directory. An appropriate batch file should start up Operator and core modules, and needs to forward its command line arguments to the Operator module. All batch files coming with BCI2000 fulfill this condition. When a batch file is specified, there is no need to call the StartupModules() method.&lt;br /&gt;
&lt;br /&gt;
As yet another option, you may connect to an Operator module that is already running, e.g., on a remote machine on the network. In this case, set the BCI2000Remote object&#039;s OperatorPath property to an empty string, and its TelnetAddress property to the address that the remote Operator module is listening on, i.e. the remote machine&#039;s IP address, followed with a colon, and the port specified when starting up the remote Operator module. The remote Operator module must have been started with the &amp;quot;--Telnet&amp;quot; command line option, followed with the address to listen on. On the remote machine, this would typically be &amp;quot;localhost:3999&amp;quot;. Don&#039;t use any of the ports between 4000 and 4002, as this will interfere with the communication between the Operator module, and BCI2000 core modules. Depending on whether the remote Operator module has been started up together with its core modules, or not, you may then call the StartupModules() method in order to start up BCI2000 core modules on the remote machine.&lt;br /&gt;
&lt;br /&gt;
Once all BCI2000 modules are running, you may load parameter files locally or remotely using the LoadParametersLocal() and LoadParametersRemote() methods. Subject ID, Session ID, and data directory are set using the respective BCI2000Remote properties.&lt;br /&gt;
&lt;br /&gt;
A recording may then be started by calling the Start() method. Depending on configuration, the recording will terminate automatically, or needs to be terminated by a call to the Stop() method.&lt;br /&gt;
&lt;br /&gt;
To run BCI2000 in a different configuration (i.e., with different core modules), it is not necessary to terminate the Operator module. Rather, you may execute StartupModules() multiple times in order to terminate currently running core modules, and start different ones.&lt;br /&gt;
&lt;br /&gt;
Once you are done using BCI2000, you may close the connection by calling the Disconnect() method, or by deleting the BCI2000Remote object. Depending on whether the Operator module was started up by the previous Connect() call, this will terminate the Operator module as well. When connection was made to an already running Operator module, local or remote, the connection will be closed but the Operator module will remain running.&lt;br /&gt;
&lt;br /&gt;
==BCI2000Remote Members==&lt;br /&gt;
The BCI2000Remote class has the following members:&lt;br /&gt;
===Properties===&lt;br /&gt;
====double Timeout=5 (rw)====&lt;br /&gt;
Timeout in seconds. Applies when establishing communication between BCI2000Remote and BCI2000.&lt;br /&gt;
&lt;br /&gt;
====string OperatorPath=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Path to Operator module, or batch file. When empty, BCI2000Remote tries to connect to an already running Operator module which may be on a different machine, depending on the &#039;&#039;TelnetAddress&#039;&#039; setting. When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module.&lt;br /&gt;
&lt;br /&gt;
====string TelnetAddress=&amp;quot;&amp;quot; (rw)====&lt;br /&gt;
Telnet address to use for connection to a remote machine. To connect to a remote machine, specify the machine&#039;s IP address, followed with BCI2000&#039;s listening port. You should take care to avoid specifying a port that is used by BCI2000&#039;s internal connections between Operator and core modules. By default, these are 4000, 4001, and 4002.&lt;br /&gt;
&lt;br /&gt;
When &#039;&#039;OperatorPath&#039;&#039; is given and &#039;&#039;TelnetAddress&#039;&#039; is empty, BCI2000Remote will use a named pipe for communication with the Operator module. This is preferable for security reasons.&lt;br /&gt;
&lt;br /&gt;
=====bool WindowVisible=2 (rw)=====&lt;br /&gt;
Visibility of the BCI2000 main window. 0: Invisible, 1: visible, 2: don&#039;t change.&lt;br /&gt;
&lt;br /&gt;
====string WindowTitle (rw)====&lt;br /&gt;
The title of the BCI2000 main window.&lt;br /&gt;
====string Result (r)====&lt;br /&gt;
Text output of the previously executed command, or an error message when the previously executed command failed.&lt;br /&gt;
====Recording information====&lt;br /&gt;
=====string SubjectID (rw)=====&lt;br /&gt;
The subject ID for the next recording. When this property is empty, the subject ID is taken from the current value of the SubjectName parameter.&lt;br /&gt;
=====string SessionID (rw)=====&lt;br /&gt;
The session ID for the next recording. When this property is empty, the session ID is taken from the SubjectSession parameter.&lt;br /&gt;
=====string DataDirectory (rw)=====&lt;br /&gt;
The data directory for the next recording. When a relative path is given, it is taken relative to BCI2000/data. When this property is empty, the data directory is taken from the DataDirectory parameter.&lt;br /&gt;
&lt;br /&gt;
===Connection methods===&lt;br /&gt;
====bool Connect()====&lt;br /&gt;
Connect to BCI2000. When OperatorPath is not empty, and no operator module is listening at TelnetAddress, this starts up the operator module before connecting. Will return true on success.&lt;br /&gt;
&lt;br /&gt;
====bool Connect( BCI2000Remote )====&lt;br /&gt;
Connects to the same Operator module as the BCI2000Remote instance given as an argument. This will not start BCI2000 when it is not running, thus it is necessary that the argument instance&#039;s Connect() method has been called before.&lt;br /&gt;
&lt;br /&gt;
====bool Disconnect()====&lt;br /&gt;
Disconnect from an existing connection. Terminates the running operator module if it was started by the previous Connect() call.&lt;br /&gt;
&lt;br /&gt;
===Control of operation===&lt;br /&gt;
====bool StartupModules( vector(string) modules )====&lt;br /&gt;
Start BCI2000 core modules, listed by executable name, including possible command line arguments. Each entry in the array corresponds to a single core module, given relative to the Operator module&#039;s working directory, which defaults to BCI2000/prog. You do not need to call this function if the OperatorPath property specifies a batch file rather than the Operator module itself.&lt;br /&gt;
====bool SetConfig()====&lt;br /&gt;
Applies the current set of parameters. Will be called from Start() automatically. Returns false if parameters could not be set, e.g. because the system was in running state, or because there was a preflight error when applying parameters. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Start()====&lt;br /&gt;
Starts a new run (recording) with current parameters. Returns false if the run could not be started. Use the Result property to obtain more error information.&lt;br /&gt;
====bool Stop()====&lt;br /&gt;
Stops the current run (recording).&lt;br /&gt;
&lt;br /&gt;
===Parameters and system state===&lt;br /&gt;
====bool GetParameter( string name, string&amp;amp; value )====&lt;br /&gt;
Copies the specified parameter&#039;s value into the &#039;&#039;value&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
====bool SetParameter( string name, string value )====&lt;br /&gt;
Sets the specified parameter to the given value. The parameter must exist in the system. To add a parameter, use the Execute() method in conjunction with the [[User Reference:Operator Module Scripting#ADD PARAMETER &amp;lt;parameter definition&amp;gt;|ADD PARAMETER]] scripting command.&lt;br /&gt;
&lt;br /&gt;
====bool ShowParameterJson( string name, string&amp;amp; json )====&lt;br /&gt;
Copies the specified parameter into the &#039;&#039;json&#039;&#039; output argument. Returns false if parameter does not exist.&lt;br /&gt;
&lt;br /&gt;
====bool PutParameterJson( string json )====&lt;br /&gt;
Constructs a parameter from the given JSON representation, and applies it to the parameter list.&lt;br /&gt;
The parameter must exist in the system. To add a parameter, use the Execute() method in conjunction with the [[User Reference:Operator Module Scripting#ADD [JSON] PARAMETER &amp;lt;parameter definition&amp;gt;|ADD JSON PARAMETER]] scripting command.&lt;br /&gt;
&lt;br /&gt;
====bool LoadParametersLocal( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the calling application. This function returns false if the specified file was not found but will not provide information whether parameters were sent successfully. Rather, illegal parameter lines will be silently ignored.&lt;br /&gt;
====bool LoadParametersRemote( string file )====&lt;br /&gt;
Load parameters from a file, relative to the working directory of the Operator module connected to. Unless explicitly changed, that working directory is the BCI2000/prog directory in which the Operator module resides.&lt;br /&gt;
&lt;br /&gt;
====bool AddStateVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds a [[Technical_Reference:State_Definition|state variable]] to the system. This is only possible before core modules have connected to the Operator module.&lt;br /&gt;
State variables added by &#039;&#039;AddStateVariable()&#039;&#039; are plain state variables (i.e., not event or stream state variables).&lt;br /&gt;
&lt;br /&gt;
====bool GetStateVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 state variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
&#039;&#039;GetStateVariable()&#039;&#039; will retrieve values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool SetStateVariable( string name, double value )====&lt;br /&gt;
Sets the value of the named BCI2000 state variable to the given value. Returns false on error.&lt;br /&gt;
&#039;&#039;SetStateVariable()&#039;&#039; can set values of plain state variables as well as stream state variables, but not event state variables.&lt;br /&gt;
&lt;br /&gt;
====bool AddEventVariable( string name, int bitWidth, double initialValue )====&lt;br /&gt;
Adds an [[Technical_Reference:State_Definition#Events|event variable]] to the system. This is only possible before core modules have connected to the Operator module.	&lt;br /&gt;
====bool GetEventVariable( string name, double&amp;amp; value )====&lt;br /&gt;
Gets the value of a named BCI2000 event variable. If no error occurred, the value will be copied into the &amp;quot;value&amp;quot; output variable.&lt;br /&gt;
====bool SetEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value. Returns false on error.&lt;br /&gt;
====bool PulseEventVariable( string name, double value )====&lt;br /&gt;
Asynchronously sets the value of the named BCI2000 event variable to the given value, for the duration of a single sample.&lt;br /&gt;
Returns false on error.&lt;br /&gt;
&lt;br /&gt;
====bool GetSystemState( string&amp;amp; state )====&lt;br /&gt;
Gets the current system state (i.e., state of operation). If no error occurred, the &amp;quot;state&amp;quot; output variable will contain the name of the current system state, which will be one of the names listed at [[User Reference:Operator Module Scripting#GET_SYSTEM_STATE]].&lt;br /&gt;
====bool GetControlSignalChannels( double&amp;amp; channels )====&lt;br /&gt;
Copies the number of control signal channels into the &amp;quot;channels&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignalElements( double&amp;amp; elements )====&lt;br /&gt;
Copies the number of control signal elements into the &amp;quot;elements&amp;quot; output variable.&lt;br /&gt;
&lt;br /&gt;
====bool GetControlSignal( int channel, int element, double&amp;amp; value )====&lt;br /&gt;
Copies the value of the control signal at the given indices into the &amp;quot;value&amp;quot; output variable. Indices are 1-based. Typically, the control signal has only a single element, and the number of output channels corresponds to the number of feedback dimensions in feedback experiments, or is 1 in evoked potential experiments.&lt;br /&gt;
&lt;br /&gt;
===Scripting methods===&lt;br /&gt;
====bool Execute( string command, int* exitCode = 0 )====&lt;br /&gt;
Execute an arbitrary BCI2000 scripting command. A return value of &amp;quot;true&amp;quot; does not indicate successful execution of the command; rather, it indicates that the command was sent, and its result was received. In general, the &#039;&#039;&#039;Result&#039;&#039;&#039; property needs to be examined in order to determine whether the command was executed successfully.&lt;br /&gt;
&lt;br /&gt;
In many cases, the optional &#039;&#039;exitCode&#039;&#039; argument may be specified to obtain the result status of a command in an integer variable that the &#039;&#039;exitCode&#039;&#039; pointer points to.&lt;br /&gt;
The exact meaning of the exit code depends on the command that has been executed, so it is necessary to be aware of a command&#039;s possible responses before evaluating an exit code.&lt;br /&gt;
&lt;br /&gt;
In detail, the exit code is determined as follows:&lt;br /&gt;
* When Execute() is used to execute a SYSTEM command, the exit code will match the exit code of the program that was run through the SYSTEM command. By convention, such exit codes are nonzero on failure, and zero on success.&lt;br /&gt;
* For other commands, the exit code is derived from the &#039;&#039;&#039;Result&#039;&#039;&#039; property as follows:&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; may be interpreted as a single floating point number, the exit code will be 0 for a nonzero number, and 1 if the number is zero.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot; (without considering case), the exit code will be 0 for &amp;quot;true&amp;quot;, and 1 for &amp;quot;false&amp;quot;.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; is empty, the exit code will be 0.&lt;br /&gt;
** If &#039;&#039;&#039;Result&#039;&#039;&#039; does not match any of the previous conditions, the exit code will be -1 to indicate that there was no obvious interpretation.&lt;br /&gt;
&lt;br /&gt;
This scheme is chosen to simplify client code for the most common cases:&lt;br /&gt;
* external programs run through the SYSTEM command,&lt;br /&gt;
* commands which do not have an output except in case of failure,&lt;br /&gt;
* functions returning binary values, such as the test command,&lt;br /&gt;
* expressions evaluated as logical conditions.&lt;br /&gt;
In all these cases, the exit code will be 0 on success, and 1 on failure.&lt;br /&gt;
&lt;br /&gt;
When executing a command that may return an arbitrary string (e.g., EXECUTE SCRIPT, or ECHO), the exit code should not be used. In this case, the &#039;&#039;exitCode&#039;&#039; argument may be omitted, or may be NULL.&lt;br /&gt;
&lt;br /&gt;
A full documentation of BCI2000 Operator scripting commands is available under [[User Reference:Operator Module Scripting]].&lt;br /&gt;
&lt;br /&gt;
====bool SetScript( string handlers, string script )====&lt;br /&gt;
Associate a sequence of BCI2000 scripting commands with the specified events. Events are given by name, as defined in the [[User Reference:Operator Module Scripting|scripting reference]]. Multiple handler names may be specified, concatenated with a pipe &#039;|&#039; character.&lt;br /&gt;
&lt;br /&gt;
====bool GetScript( string handler, string&amp;amp; script )====&lt;br /&gt;
Copy the handler script into the &#039;&#039;script&#039;&#039; output variable.&lt;br /&gt;
&lt;br /&gt;
===Watches===&lt;br /&gt;
====Watch* NewWatch( string expression, WatchCallback, void* callbackData )====&lt;br /&gt;
Creates a new watch object that watches on the expression or expressions given, and calls the specified callback each time the expression value changes. CallbackData is arbitrary user data (e.g., a pointer to an object) required for processing the callback.&lt;br /&gt;
If multiple expressions are given, they must be separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
The watch object may be disposed of by calling an ordinary delete.&lt;br /&gt;
&lt;br /&gt;
====void WatchCallback( void* callbackData, const char* values )====&lt;br /&gt;
Signature of a user-defined callback function that receives expression values, along with the arbitrary user data stored in callbackData. The values string starts with millisecond timestamp, followed with one value for each expression, and a trailing CRLF. Values are separated by tab characters.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
To facilitate the use of BCI2000Remote, it only depends on very few files from the BCI2000 framework. To use BCI2000Remote in a C++ project, you will need to add the following cpp files to the project, and their parent directories to the list of include paths:&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Remote.cpp&lt;br /&gt;
 BCI2000/src/core/Operator/BCI2000Remote/BCI2000Connection.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SockStream.cpp&lt;br /&gt;
 BCI2000/src/shared/utils/Lib/SelfPipe.cpp&lt;br /&gt;
Also, on Windows you will need to link against this additional library:&lt;br /&gt;
 WS2_32&lt;br /&gt;
&lt;br /&gt;
==[[Technical Reference:BCI2000Remote Library|BCI2000RemoteLib]]==&lt;br /&gt;
The BCI2000RemoteLib is a dynamic library that exports a C-style wrapper around the BCI2000Remote class, such that it may be used from scripting languages that support execution of library code. A C-style wrapper is required because no stable conventions exist regarding the export of classes and objects from dynamic libraries.&lt;br /&gt;
&lt;br /&gt;
BCI2000Remote member functions are directly mapped on C functions by adding an object handle as a first argument, and by replacing &amp;lt;tt&amp;gt;std::string&amp;lt;/tt&amp;gt; arguments with C string arguments. To instantiate a BCI2000Remote object, and obtain an object handle, call &amp;lt;tt&amp;gt;BCI2000Remote_New()&amp;lt;/tt&amp;gt;; specify this handle as a first argument to any BCI2000Remote member function you would like to call, and finally delete the object by specifying its handle as an argument to &amp;lt;tt&amp;gt;BCI2000Remote_Delete()&amp;lt;/tt&amp;gt;. An object handle should always be treated as an opaque reference, and never be cast to a pointer of type &amp;lt;tt&amp;gt;BCI2000Remote*&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Similarly, &amp;lt;tt&amp;gt;BCI20000Remote_NewWatch()&amp;lt;/tt&amp;gt; returns a reference to a watch object as a &amp;lt;tt&amp;gt;void*&amp;lt;/tt&amp;gt;. Once you are done with the watch object, call &amp;lt;tt&amp;gt;BCI2000Remote_DeleteWatch()&amp;lt;/tt&amp;gt; to dispose of it.&lt;br /&gt;
&lt;br /&gt;
Any function that returns a C string as a &amp;lt;tt&amp;gt;const char*&amp;lt;/tt&amp;gt; may return a zero pointer, indicating failure, or a valid pointer to a C string, indicating success. If a valid pointer is returned, the associated memory has been allocated by the library, and will be invalidated by the next call to a C string returning function. Earlier versions of BCI2000RemoteLib required to call &amp;lt;tt&amp;gt;BCI2000Release()&amp;lt;/tt&amp;gt; after receiving a C string. This is no longer the case. Instead, the memory allocated for the C string is deallocated on the next call that returns a C string.&lt;br /&gt;
&lt;br /&gt;
==Python Variations==&lt;br /&gt;
There is a wrapper to BCI2000RemoteLib in Python, which lets you call functions that are very similar to the BCI2000Remote class. Most of the members are documented above, however the syntax is different for some. There are a couple new functions as well, all of which will be highlighted here.&lt;br /&gt;
===Get &amp;lt;Variable&amp;gt;===&lt;br /&gt;
For the &amp;quot;Get&amp;quot; functions (e.g., GetState, GetParameter, GetEvent), instead of passing a variable by reference, the return value is set to the desired variable (e.g., the state, parameter, event). For example, the syntax is &amp;lt;code&amp;gt; state = bci.GetStateVariable(&amp;quot;StimulusCode&amp;quot;) &amp;lt;/code&amp;gt;, where &amp;lt;code&amp;gt;state&amp;lt;/code&amp;gt; is a c_double that is the value of the state.&lt;br /&gt;
===Additional functions===&lt;br /&gt;
*&amp;lt;b&amp;gt;Quit()&amp;lt;/b&amp;gt;: quits the system&lt;br /&gt;
*&amp;lt;b&amp;gt;GetListParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a list, this returns an array of the parameter values in the list&lt;br /&gt;
*&amp;lt;b&amp;gt;GetMatrixParameter(name)&amp;lt;/b&amp;gt;: if the parameter is a matrix, this returns a 2d array of the matrix&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
See the [[User Tutorial:BCI2000Remote|user tutorial page]] for C++, Matlab, and Python examples!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Tutorial:BCI2000Remote]], &amp;lt;!--[[Contributions:BCI2000Automation]],--&amp;gt; [[Contributions:BCI2000PresentationLink]], [[Contributions:BCI2000Command]], [[Contributions:BCI2000PythonBindings]], [[Contributions:Applications]]&lt;br /&gt;
&lt;br /&gt;
[[Category:External Interfaces]]&lt;/div&gt;</summary>
		<author><name>Mellinger</name></author>
	</entry>
</feed>