Avoid overuse of sequence structures, Study the examples – National Instruments BridgeVIEW User Manual

Page 320

Advertising
background image

Chapter 16

Program Design

BridgeVIEW User Manual

16-8

© National Instruments Corporation

Notice that the preceding example still does not check for errors. For
instance, if the file does not exist, the program does not display a warning.
The following version of the block diagram illustrates one technique for
handling this problem. In this example, the block diagram uses the error
I/O inputs and outputs of these functions to propagate any errors to the
Simple Error Handler VI.

Avoid Overuse of Sequence Structures

Because VIs can operate with a great deal of inherent parallelism, avoid
using Sequence structures. Using a Sequence structure guarantees the order
of execution but prohibits parallel operations. For instance, asynchronous
tasks that use I/O devices (GPIB, serial ports, and data acquisition boards)
can run concurrently with other operations if Sequence structures do not
prevent them from doing so.

Sequence structures tend to hide parts of the program and interrupt the
natural left-to-right flow of data. You do not sacrifice performance by using
Sequence structures. However, when you need to sequence operations, you
might consider using data flow instead. For instance, in I/O operations you
might use the error I/O technique described previously to ensure that one
I/O operation occurs before another.

Study the Examples

For further information about program design, you can examine the many
example block diagrams included in BridgeVIEW. These sample programs
provide you with insights into G programming style and technique.
To view these block diagrams, open any of the VIs in the

Examples

directory.

Advertising