Please enable JavaScript to view this site.

DAQFactory User's Guide

Navigation: 4 Expressions

4.2 Using Expressions

Scroll Prev Top Next More

Expressions are essentially values calculated in real-time based on a formula you enter.  Expressions are used for simple things, such as determining what value or trace to display in a component, or for more complex things, such as what to evaluate in a sequence 'if' statement.

Expression edit boxes:

The expression edit boxes use syntax coloring, which colors the background of the edit box depending on the validity of the expression.  By default, the background displays green for a numeric result, blue for a string result, and red for an invalid expression or one that evaluates to a null value. This is actually an easy way to tell if you can enter an expression formula in for a parameter.  Only expressions use syntax coloring, so if the text you type is colored, then you can enter a formula.  There are some exceptions, such as the watch, that allow expressions but do not syntax color.

Note: a red background does not always mean you have typed something wrong.  It can also mean you have no data yet.  So, for example back in the guided tour we created an output channel named Out.  That channel didn't have any values initially so when we typed Out[0] in the expression for the variable value component it displayed in red.  Once we set Out to a value, that background would change to green.

Expression edit boxes have some other useful features too.  As you are typing, a drop down list may appear with a list of available channels, connections, sequences, pages, functions, and other DAQFactory objects.  You can either select from the list using the mouse, or keep typing and the list will track your typing.  When the desired item is selected in the box, you can simply type an operator, space, or Enter key to automatically complete your selection.  Once selected, a tooltip will briefly appear above your typing displaying either the quick note of the channel or the format of a function if available.  If you want to see the drop down list of without typing a name, you can also hit Ctrl-Space.