webCOMAND

cScript Reference

cScript is the COMAND script language, most commonly used to define procedures started by scheduled events, repository content updates and actions performed in the webCOMAND interface.

cScript can also be used with #CSCRIPT in cTemplate.

Here is an example of what cScript looks like:

// A simple list of contacts.
insert(Template,Header);
echo('<ul>');
list(Contacts) {
	echo('<li><a href="' + link(Contact,'ID=$ID') + '">$Name</a></li>')
}
echo('</ul>');
insert(Template,Footer);

Language

cScript provides features similar to other scripting languages, including variables and flow control (if/then conditions, loops and iterators).  Code looks similar to programming languages such as PHP and JavaScript, where echo() is used to output text and semi-colons separate statements.

  • Variables - A dollar sign ($) followed by a letter and zero or more letters, numbers or underscores will be interpreted as a variable.  A variable represents a value.  When cScript is processed, variables are replaced by their values.  For example, $FullName.
  • Functions - A valid cScript function name will be interpreted as described in cScript Functions.  For example, link(WebPage,'OID=1234').  Functions are separated by a semi-colon.
  • Whitespace - Whitespace not inside a string is ignored.
  • Text - All other text (and binary data) will produce an error.

Security

cScript statements provide programmatic access to COMAND Repository content and features, typically without low-level access to the server.  This enables end-users to author templates and procedures without compromising server security.  cScript features can be further restricted to "read-only" functionality, eliminating the ability to update the repository.  Or, unrestricted features can be enabled to allow low-level access to the server in trusted code environments.