Please enable JavaScript to view this site.

DAQFactory User's Guide

Navigation: 5 Sequences & Scripting

5.12 Conditional branching with the if statement

Scroll Prev Top Next More

DAQFactory can easily do different things depending on the state of your system or anything else.  The if/else/endif statements provide the mechanism for this:

 

if (Input[0] > 5)

  do something when the latest value of Input is greater than 5

else

  do something when the latest value of Input is less than or equal to 5

endif

The else is actually optional.  You can of course put multiple steps inside the if:

 

if (Input[0] > 5)

  Output = 3

  AnotherOut = 2

endif

You can also nest ifs inside of one another:

 

if (Input[0] > 5)

  if (AnotherInput[0] > 3)

    Output = 3

  else

    Output = 2

  endif

  AnotherOut = 2

endif

For that matter, you can nest while and for loops or other block structures inside of each other.  Just make sure everything lines up correctly:

OK:

 

if (Input[0] > 5)

  for (Private.Count = 0, Private.Count < 10, Private.Count++)

    Output = Private.Count

  endfor

endif

NO:

 

if (Input[0] > 5)

  for (Private.Count = 0, Private.Count < 10, Private.Count++)

    Output = Private.Count

  endif

endfor