Please enable JavaScript to view this site.

DAQFactory User's Guide

Navigation: 5 Sequences & Scripting

5.2 Creating a New Sequence

Scroll Prev Top Next More

Sequence script is used in different places within DAQFactory.  For example, you can add sequence code that executes when a user clicks on a page component.  These sort of events are part of the object they apply to and are simply a parameter of that object.  Most sequence scripts, however, are standalone objects to perform different tasks in your application.   Each sequence is listed in the workspace under SEQUENCES:.  You can also click on SEQUENCES: to display the sequence summary view that will display all your standalone sequences and their current status.  To create a new sequence, you can either right click on SEQUENCES: in the workspace and select Add Sequence, or select Add Sequence from the sequence summary view.  You will be prompted for a name, which like the rest of DAQFactory object names, must start with a letter and only contain letters, numbers and the underscore.  After this you will be placed in the sequence view for your new sequence.

Sequences look a lot like most scripting languages, and the sequence view is simply a text editor with some advanced features.  Sequences are made up of multiple steps.  Each step is entered on a separate line in the sequence view.  You are free to add blank lines to make things easier to read.  You can also add comments, which are not used by the sequence itself, but will help you remember what your sequences does.  Comments can be added to the end of any line or on their own line by typing two slashes "//".  For example:

 

global X = 32  // set the X variable to 32

// and now set it to 40:

X = 40

 

You can also comment a block of code using “/*” and “*/”.  For example:

 

global X = 32  /* this is a comment

this is still a comment */

X = 40

Indentation Conventions:

To make sequences easier to read, we strongly recommend using indenting to organize your code.  Block operations are typically indented three spaces to clearly display the block.  For example:

 

if (condition)

  do something

  and something else

else

  do something

endif

You can manually indent or outdent blocks of code by selecting the block and pressing tab or shift-tab.

Breaking up Long Lines:

You can break up long lines of sequence code using the backslash. The next line of code is assumed to start where the backslash is placed:

 

if ((x < 5) && (y > 6) && \

  (z > 3))

  … do something

endif

The backslash cannot be used inside of a quoted string:

NO:

 

strMyString = "The quick brown fox jumped over \

  the lazy dogs tail"

 

Yes:

 

strMyString = "The quick brown fox jumped over " + \

  "the lazy dogs tail"

Saving Changes:

To save the changes made to a sequence, click the Apply button.  Alternatively, if you want to check for possible syntax errors, you can click Apply & Compile and the sequence will be saved and compiled.  If you do not compile, the sequence will automatically be compiled when you try and run it.  

Note: If you apply changes to a sequence that is running, you must stop and restart the sequence before the changes will take effect.  Likewise, if you apply changes to a sequence that is called from another running sequence or expression, the changes will not apply until the sequence has returned.

To quickly save your sequence, compile it and run it (or restart it if it is already running), select Debug - Start Sequence.  Note that this menu item will change depending on whether the sequence is compiled and whether it is already running.  You can also use F5 to do the same thing.

Separate Editor Window:

In many cases it is more handy to edit your sequences in a separate window instead of the normal DAQFactory window.  To do so, right click on the sequence name in the workspace and select Edit in Separate Window.  This will display a new window with the sequence editor.  This window has its own menu, duplicating the appropriate functionality of the regular DAQFactory menu.  Initially this window will appear on top of the main area of DAQFactory, but it is a standard window and can be moved about as needed.  You can leave this window open while working with the rest of DAQFactory.  This can be very helpful when you need to test a sequence and need to see your pages to see the results.  To switch between windows you can do several things:

1) Each window will appear as a separate item in the Window's Taskbar.  The icon is slightly different then the standard DAQFactory icon, and the sequence name is indicated.  

2) You can use Alt-Tab and Shift-Alt-Tab to switch among windows as they appear as separate tasks inside of windows.

3) Once a separate window is open for a particular sequence, clicking on the sequence in the workspace will make the window appear.  Note that if you close the separate window, you will have to reopen with Edit in Separate Window.

Note: you can only have one window open for a particular sequence.