Notice: Constant DATE_RFC7231 already defined in /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc on line 258
Variables | ComScript Manual

Error message

  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in drupal_environment_initialize() (line 690 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in drupal_environment_initialize() (line 691 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in drupal_environment_initialize() (line 692 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in drupal_environment_initialize() (line 695 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in drupal_environment_initialize() (line 697 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in include_once() (line 290 of /home2/greeneye/public_html/comscript_manual/sites/default/settings.php).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in include_once() (line 291 of /home2/greeneye/public_html/comscript_manual/sites/default/settings.php).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in include_once() (line 299 of /home2/greeneye/public_html/comscript_manual/sites/default/settings.php).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in include_once() (line 306 of /home2/greeneye/public_html/comscript_manual/sites/default/settings.php).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in drupal_settings_initialize() (line 860 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in drupal_settings_initialize() (line 869 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: session_name(): Cannot change session name when headers already sent in drupal_settings_initialize() (line 872 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc:258) in _drupal_bootstrap_page_cache() (line 2485 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: session_set_save_handler(): Cannot change save handler when headers already sent in drupal_session_initialize() (line 242 of /home2/greeneye/public_html/comscript_manual/includes/session.inc).
  • Warning: session_id(): Cannot change session id when headers already sent in drupal_session_initialize() (line 266 of /home2/greeneye/public_html/comscript_manual/includes/session.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc:258) in drupal_send_headers() (line 1305 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc:258) in drupal_send_headers() (line 1305 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in book_prev() (line 775 of /home2/greeneye/public_html/comscript_manual/modules/book/book.module).
  • Warning: Cannot modify header information - headers already sent by (output started at /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc:258) in drupal_send_headers() (line 1305 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc:258) in drupal_send_headers() (line 1305 of /home2/greeneye/public_html/comscript_manual/includes/bootstrap.inc).
  • Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /home2/greeneye/public_html/comscript_manual/includes/common.inc).

Variables

Variables and their evaluation with conditional expressions are absolutely central to the power of ComScript.  All variables are treated as "global" so they are available throughout the profile.xml file as well as imported subscripts.  They also do not have to be "passed" from one script to another.  While this greatly simplifies variable handling in ComScript, users need to be careful not to reuse variable names in a particular project.  Variable names are also case sensitive so substituting X for x will cause an undesirable result. 

Set:

Unlike more complicated languages, ComScript variables types (e.g. int, float, double, char) do not have to be set and there are no memory allocation requirements.  Simply use the set command to set an initial value or to replace it with a new value.  Text variables (strings) are also supported with the set command.
 
Examples:
<set var="TempLimit" value="99" />
<set var="message" value="Temperature limit exceeded" />
 

Reference:

To reference a variable (write to a file, evaluate in a conditional expression, etc.) it must be enclosed in square brackets (e.g. [TempLimit] ) so that ComScript knows to substitute the current variable value into the expression or command.  If you see that the variable name in the console or the log file where you expect a variable value, it usually means that the square brackets were omitted, the variable name was misspelled or that no value was loaded.
 
Tip: Empty variables often cause problems in both conditional and math expressions.  Writing them to the desktop utility window with the log command is a simple way to verify a variable value.  
 
Examples:
<write file="MyDataFile.txt" string="The Temperature limit of [TempLimit] has been exceeded" /> note: [ ] around TempLimit variable
<math var="TempInC" expression="([TempInF] -32) *9/5" /> note: [ ] around TempInF to reference value stored in the variable, but not for the TempInC variable which is being set with the math command.
                  
<if condition="[TempInC] GT [TempLimit]" >
   <email to="jsmith@gmail.com" subject="Temperature alarm" message="The Temperature of [TempInC]
   has exceeded the limit of [TempLimit] " />
</if>
 

Parsing data into variables:

Variables can also be loaded directly from the set device with the send and collect commands or from files and strings with the loadvars command.  By using the trigger and terminator attributes of the send and collect commands, the input that comes in between them is loaded into the designated variable (var attribute).  This collection variable could be just one nice and neat single value captured between the trigger and terminator, but it's often an alphanumeric string that must be parsed (split) into individual variables.  This is achieved using the loadvars command that parses strings with multiple values into individual variables.
 
Example:
<send string="data request{13}" var="DataLine" trigger="data:" terminator="end" timeout="100"/>
<write file="MyDataFile.txt" string="The complete data line = [DataLine] {13}" />
<loadvars string="[DataLine]" delimiter="," vars="a,b,c,d,e" type="string" />
<write file="MyDataFile.txt" string="Parsed into variables (a,b,c,d,e): [a],[b],[c],[d],[e]{10}{13}" />
 
Explanation: In this example ComScript sends the string "data request" and a carriage return (ascii 13) to the set decvice.  The response of the device is initially parsed between "data" and " end". Lets assume that the device responds with 'data: 99, 100, 72, -999, valid end' so that the variable DataLine= 99, 100, 72, -999, valid.  The loadvars command breaks up the individual values in string [DataLine] that are separated or delimited by a ',' so that variables a=99, b=100, c=72, d=-999, and e=valid.  Variables a-e are now available to write to a file as is done in the example above or for evaluation in conditional expressions.  Data parsing can be a little tricky so Green Eyes has provided a detailed example profile with the ComScript download called DataLineParse that demonstrates how to parse a variety of data lines.
Users are strongly encouraged to run DataLineParse and to look at its profile.xml file and the output file to gain a strong understanding of data parsing.

Data Interface - Config.xml file

Variables can also be loaded with the loadvars command from the config.xml file that is used to include variables in the data interface. Because these variables are declared in the config.xml file they do not need to be set in the profile code.  Data interface variables can be changed by the user in the data interface (if editable="True" in config.xml) and/or by the operation of the profile.  See the data interface section to learn how to utilize this powerful feature.  Be aware that is the config.xml file is re-loaded when an entire profile loops, it will set the defined variables back to the values set in config.xml.
 
Example:
<loadvars file="config.xml" type="xml" />