G Programming Reference Manual
G Programming Reference Manual
Reference Manual
Internet Support
GPIB: [email protected]
DAQ: [email protected]
LabVIEW: [email protected]
BridgeVIEW: [email protected]
Lookout: [email protected]
E-mail: [email protected]
FTP Site: ftp.natinst.com
Web Address: http://www.natinst.com
Bulletin Board Support
(512) 418-1111
International Offices
Important Information
Warranty
The media on which you receive National Instruments software are warranted not to fail to execute programming
instructions, due to defects in materials and workmanship, for a period of 90 days from date of shipment, as evidenced
by receipts or other documentation. National Instruments will, at its option, repair or replace software media that do
not execute programming instructions if National Instruments receives notice of such defects during the warranty
period. National Instruments does not warrant that the operation of the software shall be uninterrupted or error free.
A Return Material Authorization (RMA) number must be obtained from the factory and clearly marked on the outside
of the package before any equipment will be accepted for warranty work. National Instruments will pay the shipping
costs of returning to the owner parts which are covered by warranty.
National Instruments believes that the information in this manual is accurate. The document has been carefully
reviewed for technical accuracy. In the event that technical or typographical errors exist, National Instruments reserves
the right to make changes to subsequent editions of this document without prior notice to holders of this edition. The
reader should consult National Instruments if errors are suspected. In no event shall National Instruments be liable for
any damages arising out of or related to this document or the information contained in it.
EXCEPT AS SPECIFIED HEREIN , N ATIONAL INSTRUMENTS MAKES NO WARRANTIES, EXPRESS OR IMPLIED , AND
SPECIFICALLY DISCLAIMS ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE .
CUSTOMERS RIGHT TO RECOVER DAMAGES CAUSED BY FAULT OR NEGLIGENCE ON THE PART OF NATIONAL
INSTRUMENTS SHALL BE LIMITED TO THE AMOUNT THERETOFORE PAID BY THE CUSTOMER. N ATIONAL INSTRUMENTS
WILL NOT BE LIABLE FOR DAMAGES RESULTING FROM LOSS OF DATA , PROFITS , USE OF PRODUCTS , OR INCIDENTAL OR
CONSEQUENTIAL DAMAGES , EVEN IF ADVISED OF THE POSSIBILITY THEREOF. This limitation of the liability of National
Instruments will apply regardless of the form of action, whether in contract or tort, including negligence. Any action
against National Instruments must be brought within one year after the cause of action accrues. National Instruments
shall not be liable for any delay in performance due to causes beyond its reasonable control. The warranty provided
herein does not cover damages, defects, malfunctions, or service failures caused by owners failure to follow the
National Instruments installation, operation, or maintenance instructions; owners modification of the product;
owners abuse, misuse, or negligent acts; and power failure or surges, fire, flood, accident, actions of third parties, or
other events outside reasonable control.
Copyright
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical,
including photocopying, recording, storing in an information retrieval system, or translating, in whole or in part,
without the prior written consent of National Instruments Corporation.
Trademarks
LabVIEW and BridgeVIEW are trademarks of National Instruments Corporation.
Product and company names listed are trademarks or trade names of their respective companies.
Table of
Contents
Table of Contents
Chapter 2
Building VIs
G Environment ................................................................................................................ 2- 1
Tools Palette...................................................................................................... 2-4
Menus in G........................................................................................................ 2-6
Pop-Up Menus .................................................................................... 2-6
Editing VIs.................................................................................................................... ... 2-7
Selecting Objects............................................................................................... 2-7
Dragging and Dropping VIs, Pictures, and Text in G....................................... 2-8
Positioning Objects ........................................................................................... 2-9
Aligning Objects ............................................................................................... 2-11
Distributing Objects .......................................................................................... 2-12
Duplicating Objects........................................................................................... 2-12
Deleting Objects................................................................................................ 2-13
Labeling Objects ............................................................................................... 2-14
Free Labels ......................................................................................... 2-14
Text Characteristics ............................................................................ 2-16
Resizing Objects ............................................................................................... 2-23
Labels.................................................................................................. 2-23
Front Panel and Block Diagram Work Space..................................... 2-24
Coloring Objects ............................................................................................... 2-24
Creating Object Descriptions ............................................................................ 2-26
Creating VI Descriptions .................................................................................. 2-27
Saving VIs ..................................................................................................................... .. 2-27
Individual VI Files ............................................................................................ 2-28
VI Libraries (.LLBs) ......................................................................................... 2-29
Creating VI Libraries.......................................................................... 2-30
Saving in Existing VI Libraries .......................................................... 2-30
Editing the Contents of Libraries........................................................ 2-30
Chapter 3
Building SubVIs
Hierarchical Design ......................................................................................................... 3-1
Creating SubVIs from VIs............................................................................................... 3-1
Creating the Icon ............................................................................................... 3-2
Defining Connector Terminal Patterns ............................................................. 3-5
Selecting and Modifying Terminal Patterns ..................................................... 3-6
Assigning Terminals to Controls and Indicators............................................... 3-6
Required, Recommended, and Optional Connections for SubVIs.................... 3-8
Deleting Terminal Connections ........................................................................ 3-9
Confirming Terminal Connections ................................................................... 3-10
vi
Table of Contents
Chapter 4
Executing and Debugging VIs and SubVIs
Executing VIs ..................................................................................................................4-1
Running VIs.......................................................................................................4-1
Stopping VIs......................................................................................................4-4
Running VIs Repeatedly....................................................................................4-5
Data Logging on the Front Panel.......................................................................4-5
Retrieving Data Programmatically ....................................................................4-7
Accessing Databases ...........................................................................4-7
Retrieving Data Using File I/O Functions ..........................................4-9
vii
Table of Contents
Chapter 5
Printing VIs
Printing in G .................................................................................................................... 5-1
Printing Configuration ...................................................................................... 5-1
PostScript Printing .............................................................................. 5-2
Printing the Active Window ............................................................................. 5-2
Selecting Print Options ..................................................................................... 5-3
Setting Printout Formats ..................................................................... 5-3
Choosing Layout Options ................................................................... 5-4
Creating Custom Print Settings .......................................................... 5-4
Printing Section Headers...................................................... 5-6
Programmatic Printing ...................................................................................... 5-7
Controlling When Printouts Occur ..................................................... 5-7
Enhancing Printouts............................................................................ 5-7
Setting Page Layout............................................................................ 5-8
Using Alternative Printing Methods ................................................................. 5-9
viii
Table of Contents
Chapter 6
Setting up VIs and SubVIs
Creating Pop-Up Panels...................................................................................................6-1
VI Setup Options .............................................................................................................6-2
Execution Options .............................................................................................6-2
Documentation Options.....................................................................................6-3
Window Options................................................................................................6-4
SubVI Node Setup Dialog Box........................................................................................6-6
Chapter 7
Customizing Your G Environment
Setting G Preferences.......................................................................................................7-1
Preferences Dialog Box Options .......................................................................7-1
Path Preferences..................................................................................7-2
Library, Temporary, and Default Directories .......................7-3
VI Search Path ......................................................................7-5
Performance and Disk Preferences .....................................................7-6
Front Panel Preferences ......................................................................7-9
Block Diagram Preferences ................................................................7-11
Debugging Preferences .......................................................................7-12
Color Preferences ................................................................................7-13
Font Preferences..................................................................................7-14
Printing Preferences ............................................................................7-16
History Preferences .............................................................................7-17
Time and Date Preferences .................................................................7-21
Miscellaneous Preferences ..................................................................7-22
How Preferences Are Stored .............................................................................7-23
Customizing the Controls and Functions Palettes ...........................................................7-25
Adding VIs and Controls to user.lib and instr.lib..............................................7-25
Installing and Changing Views .........................................................................7-26
Palettes Editor....................................................................................................7-26
Creating Subpalettes ...........................................................................7-27
Moving Subpalettes.............................................................................7-29
How Views Work ..............................................................................................7-29
ix
Table of Contents
Chapter 9
Numeric Controls and Indicators
Digital Controls and Indicators ....................................................................................... 9-2
Digital Numeric Options................................................................................... 9-3
Displaying Integers in Other Radixes................................................. 9-4
Changing the Representation of Numeric Values .............................. 9-4
Range Options of Numeric Controls and Indicators ......................................... 9-6
Numeric Range Checking................................................................... 9-7
Format and Precision of Digital Displays ......................................................... 9-9
Slide Numeric Controls and Indicators ........................................................................... 9-12
Slide Scale......................................................................................................... 9-14
Scale Markers ..................................................................................... 9-15
Changing Scale Limits ......................................................... 9-16
Selecting Non-Uniform Scale Marker Distribution ............. 9-16
Text Scale ........................................................................................... 9-18
Filled and Multivalued Slides ........................................................................... 9-20
Rotary Numeric Controls and Indicators......................................................................... 9-21
Color Box ........................................................................................................................ 9-24
Color Ramp ..................................................................................................................... 9-25
Unit Types ....................................................................................................................... 9-26
Entering Units ................................................................................................... 9-31
Units and Strict Type Checking ........................................................................ 9-33
Polymorphic Units ............................................................................................ 9-35
Table of Contents
Chapter 10
Boolean Controls and Indicators
Creating and Operating Boolean Controls and Indicators ...............................................10-1
Configuring Boolean Controls and Indicators .................................................................10-3
Changing Boolean Labels..................................................................................10-3
Stopping on a Boolean Value..............................................................10-4
Boolean Data Range Checking ...........................................................10-4
Configuring the Mechanical Action of Boolean Controls ..................10-4
Customizing Booleans with Imported Pictures .................................................10-6
Chapter 11
String Controls and Indicators
Using String Controls and Indicators...............................................................................11-1
String Control and Indicator Options...............................................................................11-2
Scrollbar Option ................................................................................................11-3
Display Types....................................................................................................11-3
Normal Display Option.......................................................................11-3
Backslash (\) Codes Display Option ................................................11-3
Password Display Option....................................................................11-5
Hex Display Option ............................................................................11-5
Limit to Single Line Option ..............................................................................11-6
Tables...............................................................................................................................11-6
Resizing Tables, Rows, and Columns ...............................................................11-6
Entering and Selecting Data Tables ..................................................................11-7
Chapter 12
Path Controls and Indicators and Refnums
Path Controls and Indicators............................................................................................12-1
Refnums ...........................................................................................................................12-2
Chapter 13
List and Ring Controls and Indicators
Listbox Controls ..............................................................................................................13-1
Creating a List of Options .................................................................................13-2
Selecting Listbox Items .....................................................................................13-2
Listbox Data Types............................................................................................13-3
xi
Table of Contents
Chapter 14
Array and Cluster Controls and Indicators
Arrays .............................................................................................................................. 14-1
Creating Array Controls.................................................................................... 14-5
Array Dimensions............................................................................... 14-7
Array Index Display ........................................................................... 14-8
Displaying Arrays in Single-Element or Tabular Form ..................... 14-9
Operating Arrays............................................................................................... 14-11
Default Sizes and Values of Arrays.................................................... 14-11
Array Elements ................................................................................... 14-13
Finding the Size of Arrays.................................................................. 14-13
Moving or Resizing Arrays ................................................................ 14-14
Selecting Array Cells.......................................................................... 14-14
An Example of Selecting Array Cells .................................. 14-14
G Arrays and Arrays in Other Systems............................................................. 14-16
Clusters ............................................................................................................................ 14-19
Creating Clusters............................................................................................... 14-20
Operating and Configuring Cluster Elements ................................................... 14-20
Cluster Elements................................................................................. 14-21
Cluster Default Values........................................................................ 14-21
Cluster Element Order ........................................................................ 14-21
Moving or Resizing Clusters .............................................................. 14-22
Cluster Assembly .............................................................................................. 14-23
Bundle Function ................................................................................. 14-24
Bundle By Name Function ................................................................. 14-24
Array To Cluster Function.................................................................. 14-28
Cluster Disassembly.......................................................................................... 14-29
Unbundle Function ............................................................................. 14-29
Unbundle By Name Function ............................................................. 14-30
Cluster To Array Function.................................................................. 14-32
Replacing Cluster Elements .............................................................................. 14-33
xii
Table of Contents
Chapter 15
Graph and Chart Controls and Indicators
Creating Waveform and XY Graphs ...............................................................................15-2
Plotting Single-Plot Graphs...............................................................................15-2
Waveform Graph Data Types .............................................................15-2
XY Graph Data Types.........................................................................15-3
Plotting Multiplot Graphs..................................................................................15-5
Waveform Graph Data Types .............................................................15-5
XY Graph Data Types.........................................................................15-9
Setting Custom Options on a Graph..................................................................15-11
Scale Options ......................................................................................15-12
Marker Spacing.....................................................................15-13
Formatting ............................................................................15-15
Autoscale ..............................................................................15-17
Loose Fit ...............................................................................15-17
Panning and Zooming Options ...........................................................15-17
Legend Options ...................................................................................15-19
Waveform Charts .............................................................................................................15-22
Waveform Chart Data Types.............................................................................15-22
Waveform Chart Options ..................................................................................15-25
Chart Update Modes ...........................................................................15-26
Stacked Versus Overlaid Plots............................................................15-28
Intensity Graphs ...............................................................................................................15-29
Intensity Graph Data Type ................................................................................15-29
Intensity Graph Options ....................................................................................15-29
Graph Cursors ..................................................................................................................15-30
Intensity Charts ................................................................................................................15-36
Intensity Chart Options......................................................................................15-38
Color Mapping ....................................................................................15-40
xiii
Table of Contents
Chapter 17
Wiring the Block Diagram
Wiring Techniques .......................................................................................................... 17-1
Wire Stretching ................................................................................................. 17-5
Selecting, Moving, and Deleting Wires ............................................................ 17-6
Wiring Off-Screen............................................................................................. 17-10
Solving Wiring Problems.................................................................................. 17-11
Bad Wires ........................................................................................... 17-11
Wire Type, Dimension, Unit, or Element Conflict .............. 17-12
Multiple Wire Sources ......................................................... 17-13
No Wire Source.................................................................... 17-13
Loose Ends ........................................................................... 17-14
Wire Stubs ............................................................................ 17-14
Wire Cycles .......................................................................... 17-15
Wiring Situations to Avoid ............................................................................... 17-15
Looping Wires .................................................................................... 17-15
Hidden Wire Segments ....................................................................... 17-16
Wiring underneath Objects ................................................................. 17-17
Chapter 18
Structures
For Loop and While Loop Structures.............................................................................. 18-3
For Loop............................................................................................................ 18-3
While Loop ....................................................................................................... 18-4
Placing Objects inside Structures...................................................................... 18-4
Placing and Sizing Structures on the Block Diagram ....................................... 18-5
Placing Terminals inside Loops........................................................................ 18-6
Auto-Indexing ................................................................................................... 18-7
Auto-Indexing for Setting the For Loop Count .................................. 18-8
Auto-Indexing with While Loops....................................................... 18-9
Executing a For Loop Zero Times .................................................................... 18-9
Shift Registers ................................................................................................... 18-10
xiv
Table of Contents
Chapter 19
Formula Nodes
Using Formula Nodes ......................................................................................................19-2
Formula Node Functions and Operators ..........................................................................19-5
Formula Node Syntax ......................................................................................................19-8
Formula Node Errors .......................................................................................................19-9
Chapter 20
Attribute Nodes
Creating Attribute Nodes .................................................................................................20-1
Using Attribute Node Help................................................................................20-6
Base Attributes.................................................................................................................20-7
Visible Attribute..................................................................................20-7
Disabled Attribute ...............................................................................20-7
Key Focus Attribute ............................................................................20-8
Blinking Attribute ...............................................................................20-8
Position Attribute ................................................................................20-9
Bounds Attribute (Read Only) ............................................................20-10
Examples of Attributes Specific to Controls or Indicators................................20-10
Changing Plot Color on a Chart..........................................................20-10
Setting the Strings of a Boolean Attribute ..........................................20-11
Setting the Strings of Ring Controls ...................................................20-12
Using a Double-Clicked Listbox Item ................................................20-13
Selectively Presenting Users with Options .........................................20-14
Reading Graph Cursors Programmatically .........................................20-14
xv
Table of Contents
Chapter 21
Global and Local Variables
Global Variables.............................................................................................................. 21-1
Local Variables................................................................................................................ 21-3
xvi
Table of Contents
Chapter 23
Calling Code from Other Languages
Executing Other Applications from within Your VIs......................................................23-1
Using the Call Library Function........................................................................23-2
Using Code Interface Nodes..............................................................................23-2
Call Library Function.......................................................................................................23-3
Calling Conventions (Windows) .......................................................................23-4
Parameter Lists ..................................................................................................23-5
Calling Functions that Expect Other Data Types ..............................................23-7
LabWindows/CVI Function Panel Converter..................................................................23-7
Conversion Process ...........................................................................................23-8
Chapter 24
Understanding the G Execution System
Multitasking .....................................................................................................................24-1
Cooperation .......................................................................................................24-2
Task Switching....................................................................................24-2
Synchronous Nodes ...........................................................................................24-3
Prioritizing Tasks of the Same Priority Level ...................................................24-3
Wait Functions for Prioritizing Tasks ...............................................................24-3
VI Setup Priority Setting ...................................................................................24-4
Subroutine Priority Level ..................................................................................24-4
Reentrant Execution ..........................................................................................24-5
Examples in which You Should Use Reentrancy..............................................24-5
Using a VI That Waits ........................................................................24-5
Using a Storage VI Not Meant to Share Its Data ................................24-7
Chapter 25
Managing Your Applications
File Arrangement Using VI Libraries ..............................................................................25-1
Backing Up Your Files ....................................................................................................25-2
Distributing VIs ...............................................................................................................25-2
Save with Options Dialog Box ..........................................................................25-3
Designing Applications with Multiple Developers .........................................................25-5
Keeping Master Copies .....................................................................................25-5
VI History Window ...........................................................................................25-5
Revision Numbers...............................................................................25-7
Resetting History Information ............................................................25-8
Printing History Information...............................................................25-9
Setting Related VI Setup & Preference Dialog Box Options .............25-9
xvii
Table of Contents
Chapter 26
Performance Issues
Performance Profiling ..................................................................................................... 26-1
Viewing the Results .......................................................................................... 26-3
Timing Information ............................................................................ 26-4
Memory Information .......................................................................... 26-5
Speeding Up Your VIs .................................................................................................... 26-6
Input/Output ...................................................................................................... 26-6
Screen Display .................................................................................................. 26-7
Other Issues....................................................................................................... 26-8
Parallel Diagrams ............................................................................... 26-8
SubVI Overhead ................................................................................. 26-9
Unnecessary Computation in Loops................................................... 26-9
Memory Usage ................................................................................................................ 26-12
Virtual Memory................................................................................................. 26-12
Macintosh Memory ........................................................................................... 26-13
VI Component Memory Management .............................................................. 26-13
Dataflow Programming and Data Buffers ........................................................ 26-14
Monitoring Memory Usage............................................................................... 26-17
Rules for Better Memory Usage ....................................................................... 26-18
Memory Issues in Front Panels .......................................................... 26-19
SubVIs Can Reuse Data Memory....................................................... 26-20
Local Variables Cannot Reuse Data Memory .................................... 26-20
Global Variables Always Keep Copies of Their Data........................ 26-21
Understanding When Memory Is Deallocated ................................... 26-21
Determining When Outputs Can Reuse Input Buffers ....................... 26-22
Consistent Data Types ........................................................................ 26-22
How to Generate Data of the Right Type............................. 26-23
Avoid Constantly Resizing Data .......................................... 26-24
Example 1: Building Arrays................................................. 26-24
Example 2: Searching through Strings................................. 26-27
Developing Efficient Data Structures ............................................................... 26-28
Case Study 1: Avoiding Complicated Data Types............................................ 26-30
Case Study 2: Global Table of Mixed Data Types ........................................... 26-32
Obvious Implementation .................................................................... 26-33
Alternative Implementation 1 ............................................................. 26-33
Alternative Implementation 2 ............................................................. 26-33
Case Study 3: A Static Global Table of Strings................................................ 26-35
xviii
Table of Contents
Chapter 27
Portability Issues
Portable and Nonportable VIs..........................................................................................27-1
Porting between Platforms...............................................................................................27-2
Separator Character Differences........................................................................27-2
Resolution and Font Differences .......................................................................27-2
Overlapping Labels ...........................................................................................27-4
Picture Differences ............................................................................................27-4
Appendix A
Data Storage Formats
Data Formats for Front Panel Controls and Indicators ....................................................A-1
Booleans ............................................................................................................A-1
Numerics............................................................................................................A-1
Extended..............................................................................................A-1
Double.................................................................................................A-2
Single ..................................................................................................A-2
Long Integer........................................................................................A-3
Word Integer .......................................................................................A-3
Byte Integer.........................................................................................A-3
Arrays ................................................................................................................A-3
Strings................................................................................................................A-5
Paths ..................................................................................................................A-5
Clusters ..............................................................................................................A-5
Type Descriptors..............................................................................................................A-7
Data Types.........................................................................................................A-8
Array ...................................................................................................A-11
Cluster .................................................................................................A-11
Flattened Data ..................................................................................................................A-12
Scalars................................................................................................................A-13
Strings, Handles, and Paths ...............................................................................A-13
Arrays ................................................................................................................A-13
Clusters ..............................................................................................................A-14
xix
Table of Contents
Appendix B
Common Questions about G
Charts and Graphs ........................................................................................................... B-1
Error Messages and Crashes............................................................................................ B-4
Platform Issues and Compatibilities................................................................................ B-6
Printing ............................................................................................................................ B-7
Miscellaneous .................................................................................................................. B-9
Appendix C
Customer Communication
Glossary
Index
Tables
Table 4-1.
Table 4-2.
Table 9-1.
Table 9-2.
Table 9-3.
Table 9-4.
Table 9-5.
Table 9-6.
Table 11-1.
Table 16-1.
Table 19-1.
Table 19-2.
Table A-1.
Table A-2.
xx
About
This
Manual
Basic G Concepts
xxi
Chapter 6, Setting up VIs and SubVIs, discusses how you can use the
VI Setup and SubVI Node Setup dialog boxes to customize the
behavior of a subVI. You can use these dialog boxes to create
subVIs that show their panels when they are called and to enable
and disable features of a panel, such as the scrollbars, the toolbar,
and the window resizing capability.
Chapter 13, List and Ring Controls and Indicators, describes the
listbox and ring controls and indicators, which are available from
the ControlsList & Ring palette.
Chapter 15, Graph and Chart Controls and Indicators, describes how
to create and use the graph and chart indicators in the
ControlsGraph palette.
xxii
Chapter 18, Structures, describes how to use the For Loop, While
Loop, Case Structure, and Sequence Structure. These structures are
in the FunctionsStructures palette.
Chapter 19, Formula Nodes, describes how to use the Formula Node
to execute mathematical formulas on the block diagram. The
Formula Node is available from FunctionsStructures.
Chapter 21, Global and Local Variables, describes how to define and
use global and local variables. You can use global variables to
access a particular set of values easily. Local variables serve a
similar purpose within a single VI.
Advanced G Topics
xxiii
Bold text denotes menus, palettes, menu items, or dialog box buttons or
options. In addition, bold text denotes VI input and output parameters.
italic
bold italic
monospace
Monospace font denotes text or characters that you enter using the
keyboard. Sections of code, programming examples, syntax examples,
key names, and messages and responses that the computer
automatically prints to the screen also appear in this font.
italic
monospace
Italic text in this font denotes that you must supply the appropriate
words or values in the place of these items.
<>
The symbol leads you through nested menu items and dialog box
options to a final action. The sequence
FilePage SetupOptionsSubstitute Fonts
directs you to pull down the File menu, select the Page Setup item,
select Options, and finally select the Substitute Fonts option from the
last dialog box.
xxiv
paths
Paths in this manual are denoted using backslashes (\) to separate drive
names, directories, and files, as in drivename\dir1name\
dir2name\myfile.
Warning: This icon to the left of bold italicized text denotes a warning, which alerts
you to the possibility of damage to you or your equipment.
Caution:
This icon to the left of bold italicized text denotes a caution, which alerts
you to the possibility of data loss or a system crash.
Note:
This icon to the left of bold italicized text denotes a note, which alerts you
to important information.
Abbreviations, acronyms, metric prefixes, mnemonics, symbols, and
terms are listed in the Glossary.
Related Documentation
The following documents contain information that you might find
helpful as you read this manual:
Customer Communication
National Instruments wants to receive your comments on our products
and manuals. We are interested in the applications you develop with our
products, and we want to help if you have problems with them. To make
it easy for you to contact us, this manual contains comment and
configuration forms for you to complete. These forms are in
Appendix C, Customer Communication, at the end of this manual.
xxv
Chapter
Introduction to G
Programming
What Is G?
G is the programming language that has been at the heart of LabVIEW
for several years. Currently, it is integral to two of National
Instruments application development environments, LabVIEW and
BridgeVIEW.
G, like C or BASIC, is a general-purpose programming language with
extensive libraries of functions for any programming task. G includes
libraries for data acquisition, GPIB and serial instrument control, data
analysis, data presentation, and data storage. G also includes
conventional program debugging tools, so you can set breakpoints,
animate the execution to see how data passes through the program, and
single-step through the program to make debugging and program
development easier.
G differs from those programming languages in one important respect.
Other programming systems use text-based languages to create lines of
code, while G uses a graphical programming language to create
programs in block diagram form.
Components of a VI
G is a general-purpose programming system, but it also includes
libraries of functions and development tools designed specifically for
data acquisition and instrument control. G programs are called virtual
instruments (VIs) because their appearance and operation can imitate
actual instruments. However, VIs are similar to the functions of
conventional programming languages.
A VI consists of an interactive user interface, a dataflow diagram that
serves as the source code, and icon connections that set up the VI so that
1-1
Chapter 1
Introduction to G Programming
it can be called from higher level VIs. More specifically, VIs are
structured as follows:
VIs are hierarchical and modular. You can use them as top-level
programs, or as subprograms within other programs or
subprograms. A VI within another VI is called a subVI. The icon
and connector of a VI work like a graphical parameter list so that
other VIs can pass data to a subVI.
With these features, G makes the best use of the concept of modular
programming. You divide an application into a series of tasks, which
you can divide again until a complicated application becomes a series
of simple subtasks. You build a VI to accomplish each subtask and then
combine those VIs on another block diagram to accomplish the larger
task. Finally, your top-level VI contains a collection of subVIs that
represent application functions.
Because you can execute each subVI by itself, separate from the rest of
the application, debugging is much easier. Furthermore, many
low-level subVIs often perform tasks common to several applications,
so you can develop a specialized set of subVIs well-suited to
applications you are likely to construct.
The following sections further explain the front panel, block diagram,
icon, connector, and other related features.
Note:
1-2
Chapter 1
Introduction to G Programming
Front Panel
The user interface of a VI is like the user interface of a physical
instrumentthe front panel. A front panel of a VI might look like the
following illustration.
1-3
Chapter 1
Introduction to G Programming
You can change the size, shape, and position of a control or indicator.
In addition, each control or indicator has a pop-up menu you can use to
change various attributes or select different options. You access this
pop-up menu by
button.
See Chapter 2, Building VIs, and the Front Panel Objects section of this
manual (Chapters 8 through 15) for information about how to build a
front panel.
Block Diagram
The Diagram window holds the block diagram of the VI, which is the
graphical source code of a VI. You construct the block diagram by
wiring together objects that send or receive data, perform specific
functions, and control the flow of execution.
The following simple VI computes the sum of and difference between
two numbers. The diagram shows several primary block diagram
program objectsnodes, terminals, and wires.
1-4
Chapter 1
Introduction to G Programming
diagram. The data then enters the Add and Subtract functions. When the
Add and Subtract functions complete their internal calculations, they
produce new data values at their exit terminals. The data flows to the
indicator terminals and reenters the front panel, where it is displayed.
The data exits from a source terminal and enters a destination or sink
terminal.
Nodes are program execution elements. They are analogous to
statements, operators, functions, and subroutines in conventional
programming languages. The Add and Subtract functions are one type
of node. G has an extensive library of functions for math, comparison,
conversion, I/O, and more.
Another type of node is a structure. Structures are graphical
representations of the loops and case statements of traditional
programming languages, by repeating blocks of code or executing them
conditionally. G also has special nodes for linking to external
text-based code and for evaluating text-based formulas.
Wires are the data paths between source and sink terminals. You cannot
wire a source terminal to another source, nor can you wire a sink
terminal to another sink. However, you can wire one source to several
sinks. Each wire has a different style or color, depending on the value
that flows through the wire. The previous example shows the wire style
for a numeric scalar valuea thin, solid line.
Data flow is the principle that governs G program execution. Stated
simply, a node executes only when all data inputs have arrived; the node
supplies data to all of its output terminals when it finishes executing; the
data passes immediately from source to sink terminals. Dataflow
programming contrasts with the control flow method of executing a
conventional program, in which instructions are executed in the
sequence in which they are written. Control flow execution is
instruction driven. Dataflow execution is data-driven or
data-dependent.
You can switch from the front panel to the block diagram by selecting
WindowsShow Panel from the menu.
See the Block Diagram Programming section of this manual
(Chapters 16 through 21) for in-depth information about using block
diagram objects to build a program.
1-5
Chapter 1
Introduction to G Programming
1-6
Chapter 1
Introduction to G Programming
Help in G
The G Help window contains help information for functions, constants,
subVIs, controls and indicators, and dialog box options. To display the
window, choose Show Help from the Help menu or press <Ctrl-h>
(Windows); <command-h> (Macintosh); <meta-h> (Sun); or
<Alt-h> (HP-UX). If your keyboard has a <Help> key, you can press
that key instead. Move your cursor onto the icon of a function, a subVI
node, or a VI icon (including the icon of the VI you have open, shown
at the top right of the VI window) to see the help information.
Selecting HelpLock Help or clicking on the lock icon at the bottom of
the window locks the current contents of the Help window. When you
have locked it, moving over another function or icon does not change
the display in the Help window. Select Lock Help or click on the lock
icon again to turn this option off.
1-7
Chapter 1
Introduction to G Programming
exist and that choosing the complex view will display them. The
following illustration shows the simple view of a File I/O VI.
wire stub
showing optional input
In the complex view, the Help window shows all inputs with wires
pointing to the left, and outputs with wires pointing to the right. Labels
of optional inputs are in gray text. The following illustration shows the
complex view of a File I/O VI.
optional input
displayed
Also, the file path of the location of the path of the node is displayed.
If a function input does not need to be wired, the default value is usually
indicated in parentheses next to the name. If the function can accept
multiple data types, the Help window shows the most common type.
The terminal names for subVI nodes are the labels of the corresponding
front panel controls and indicators. The default value of a subVI does
not automatically appear in the wiring diagram. It is a good idea,
however, to include the default value in parentheses in the name of
controls when you create a subVI.
When you place the Wiring tool over a wire, the Help window displays
the data type carried by that wire. Also, when you move the Wiring tool
G Programming Reference Manual
1-8
Chapter 1
Introduction to G Programming
Online Reference
In addition to the Help window, G has more extensive online
information available. To access this information, select HelpOnline
Reference. For most block diagram objects, you can select Online
Reference from the pop-up menu of the object to access its online
description. You also can access this information by pressing the button
shown to the left, which is located at the bottom of the Help window.
1-9
Chapter 1
Introduction to G Programming
When you have created source documents, you use a help compiler to
create a help document. If you want help files on multiple platforms,
you must use the help compiler for the specific platform on which you
intend to use the file. You can use any of the following compilers. The
Windows compilers also include tools for creating help documents.
1-800-939-8324.
When you have created and compiled your help files, you can link them
directly to a VI. Pop up on the VI connector pane of the VI for which
you want to link a file and select VI SetupDocumentation. Select the
Help Tag box and type the topic you would like to link to in the help
file. Choose the help file by clicking on the Browse button. The path
of the file appears in the Help Path box.
1-10
Chapter
Building VIs
G Environment
You use palettes and menus to build VIs. You can choose objects from
palettes to position on the front panel of the block diagram. These
objects can be moved or modified by the use of menus.
Note:
If you are a BridgeVIEW user, you must make sure your palettes are
changed to Basic G. Select EditSelect Palette Set. Then, choose the
Basic G palette from the palette set menu.
You create objects on the front panel and block diagram by selecting
them from the floating Controls and Functions palettes. For example,
2-1
Chapter 2
Building VIs
if you want to create a knob on a front panel, select it from the Numeric
palette of the Controls palette, as shown in the following illustration.
As you move the selection arrow over an object on the palette, the name
of the object appears at the top of the palette. In the preceding
illustration, the digital control is selected. At this point, if you click on
and move the mouse over the front panel, a digital control appears at the
point where you release the mouse. You can resize an object at the same
time you create it by clicking on and dragging it as you place it.
Note:
If you need several functions from the same palette, you can keep it open.
To keep a palette open, select the pushpin in the top left corner of the
palette. When you have pinned the palette open, it has a titlebar so you can
move it around easily. If you save the VI the next time you launch your G
development environment, the palettes are opened in the same locations in
which you previously closed them.
2-2
Chapter 2
Building VIs
If you do not enter text into the label of a control when you first create it,
the label disappears when you click elsewhere. You can show the label
again by popping up on the control and selecting ShowLabel.
The following illustration shows an example of the result of popping up
on the control and selecting ShowLabel.
2-3
Chapter 2
Building VIs
front panel
block diagram
Tools Palette
A tool is a special operating mode of the mouse cursor. You use tools to
perform specific functions.
Many of the tools contained in the floating Tools palette are shown in
the following illustration. You can move this palette anywhere you
want, or you can close it temporarily by clicking on the close box (the
small box with an x that appears in the top right corner of palettes).
Once closed, you can access it again by selecting WindowsShow Tools
Palette. You also can bring up a temporary version of the Tools palette
at the location of your cursor by clicking while pressing
<Ctrl-Shift> (Windows); <command-Shift> (Macintosh);
<meta-Shift> (Sun); or <Alt-Shift> (HP-UX).
2-4
Chapter 2
Building VIs
Scroll toolScrolls through the window without using the scroll bars.
Color Copy toolCopies colors for pasting with the Color tool.
Change from one tool to another by doing any of the following while in
edit mode:
Use the <Tab> key to move through the most commonly used tools
in sequence.
Press the spacebar to toggle between the Operating tool and the
Positioning tool when the front panel is active, and between the
Wiring tool and the Positioning tool when the block diagram is
active.
2-5
Chapter 2
Building VIs
Menus in G
G uses menus extensively. The menu bar at the top of a VI window (or
at the top of the Macintosh screen) contains several pull-down menus.
You can access pull-down menus from a menu bar by clicking on a
menu bar item. The pull-down menus are usually general in nature and
contain items common to other applications, such as Open, Save,
Copy, and Paste, and many others specific to the language G. Some
menus also list shortcut key combinations.
The menu in G that you use most often is the object pop-up menu.
Almost every G object, as well as empty front panel and block diagram
space, has a pop-up menu with options and commands. Instructions
throughout this manual suggest that you select a command or option
from an object pop-up menu.
Pop-Up Menus
As you learned in the previous section, all G objects have associated
pop-up menus. You pop up on an object by clicking on the object with
the right mouse button (on the Macintosh, holding down the
<command> key while you click on the object with the mouse). By
selecting options from the resulting menu, you can access options
related to that object and change its look or behavior.
2-6
Chapter 2
Building VIs
Editing VIs
After you are familiar with editing techniques, see the Front Panel
Objects section (Chapters 8 through 15) for information on building
front panels, and the Block Diagram Programming section of this manual
(Chapters 16 through 21) for help in building block diagrams.
Selecting Objects
Positioning
Tool
Not selected
Selected
2-7
Multiple selection
with selection rectangle
Chapter 2
Building VIs
Click on an open area with the Positioning tool and drag diagonally
until all the objects you want to select are within or are touched by the
selection rectangle. When you release the mouse button, the selection
rectangle disappears and a marquee surrounds each selected object.
Then you can move, copy, or delete the selected objects.
Some objects must be enclosed completely by the rectangle to be
selected. Others are selected when they are partially enclosed. By
holding down the <Shift> key while dragging the selection rectangle,
you can select additional objects or deselect an object enclosed by the
rectangle.
Clicking on an unselected object or clicking on an open area deselects
everything currently selected. <Shift>-clicking on an object selects
or deselects it without affecting other selected objects.
You cannot select a front panel object and a block diagram object at the
same time. However, you can select more than one object on the same
front panel or block diagram.
2-8
Chapter 2
Building VIs
You can use the following Drag and Drop capabilities externally (from
other applications to G objects):
Drag a file into a path control or constant to drop its full pathname.
Drag a datalog file into a Data Log File Refnum to create a cluster
containing the data structure in the datalog file.
Drag a graphics file into a Pict Ring, front panel, or block diagram
to drop the picture it contains.
Drag a custom control file into the front panel to drop the custom
control stored in that file.
(Windows 95/NT) Drag Text from an OLE source to drop its text into
(Windows 95/NT) Drag Image from an OLE source to drop its picture
Positioning Objects
You can position an object by clicking on it with the Positioning tool
and then dragging it to the location you want.
If you hold down the <Shift> key and then drag an object, the action
restricts the direction of movement horizontally or vertically,
depending on which direction you first move the object.
You can move selected objects in small, precise increments by pressing
the appropriate arrow key on the keyboard once for each pixel you want
the objects to move. Hold down an arrow key to repeat the action. Hold
down the <Shift> key along with an arrow key to move the object
more rapidly.
2-9
Chapter 2
Building VIs
If you change your mind about moving an object while you are
dragging, continue to drag until the cursor is outside all open windows
and the dotted outline disappears, then release the mouse button. This
cancels the move operation, and the object remains where it was. If your
screen is cluttered, the menu bar is a convenient and safe place to
release the mouse button when you want to cancel a move.
You also can place objects on top of other objects. There are several
commands in the Edit menu to move them relative to each other.
For example, assume you have three objects stacked on top of each
other. Object 1 is on the bottom of the stack, and object 3 is on top.
Move To Front moves the selected object in the stack to the top. If
object 1 is selected, object 1 moves to the top of the stack, with object 3
under it, and object 2 on the bottom.
Move Forward moves the selected object one position higher in the
stack. So starting with the original order of object 1 on the bottom of the
stack and object 3 on top, selecting this option for object 1 puts object 2
on the bottom, object 3 on the top, and object 1 in the middle.
G Programming Reference Manual
2-10
Chapter 2
Building VIs
Aligning Objects
Select the objects you want to align and choose the axis along which
you want to align them from the Alignment ring, as shown at left. The
following illustration shows you how to select objects for alignment and
the results of the selection.
Selecting objects for alignment by left edges:
Results:
You can align an object along the vertical axis using its left, center, or
right edge. You also can align an object along a horizontal axis using its
top, center, or bottom edge. Your selection becomes the current
alignment option, which is indicated by a dark border around the item
in the palette.
2-11
Chapter 2
Building VIs
Top EdgesAligns all top edges of the selected objects with the
topmost object.
Left EdgesAligns all left edges of the selected objects with the
object that is farthest to the left.
Distributing Objects
To space objects evenly, or distribute them, select the objects you want
to distribute and choose how you want to distribute them from the
Distribution ring. In addition to distributing selected objects by making
their edges or centers equidistant, four options at the right side of the
ring let you add or delete gaps between the objects, horizontally or
vertically.
Duplicating Objects
There are three basic methods for duplicating a G objectby copying
and pasting, by cloning, and by dragging and dropping. In all cases, you
can create a new copy of the object complete with its associated
elements, such as the terminal belonging to a front panel control or the
front panel control belonging to a terminal, the label, local variables,
and Attribute Nodes. Local variables and Attribute Nodes referring to
original controls are copied and switched so they refer to the copied
control.
To copy and paste within a VI or between VIs, select the object with the
Positioning tool and choose EditCut or EditCopy. Then, click on the
area in which you want to place the duplicate and choose EditPaste.
You can duplicate several objects at the same time by dragging a
selection marquee around the objects before duplicating them. You also
can copy text or pictures from other applications and paste them into
your front panel or block diagram.
2-12
Chapter 2
Building VIs
Deleting Objects
To delete an object, select the object and choose EditClear or press the
<Backspace> (Windows and HP-UX) key or the <Delete> key
(Macintosh and Sun). You only can delete block diagram terminals by
deleting the corresponding front panel controls or indicators.
Although you can delete most objects, you cannot delete parts of a
control or indicator such as labels or digital displays. However, you can
hide these components by deselecting ShowLabel or ShowDigital
Display from the pop-up menu of the object.
If you delete a structure such as a While Loop, the contents are deleted
as well. If you want to delete only the structure itself but preserve its
contents, pop up on the edge of the structure and select Remove While
Loop (or other structure name). You delete the structure but not its
contents and automatically reconnect any wires that crossed the border
of the structure.
2-13
Chapter 2
Building VIs
Labeling Objects
Labels are blocks of text that annotate components of front panels and
block diagrams. There are two kinds of labelsowned labels and free
labels. Owned labels belong to and move with a particular object and
annotate that object only. You can hide these labels, but you cannot
copy or delete them independently of their owners. Free labels are not
attached to any object, and you can create, move, or dispose of them
independently. Use them to annotate your front panels and block
diagrams. You use the Labeling tool, whose cursor is the I-beam and
box cursor, to create free labels or to edit either type of label.
Free Labels
To create a free label, select the Labeling tool from the Tools palette and
click anywhere on the open space.
A small box appears with a text cursor at the left margin ready to accept
typed input. Type the text you want to appear in the label. As shown in
the following illustration, the Enter button appears on the toolbar to
remind you to end text entry by clicking on the Enter button.
You also can end text entry by pressing the <Enter> key on the
numeric keypad. If you do not have a keypad, you can press the
<Enter> (Windows and HP-UX), or <Return> (Macintosh and Sun)
key on the keyboard, or click anywhere outside the label. If you do not
type any text in the label, the label disappears as soon as you click on
any other area.
2-14
Chapter 2
Note:
Building VIs
If you place a label or any other object over (partially covering) a control
or indicator, it slows down screen updates and might make the control or
indicator flicker. To avoid this problem, do not overlap a front panel object
with a label or other object.
You can copy the text of a label by selecting it with the Labeling tool.
Double-click on the text with the Labeling tool to highlight the section
you want. Triple-click on the text to highlight the entire label. You also
can drag the Labeling tool across the text to highlight it. When the text
is selected, choose EditCopy to copy the text onto the Clipboard. Now
you can highlight the text of a second label. Select EditPaste to replace
the highlighted text in the second label with the text from the Clipboard.
To create a new label with the text from the Clipboard, click on the
screen with the Labeling tool where you want the new label positioned.
Then, select EditPaste.
When you create a control or indicator on the front panel, a blank,
owned label accompanies it, waiting for you to type the name of the new
control or indicator. The label disappears if you do not enter text into it
before clicking on another area with the mouse. You can show the label
again by popping up on the control or indicator and selecting
ShowLabel.
Structures and functions come with a default label, which is hidden until
you show it. You can edit this label the way you want it to look.
2-15
Chapter 2
Building VIs
The label appears, waiting for typed input. The label disappears if you
do not enter text into it before clicking outside the label.
Note:
On the block diagram, subVIs do not have labels that you can edit. The
label of a subVI always shows its name. Function labels, on the other hand,
can be edited to reflect the use of the function in the block diagram. For
example, you can use the label of an Add function to document what
quantities are being added, or why they are being added at that point in the
block diagram. See the note in the Creating VI Descriptions section in this
chapter for related information.
Text Characteristics
You can change text attributes by using the options from the Font ring
on the toolbar, as shown in the illustration that follows. If you select
objects or text and make a selection from this ring, the changes apply to
everything selected. If nothing is selected, the changes apply to the
default font, meaning that labels you create from then on will use the
new default font. Changing the default font does not change the font of
existing labels; it only affects labels created from that point on.
2-16
Chapter 2
Building VIs
If you select Font Dialog from the font window while a front panel is
active, the dialog box shown in the following illustration appears. If a
block diagram is active instead, the dialog box differs only in the
selection of Diagram Default instead of Panel Default in the
checkboxes at the bottom of the dialog box.
2-17
Chapter 2
Building VIs
If you click the Panel Default and Diagram Default checkboxes, the
selected font becomes the current font for the front panel, the block
diagram, or both. The current font is used on new labels. You can use
the checkboxes to set different fonts for the front panel and block
diagram. For example, you can have a small font on the block diagram
and a large one on the front panel.
For information on portability issues regarding the three types of fonts,
see the Resolution and Font Differences section in Chapter 27,
Portability Issues. For information on changing the defaults for the three
categories of fonts, see the Font Preferences section in Chapter 7,
Customizing Your G Environment.
The Font ring also has Size, Style, Justify, and Color options, as shown
in the following illustration.
2-18
Chapter 2
Building VIs
Font selections made from any of these submenus apply to objects you
select. For example, if you select a new font while you have a knob and
a graph selected, the labels, scales, and digital displays all change to the
2-19
Chapter 2
Building VIs
2-20
Chapter 2
Building VIs
2-21
Chapter 2
Building VIs
markers change to bold. These three types of changes are shown in the
following illustration.
2-22
Chapter 2
Building VIs
Resizing Objects
You can change the size of most objects. When you move the
Positioning tool over a resizable object, resizing handles appear at the
corners of the object, as shown in the following illustration.
Resizing cursor
When you pass the tool over a resizing handle, the Positioning tool
changes to the Resizing cursor. Click on and drag this cursor until the
dashed border outlines the size you want, as shown in the following
illustration.
Labels
You resize labels as you would other objects, using the resizing cursor.
Labels normally autosize; that is, the box automatically resizes to
contain the text you enter. Label text remains on one line unless you
enter a carriage return or resize the label box. Choose Size to Text from
the label pop-up menu to turn autosizing back on.
2-23
Chapter 2
Building VIs
Coloring Objects
Your G development environment appears on the screen in black and
white, shades of gray, or color depending on the capability of your
monitor. You can change the color of many G objects, but not all of
them. For example, block diagram terminals of front panel objects and
wires use color codes for the type and representation of data they carry,
so you cannot change them. You cannot change colors in
black-and-white mode.
To change the color of an object or the background of a window, pop up
on it with the Color tool from the Tools palette, as shown at the left. The
following palette appears in color.
As you move through the palette while pressing the mouse button, the
object or background you are coloring redraws with the color the cursor
currently is touching. This gives you a preview of the object in the new
color. If you release the mouse button on a color, the object retains the
selected color. To cancel the coloring operation, move the cursor out of
the palette before releasing the mouse button.
If you select the box with a T in it, your application makes the object
transparent. With this feature, you can layer objects. For example, you
can place invisible controls on top of indicators, or you can create
numeric controls without the standard three-dimensional container.
2-24
Chapter 2
Building VIs
Each of the three color components, red, green, and blue, describes
eight bits of a 24-bit color. Therefore, each component has a range
of 0 to 255. To change the value of a color component, you can
double-click on the display of that color and enter the new value, or
click on the appropriate arrow key to increase or decrease the current
value. After entering the new value, press the <Enter> key on the
numeric keypad to see the results in the color rectangle. To alter one of
the base colors, click on the color rectangle and choose one of the
2-25
Chapter 2
Building VIs
selections. The component values for the selected color appear in each
display.
The last color you select from the palette becomes the current color.
Clicking on an object with the Color tool sets that object to the current
color.
You also can copy the color of one object and transfer it to a second
object without using the Color palette. Click with the Color Copy tool
<Ctrl-click> (Windows); <command-click> (Macintosh);
<meta-click> (Sun); or <Alt-click> (HP-UX) with the Color tool
on the object whose color you want to duplicate. The Color tool appears
as an dropper and takes on the color of the selected object. Now, you
can click on another object with the Color tool, and that object becomes
the color you have chosen.
2-26
Chapter 2
Building VIs
The description of the object also appears in the Help window when you
place the cursor over the object. The best way to set up help for the VIs
you create is to enter descriptions for all your controls and indicators.
Note:
You cannot edit subVI descriptions from the calling VI diagram. You can
edit a VI description through the WindowsShow VI Info option when
the front panel of the VI is open. Function description boxes are blank so
that you can describe the action taking place at each occurrence of that
function on the block diagram.
Creating VI Descriptions
Selecting WindowsShow VI Info displays the information dialog
box for the current VI. You can use the information dialog box to
perform the following functions.
Lock or unlock the VI. You can execute but not edit a locked VI.
View how much memory the VI uses. The Memory Usage portion
of the information box displays the disk and system memory used
by the VI. (This figure applies only to the amount of memory the
VI is using and does not reflect the memory used by any of its
subVIs.)
The memory usage is divided into space required for the front panel
and the block diagram, VI code, and data space. The memory usage
can vary widely, especially as you edit and execute the VI. The
block diagram usually requires the most memory. When you are not
editing the diagram, save the VI and close the block diagram to free
space for more VIs. Saving and closing subVI front panels also
frees memory.
Saving VIs
You can save VIs as individual files, or you can group several VIs
together and save them in a VI library.
2-27
Chapter 2
Building VIs
Individual VI Files
Five options in the File menu concern saving your VIs as individual
files.
Select the Save option to save a new VI, choose a name for the VI, and
indicate its destination in the disk hierarchy. Also use this option to save
changes to an existing VI in a location previously indicated.
If you want to save a VI with a new name, you can use Save As, Save
a Copy As, or Save with Options from the File menu.
When you select the Save As option, G saves a copy of the VI in
memory to disk with the name you direct. After the save is finished, the
VI in memory points to the new version. In addition, all callers to the
old VI that are in memory now refer to the new VI. If you enter a new
name for the VI, G does not overwrite or delete the disk version of the
original VI.
When you select the Save A Copy As option, G saves a copy of the
VI in memory to disk with the name you enter. This does not affect the
name of the VI in memory.
Save with Options brings up a dialog box in which you can choose
to save an entire VI hierarchy to disk, optionally saving VIs without
their block diagrams. This option is useful when you are distributing
VIs or making backup copies. See Chapter 25, Managing Your
Applications, for instructions on how to use this option.
Caution:
You cannot edit a VI after you save it without a block diagram. Always
make a copy of the original VI.
You can use the FileRevert option to return to the last saved version
of the VI you are working on. A dialog box appears to confirm whether
to discard all changes made to the VI.
VIs that have been modified since they were last saved are marked with
an asterisk in their titlebars and in the list of open VIs displayed in the
Windows menu. When you save a VI, the asterisk disappears until you
make a new change.
See Chapter 25, Managing Your Applications, for information on saving
backup copies.
2-28
Chapter 2
Caution:
Building VIs
VI Libraries (.LLBs)
You can group several VIs together and save them as a VI library.
However, unless you have a good reason for saving them as libraries, it
is preferable to save them as individual files, organized in directories.
Read the following lists before deciding to save VIs in a library.
Reasons for you to save VIs as libraries:
If disk space is an important issue, you can save your files within
VI libraries, because they are compressed, slightly reducing disk
space requirements for VIs.
If you store your VIs as individual files, you can use the file system
to manage them (copying, moving, renaming, backing up,
managing source code).
Loading and saving files are faster from the file system than from
VI libraries. Less disk space is required for temporary files during
the load and save processes.
Keep in mind that many of the VIs shipped with G are shipped in VI
libraries so that they are stored in consistent locations on all platforms.
2-29
Chapter 2
Building VIs
Creating VI Libraries
To create a VI library, take the following steps:
1.
Select Save, Save as, or Save a Copy As from the File menu.
2.
to use native file dialog boxes, click on Use LLBs in the dialog box
that appears.
3.
In the dialog box that appears after step 1 or step 2, click on the
New or the New VI Library button.
4.
In the dialog box that appears, enter the name of the new library and
click on the VI Library button. G adds a .llb extension to the
name of the library automatically, if you do not.
5.
A dialog box appears, ready for you to name your VI if you wish,
and save it in the new library.
2-30
Chapter
Building SubVIs
Hierarchical Design
One of the keys to creating G applications is understanding and using
the hierarchical nature of a VI. After you create a VI, you can use it as
a subVI in the block diagram of a higher level VI. Therefore, a subVI is
analogous to a subroutine in C. Just as there is no limit to the number of
subroutines you can use in a C program, there is no limit to the number
of subVIs you can use in a G program. You also can call a subVI inside
another subVI.
When creating an application, you start at the top-level VI and define
the inputs and outputs for the application. Then, you use other VIs as
subVIs to perform the necessary operations on the data as it flows
through the block diagram. If a block diagram has a large number of
icons, you can group them into a lower-level VI to maintain the
simplicity of the block diagram. This modular approach makes
applications easy to debug, understand, and maintain.
You can create a subVI from a VI, or you can create a subVI from a
selection (portion) of a VI. Both methods are described in this chapter.
3-1
Chapter 3
Building SubVIs
3-2
Chapter 3
Building SubVIs
Use the tools to the left of the window, shown in the preceding
illustration, to create the icon design in the fat-pixel editing area. The
normal-size image of the icon appears in the appropriate box to the right
of the editing area.
Depending on the type of monitor you are using, you can design a
separate icon for display in monochrome, 16-color, and 256-color
mode. You design and save each icon version separately. The editor
defaults to Black & White, but you can click on one of the other color
options to switch. You can copy from a color icon to a black-and-white
icon, and from black and white to color as well, by using the Copy from
options at the right of the Icon Editor.
Note:
line
dropper
fill bucket
rectangle
3-3
Chapter 3
Building SubVIs
filled rectangle
select
text
foreground/background
Note:
Undo
OK
Cancel
You can cut, copy, and paste the entire icon using these options from the
menu or pressing <Ctrl> (Windows); <command> (Macintosh); <meta>
(Sun); or <Alt> (HP-UX) plus x for cut, c for copy, and v for paste.
3-4
Chapter 3
Building SubVIs
The connector replaces the icon in the upper right corner of the front
panel. G selects a terminal pattern for your VI with as many terminals
on the left of the connector pane as controls on the front panel, and as
many terminals on the right of the connector pane as indicators on the
front panel.
Each of the rectangles on the connector represents a terminal area, and
you can use them either for input to or output from the VI. If you want
to use a different terminal pattern for your VI, you can select a different
pattern.
3-5
Chapter 3
Building SubVIs
3-6
Chapter 3
Building SubVIs
2.
3.
Position the cursor in an open area of the front panel and click on
it. The marquee disappears and the selected terminal turns to gray,
indicating that the terminal has been assigned.
3-7
Chapter 3
Building SubVIs
Note:
If the connector terminal turns white, then a connection was not made.
Repeat steps 1 through 3 until the connector terminal turns gray.
Although you use the Wiring tool to assign terminals on the connector to
front panel controls and indicators, no wires are drawn between the
connector and these controls and indicators.
4.
Repeat steps 1 and 2 for each control and indicator you want to
connect.
You also can select the control or indicator first, and then select the
terminal. You can choose a pattern with more terminals than you need.
You can leave some extra terminals unconnected if you anticipate
making changes to the VI in the future that require a new input or
output. Having the extra connections available means that the new input
or output does not affect other VIs that already are using this VI as a
subVI. Unassigned terminals do not affect the operation of the VI. You
also can have more front panel controls than terminals.
The connector pane has, at most, 28 terminals. If your front panel
contains more than 28 controls and indicators that you want to use
programmatically, group some of them into a cluster and assign the
cluster to a terminal on the connector.
3-8
Chapter 3
Building SubVIs
3-9
Chapter 3
Building SubVIs
3-10
Chapter 3
Building SubVIs
Note:
Because local variables can either read or write from a front panel
terminal, when instances of both read and write local variables are
selected, two front panel objects are created in the subVIone to
pass the value of the local variable into the subVI and another to
pass the value out of the subVI. The front panel terminal created to
represent the read local variables has the suffix read added to its
name, and the front panel terminal created to represent the write
locals has the suffix write added to its name.
3-11
Chapter 3
Building SubVIs
Number of Connections
Do not make very large selections that create a subVI with more than
28 inputs and outputs, the maximum number of connections on a
connector pane.
Keep in mind that each front panel terminal, each attribute, and certain
local variables included in the selection require a slot in the connector
pane; a selection with a large number of these items might run out of
connector pane slots.
To avoid exceeding the maximum terminals, select a smaller section of
the diagram, or group data into arrays and clusters before selecting a
region of the diagram to convert.
Cycles
Try to avoid making selections that create cycles in the diagram. Cycles
occur if a data flow originates from an output of the subVI and
terminates as an input to the subVI.
Identifying cycles while making selections is difficult, but G detects
them for you. When G detects a cycle, it displays a dialog box
prompting you either to create a new VI from the selection or to cancel.
If you choose to create a new VI, a new Untitled VI is created from your
selection. The selected items in the original diagram are left untouched.
3-12
Chapter 3
Building SubVIs
Illogical Selections
Do not convert selections into a subVI that do not make sense. For
example, it does not make sense to convert a selection consisting of one
object inside a Sequence Structure and another object outside of the
Sequence Structure without including the Sequence Structure itself.
G disallows such selections and displays an explanation of the problem.
3-13
Chapter 3
Building SubVIs
The Case Structure is selected for conversion into a subVI. The front
panel terminal Output is left out in the original diagram and connected
to the subVI through a connector as shown in the following illustration.
In the original block diagram, G wrote a value to Output only when the
FALSE part of the case executed. However, when the selection turns
into a subVI, G always writes a value to Output regardless of whether
the TRUE or FALSE part of the case was executed within the subVI.
You need to edit the subVI to supply data for the extra cases.
3-14
Chapter 3
Building SubVIs
3-15
Chapter 3
Building SubVIs
SubVIs always are connected with lines to their calling VIs. The
window shown in the following illustration is displayed horizontally.
Arrow buttons and arrows beside nodes indicate what is displayed and
what is hidden, as follows:
A red arrow button pointing towards the node indicates that some
or all subVIs are hidden. Clicking on the button shows the
immediate subVIs of the node.
A blue arrow pointing towards the callers of the node indicates that
the node has additional callers that are not shown.
3-16
Chapter 3
Building SubVIs
3-17
Chapter 3
Building SubVIs
3-18
Chapter 3
Building SubVIs
The buttons, which perform some of the same actions as items in the
View menu, are described as follows:
Redo Layout
Vertical Layout
Horizontal Layout
Include VI Lib
Include Globals
3-19
Chapter 3
Building SubVIs
3-20
Chapter 3
Building SubVIs
Show All SubVIsMakes the selected node the focus node and
expands its entire subVI chain. The edges connecting the subVI
chain of the node are highlighted in red.
Show All CallersMakes the selected node the focus node and
expands its entire call chain. The edges connecting the call chain
are highlighted in red.
Edit IconDisplays the Icon Editor for editing of the icon of the
node.
Get InfoDisplays the Get Info dialog box for the node.
3-21
Chapter 3
Building SubVIs
Pressing the <Tab> key toggles between the Positioning and the
Scroll tool of the Tools palette.
3-22
Chapter 3
Building SubVIs
VIs
Built-in functions
Type definitions
Global variables
Local variables
Attribute Nodes
Breakpoints
Text
3-23
Chapter 3
Building SubVIs
To select the object you want to search for, click on the button after the
words Select Object. The Select Objects menu appears.
3-24
Chapter 3
Building SubVIs
3-25
Chapter 3
Building SubVIs
Finding Text
To search for specific text, click on the Text button in the Find dialog
box. The dialog box is displayed as follows.
Match CaseFinds only text strings that exactly match the case
(uppercase or lowercase) of the characters you type in.
3-26
Chapter 3
Building SubVIs
The options indicate if and where to search text that is visible or hidden.
The options are as follows:
Note:
The Text Search options are saved from search to search; therefore, if you
do not find a string of text that is expected to exist, make sure that the Text
Search Options are set appropriately.
Chapter 3
Building SubVIs
Click on the Find button to begin searching for the text or you have
selected.
3-28
Chapter 3
Building SubVIs
Find Pop-Up Menu for Global and Local Variables and Attribute Nodes
A Find pop-up menu item is available on controls, front panel controls
and indicators, global variables, locals variables, and Attribute Nodes.
You can pop up on a local variable or Attribute Node to find its
corresponding control, front panel terminal, or other local variables and
Attribute Nodes. Conversely, controls and front panel controls and
indicators have pop-up menus to find all corresponding locals and
Attribute Nodes. From a global node, you can find its corresponding
global definition or all other global nodes. Conversely, global controls
have a pop-up menu for finding all corresponding global references in
memory. If more than one result is found, the Search Results window
appears.
3-29
Chapter
This chapter discusses how to operate and debug VIs, and explains how
to set up VIs and subVIs for special execution modes.
Executing VIs
Running VIs
You can run a VI by selecting OperateRun or by clicking on the Run
button. G compiles the VI if necessary.
Run button
VI running at
top level
Press the Run Continuously button to run the VI over and over, until
you stop or pause execution.
Run Continuously
button
Stop button
Pause button
Pressing this button pauses execution. You can press it again at any time
to continue execution.
4-1
Chapter 4
You can run multiple VIs at the same time. After you start the first one,
switch to the front panel or block diagram of the next one and start it as
described previously. Notice that if you run a subVI as a top-level VI,
all caller VIs are broken until the subVI completes. You cannot run a
subVI as a top-level VI and as a subVI at the same time.
If your VI runs but does not perform correctly, see the sections
Debugging Broken VIs and Debugging Executable VIs later in this
chapter.
When you edit a VI, the toolbar contains several tools used for editing
VIs, including the Font ring, the Alignment ring, and the Distribution
ring.
When you run a VI, those tools are replaced with debugging tools, as
shown in the following illustration.
Run button
If you pop up on a control while running a VI, you can see that all
objects have a much simpler set of options. These are the same as the
options in the Data Operations submenu that you see in pop-up menus
when you edit VIs.
4-2
Chapter 4
You can cut, copy, or paste the contents of the control, set the control
to its default value, and read the description of the control with options
in this menu. Some of the more complex controls have additional
options. For example, an array has options you can use to copy a range
of values or go to the last element of the array.
4-3
Chapter 4
The Operate menu on the menu bar contains commands for executing
the current VI. The following sections discuss several fundamental
execution-related tasks.
Stopping VIs
Stop button
Normally, you should let the VI run until it completes. However, if you
need to halt execution immediately, click on the Stop button or select
OperateStop. The Stop command aborts the top-level VI at the
earliest opportunity. The halted VI most likely did not complete its task,
so you cannot rely on any data it produces. Although G closes files open
at the time and halts any data acquisition that might be in progress, you
should avoid designing VIs that rely on the Stop button or Stop menu
option. For example, if you create a VI that executes indefinitely within
a While Loop until stopped by the operator, wire the conditional
terminal of the loop with a Boolean switch on the front panel.
If you want to prevent an operator from inadvertently aborting your VI
by clicking on the Stop button, hide it by deselecting the VI
SetupWindow OptionsShow Abort Button option from the icon
pane pop-up menu on the front panel of the VI. See Chapter 6, Setting
up VIs and SubVIs, for information on setting window options.
4-4
Chapter 4
VI running
continuously
4-5
Chapter 4
When automatic data logging is enabled for a VI, G logs the front panel
of the VI any time the VI completes execution. You can tell if automatic
data logging is enabled for a VI by looking at the OperateLog at
Completion option. Selecting OperateLog at Completion enables
automatic data logging for a VI if it is disabled and disables it if it is
enabled.
To interactively log front panel data for a VI, select OperateData
LoggingLog.
Note:
A waveform chart returns only one data point at a time with front panel
data logging. If you wire an array into the chart indicator, the data log
contains the array subset that was displayed on the chart for that record.
Enter button
You can change the log file binding of a VI with the OperateData
LoggingChange Log File Binding option. You can select a specific
record by typing the record number and then clicking on the Enter
button or pressing the <Enter> key on the numeric keypad.
You can mark the selected record for deletion by clicking on the Delete
button. When the selected record is marked for deletion, the Delete
button changes to a full trash can. Clicking on the full trash can unmarks
Delete button
the selected record for deletion. Selected records are not deleted until
you select OperateData LoggingPurge Data, or until you switch
out of data retrieval mode, either by clicking on the OK button or
Record marked
selecting Retrieve again. If any records still are marked for deletion
for deletion button when you switch out of data retrieval mode, you are asked if you want
to delete the marked records.
Click on the OK button to return to the VI whose data log you have been
viewing.
Selecting OperateClear Log File Binding disassociates the VI from
any associated log file. The next time you log from the front panel data
of the VI, you will be prompted to specify the log file.
To view logged data interactively, select the OperateRetrieve
option. The toolbar becomes the data retrieval toolbar, as shown in the
following illustration.
4-6
Chapter 4
Accessing Databases
You also can retrieve data by using the Enable Database Access
option.You can access this option from the pop-up menu of a subVI that
has logged front panel data in the associated datalog file of the VI, as
shown in the following illustration. A halo that looks like a file cabinet
appears around the datalog file. This halo has terminals for accessing
data from the datalog file. If you run the calling diagram, the subVI does
not execute. Instead, you retrieve data from a specified record of the
datalog file. It also returns the time that the data was logged, and a
4-7
Chapter 4
The following illustration shows the halo terminals for accessing the
logged data.
4-8
Chapter 4
If the subVI has n logged records, you can wire any number from n to
n 1 to the record # terminal. You can access records relative to the
first logged record using non-negative record numbers. 0 means first
record, 1 means second record, and so on, through n 1, which stands
for the last record.
You can access records relative to the last logged record using negative
record numbers. 1 means last record, 2 means second to the last, and
so on, through n, which means the first record. If you wire a number
outside the range n to n 1 to the record # terminal, the invalid record
#? output is set to TRUE, and no data is retrieved.
4-9
Chapter 4
Debugging VIs
Debugging Broken VIs
A VI cannot compile or run if it is broken. The VI Run button typically
appears broken while you are creating or editing it, until you wire all
the icons in the diagram. If it still is broken after you finish wiring the
icons, try selecting EditRemove Bad Wires or selecting <Ctrl-b>
(Windows); <command-b> (Macintosh); <meta-b> (Sun); or
<Alt-b> (HP-UX). Often, this fixes a broken VI.
Broken run
button
Warning
button
You also can access this box by clicking on the Warning button of a
VI, or by selecting WindowsShow Error List. The Warning button
for a VI is only visible if the VI has a warning (such as overlapping
objects) and you have checked the Show Warnings option in the Error
List window. You can use the Preferences dialog box to configure G to
show warnings by default.
To locate a particular error, double-click on the text that describes it. G
shows the error by bringing the relevant window to the front and
4-10
Chapter 4
highlighting the object causing the error. You also can view errors and
warnings for other VIs by selecting the name of the VI from the VI List
pop-up menu.
The following list contains some of the most common reasons for a VI
being broken during editing.
A subVI is broken, or you edited its connector after you placed its
icon in the diagram.
You might have a problem with an object you have made invisible,
disabled, or otherwise altered through an Attribute Node. Restore
the object using the Attribute Node to fix the problem, if possible.
Error Messages
Error Messages
Descriptions
4-11
Chapter 4
Table 4-1.
Error Messages
Descriptions
More Errors....
A shift register must have inputs for all the left sides
or for none.
4-12
Chapter 4
Table 4-1.
Error Messages
Descriptions
4-13
Chapter 4
Table 4-1.
Error Messages
Descriptions
If you encounter messages that are not self-explanatory, and are not
listed in this chapter, contact National Instruments.
4-14
Chapter 4
Note:
Check wire paths to ensure that the wires connect to the proper
terminals. Triple-clicking on the wire with the Operating tool
highlights the entire path. A wire that appears to emanate from one
terminal actually might emanate from another, so look closely to
see where the end of the wire connects to the node.
Use the Help window (HelpShow Help) to make sure that both
functions and Tip strips are wired correctly.
Verify that the default value for functions or subVIs that have
unwired inputs is what you expect.
Use the probe feature described in the Using the Probe Tool section
of this chapter to observe intermediate data values. Also, check the
error output of functions and subVIs, especially those performing
I/O.
4-15
Chapter 4
Check the data range and range error action of controls and
indicators. They might not be taking the error action you want.
Check the node execution order. Nodes that are not connected by a
wire can execute in any order. The spatial arrangement of these
nodes does not control the order. That is, unconnected nodes do not
execute from left to right, top to bottom on the diagram as
statements do in textual languages.
Check that there are not any extraneous VIs. Unlike functions,
unwired subVIs do not always generate errors (unless you
configure an input to be required or recommended). If you
mistakenly place an unwired subVI on the block diagram, it
executes when the diagram does, and consequently your program
might end up doing extra actions.
Check that you do not have hidden VIs. You inadvertently might
have hidden subVIs three waysby dropping one directly on top
of another node; by decreasing the size of a structure without
keeping the subVI in view; or by placing one off the main diagram
area. In the last case, scroll the block diagram window to its limits.
Also check the inventory of subVIs used in the VI against the
Project menu options This VIs SubVIs and Unopened SubVIs to
determine if any extraneous subVIs exist. You also can look in the
Hierarchy window to see the subVIs for a VI, or in the Error List
window to see a list of hidden objects (as long as the Show
Warnings checkbox is selected). To help avoid corruption caused
4-16
Chapter 4
by hidden VIs, you can indicate that inputs to VIs are required; for
information, see Required, Recommended, and Optional Connections
for SubVIs in Chapter 3, Building SubVIs.
4-17
Chapter 4
the input array is empty. You either can produce an output error code or
substitute predefined values for the values created by the loop.
Note:
Understanding Warnings
If an object is hidden completely by another object, G generates a
warning to indicate that all objects are not visible. For example, if a
terminal is hidden under the edge of a structure, or tunnels are on top of
each other, a warning message is placed in the Error List window.
Warnings do not prevent you from running a VI; they are intended to
help you debug potential problems in your programs.
Debugging Features
The following debugging features are discussed in this section:
Pause button
Step Over
button
4-18
Chapter 4
After stepping into the subVI Fibonacci.vi and stepping into the
loop, clicking on the Step Out button and holding down the mouse for
a second, a menu appears from which the user can select how far the VI
should execute before pausing. Selecting Block Diagram runs the VI
until all nodes on the block diagram of the VI have executed, at which
time execution pauses.
4-19
Chapter 4
Selecting one of the VIs on the call stack runs that VI until it is finished.
At that point, the caller of the selected VI pauses.
Press the Step Over button to execute a structure (sequence, loop, etc.)
or a subVI and then pause at the next node. The keyboard shortcut is
<Ctrl> (Windows); <command> (Macintosh); <meta> (Sun); or
<Alt> (HP-UX) followed by the right arrow key.
Press the Step Into button to execute the first step of a subVI or
structure (sequence, loop, etc.) and then pause at the next step of the
subVI or structure. The keyboard shortcut is <Ctrl> (Windows);
<command> (Macintosh); <meta> (Sun); or <Alt> (HP-UX) followed
by the down arrow key.The step buttons affect execution only in a VI or
subVI that is in single-step mode. If a VI in single-step mode has one
subVI that is also in single-step mode and one that is in normal
execution mode, the first subVI single-steps when called but the second
executes normally when called. Press the Step Out button to finish
executing the current block diagram, structure, or VI and pause. The
keyboard shortcut is <Ctrl> (Windows); <command> (Macintosh);
<meta> (Sun); or <Alt> (HP-UX) followed by the up arrow key.
When the VI finishes executing, the step buttons become grayed-out.
4-20
Chapter 4
In addition to the keyboard shortcuts given in the Using Step Buttons, the
following commands are available:
Execution Highlighting
For debugging purposes, it is helpful to view an animation of the
execution of the VI block diagram.
To use this feature, click on the Hilite Execution button. The button
changes its appearance. Click on this button at any time to return to
off
on
normal view mode. You commonly use execution highlighting in
Hilite Execution button conjunction with single-step mode to gain an understanding of how data
flows through nodes. Highlighting greatly reduces the performance of a
VI.
With execution highlighting, the movement of data from one node to
another is marked by bubbles moving along the wires. Additionally, in
4-21
Chapter 4
4-22
Chapter 4
running
waiting to run
Block Diagram
paused
Hierarchy Window
One way to look for the source of the questionable results is to wire an
indicator to the output wire from one of the operations to display the
intermediate results. But placing an indicator on the front panel and
wiring its terminal to the block diagram is not a convenient debugging
mechanism. It is time-consuming and creates unwanted items on your
front panel and block diagram that you later must delete.
4-23
Chapter 4
Select the Probe tool and place its cursor on a wire, or pop up on the
wire and select Probe. As shown in the following illustration, the
floating Probe window appears, with no data displayed within. As soon
as you run the VI, the Probe window displays data passed along the
wire.
4-24
Chapter 4
If you select the Find Wire option, the block diagram containing that
wire comes to the front of all VIs and the wire is highlighted.
Use Reinitialize to Default to reset the value displayed in the Probe
window to its default value.
Use the Copy Data option to copy the data to other numeric controls in
the same VI or in other VIs.
Creating Probes
When you create a probe, you create a default-style probe to match the
data type of the wire. With numeric data types, for example, a digital
indicator is used to probe the data of a wire.
If you prefer, you can select a control for the probe from the built-in
controls, or from controls that have been saved as custom controls or
type definitions. To do so, pop up on the wire, select Custom Probe, and
then select a control from the Custom Probe palette that appears to the
right. If you choose Select a Control, you can use the file dialog box
to select any custom control or type definition that was saved in the file
4-25
Chapter 4
system. Type definitions are treated just like standard custom controls
when used to probe data.
Only those parts of the Custom Probe palette that might match the data
type of the wire are enabled. If you choose a control that cannot have
the same data type as the wire, G signals this mismatch with a beep. For
example, with arrays and clusters, you cannot use the array and cluster
shells from the Array & Cluster palette, because they are not completed
data types.
You can add your own palettes to the end of the Custom Probe palette,
just as you can add them to the Controls palette. See Chapter 7,
Customizing Your G Environment, for more information on how to do
this.
Clear Breakpoint
cursor
You can place a breakpoint on a VI, node, or wire to set a pause to occur
during execution. Nodes include subVIs, functions, structures, Code
Interface Nodes (CINs), Formula Nodes, and Attribute Nodes. When a
block diagram has a breakpoint, execution pauses after all nodes on the
4-26
Chapter 4
Location of
Breakpoint
Breakpoint Placement
How Breakpoint Is
Highlighted
Block diagram
Node
Wire
4-27
Chapter 4
In the following example, the wire with the attached probe has a
breakpoint. The VI pauses after the probe has generated data.
And in the following example, the For Loop has a breakpoint. The VI
will pause after Multiply has executed.
4-28
Chapter 4
Suspending Execution
You can edit indicators, execute the subVI as many times as you want
before returning to the caller, or go back to the beginning of the subVI
by suspending execution of a SubVI.
To set a subVI in suspend mode, open the subVI and check the
OperateSuspend when Called option. This option also can be
accessed by popping up on the connector pane on the front panel while
in run mode, and selecting SetupExecution OptionsSuspend when
Called. The subVI automatically suspends when it is called. If you
check this option when single-stepping, the VI does not switch into
suspend mode immediately.
If you want to suspend execution at a particular call to a subVI, use the
SubVI Node Setup option from the pop-up menu of the subVI node,
instead of the Suspend when Called option. The SubVI Node Setup
suspends execution at that particular instance of the subVI only.
4-29
Chapter 4
Run button
If you want to execute the current subVI before returning to the caller,
press the Run button (or select the OperateRun command) while in
suspend mode. You can repeat the execution as many times as you want.
When the subVI completes, the indicators display results from that
execution of the subVI. However, you can change the indicator values
if you want to return different values to the calling VI. In fact, the
suspend mode is the only time you can set values on indicators. Click
on the Run button again when you are ready to return the indicator
values of the subVI to the calling VI.
If you want to go back to the beginning of the VI, click on the Skip to
Beginning button.
Skip to Beginning
Return to Caller
4-30
Chapter 4
4-31
Chapter
Printing VIs
This chapter discusses printing issues in G.
Printing in G
There are three primary ways to print VIs in G.
You can use the Print Window option to make a quick printout
of the contents of the current window.
You can use the G programmatic printing feature to make VIs that
can print under the control of your application.
In addition, you can use the Serial Port VIs to send text to the printer if
you have a printer connected to your serial port; doing so generally
requires some knowledge of the command language of the printer.
In Windows and UNIX, another option for printing is to use the System
Exec VI located in FunctionsCommunication. On the Macintosh,
you can use the AESend Print Document VI located in
FunctionsCommunicationAppleEvent. In Windows, you also can
use dynamic data exchange (DDE) to tell another application to print
data.
Printing Configuration
There are two dialog boxes that affect the appearance of all printouts,
regardless of the method you use to print: the Printing dialog box and
the Preferences dialog box.
You use the Printing dialog box of the Preferences dialog box to tell
G how it should print. You can choose the following dialog box, for
example, to implement PostScript printing.
5-1
Chapter 5
Printing VIs
PostScript Printing
To produce higher quality printouts, you can use the Preferences dialog
box, which contains options for customizing the way G prints, including
the option to select PostScript printing (if you have a PostScript
printer).
If you have a PostScript printer, you can take advantage of the
following benefits.
You use the Preferences dialog box to indicate if you want to use
PostScript printing. If you select PostScript printing, you have the
option to select PostScript level 2, or Color/Grayscale, which
supports color printing. See Chapter 7, Customizing Your
G Environment, for information on the Preferences dialog box.
5-2
Chapter 5
Printing VIs
The Using the Panel format prints the front panel, VI description, and
the control names and their descriptions.
5-3
Chapter 5
Printing VIs
Front panel
Block diagram
VI hierarchy
List of subVIs
5-4
Chapter 5
Printing VIs
This dialog box displays the categories of items that you can print.
These categories are listed in the order that they appear on the printout.
In addition, the page layout options in this dialog box control scaling,
page breaks, and headers for the printout.
The icon for each of the custom print setting options is shown to the left
of the description.
Icon and Description
VI Connector and IconPrints a picture of the VI icon along with
its inputs and outputs.
VI DescriptionPrints the VI description.
Front PanelPrints the front panel.
5-5
Chapter 5
Printing VIs
printed. You can select the following options from the pop-up menu
next to this option.
5-6
Chapter 5
Printing VIs
Programmatic Printing
If you want to print something under the control of your VI, rather than
interactively as with the Print Window and Print Documentation dialog
boxes, use programmatic printing. With this type of printing, you can
program your VI to print after every execution. You also can program
it to print out the contents of a specific front panel or a specific control
during executionperhaps in response to the user pressing a Print
button.
Programmatic printing allows you to control when printouts occur, as
well as the appearance of your printouts, such as if or not a header is
printed.
To implement programmatic printing, select OperatePrint at
Completion.
When this option is on, G prints the contents of that front panel any time
the VI completes execution. If the VI is a subVI, G prints when that
subVI finishes execution, before it returns to the caller.
Enhancing Printouts
Using transparency and the Color tool, you can hide portions of controls
that you do not want to be visible in your printouts. For example, you
can use transparency to simplify the appearance of the edges of
controls.
5-7
Chapter 5
Printing VIs
5-8
Chapter 5
Printing VIs
5-9
Chapter
This chapter discusses how you can use the VI Setup and SubVI Node
Setup dialog boxes to customize the behavior of a subVI. You can use
these dialog boxes to create subVIs that show their panels when they are
called and to enable and disable features of a panel, such as the
scrollbars, the toolbar, and the window resizing capability.
6-1
Chapter 6
This dialog box contains several options for customizing the look and
behavior of the VI. Use the ring at the top of the dialog box to select
from three different option categoriesExecution Options, Window
Options, and Documentation.
VI Setup Options
Execution Options
Initially, the VI Setup dialog box presents you with execution options
for the current VI. The Execution Options are shown in the following
illustration.
6-2
Chapter 6
Documentation Options
The dialog box in VI SetupDocumentation, shown in the following
illustration, presents you with options concerning entries made to the
History window, which displays the development history of the VI. For
information on the History window, see the VI History Window section
in Chapter 25, Managing Your Applications.
To use any of the first four options in the Documentation menu, the Use
History Defaults (In Preferences Dialog) option must be deselected. If
you select the option, G uses the history preferences instead. The
history preferences are identical, except that they set up the defaults
used when you create any new VI, although the VI Setup documentation
options apply only to the current VI.
6-3
Chapter 6
If you check the Add an entry every time this VI is saved option, G adds
an entry to the VI history every time you save the VI. If you have not
entered a comment in the Comment box of the History window, only a
header is added to the history. The header contains the revision number
if that option is checked in the PreferencesHistory dialog box, the date
and time, and the name of the VI.
If you check the Prompt for comment when this VI is closed option, the
History window appears so that you can enter a comment when you
close a VI that has changed since you loaded it, even if you already have
saved the changes.
If you check the Prompt for comment when this VI is saved option, the
History window appears when you save so that you can enter a
comment. This is useful if you prefer to comment on your changes when
you finish making them instead of as you are editing. If you do not set
this option, you cannot change the history of the VI after you select
Save until the save is finished.
Note:
G does not prompt you to enter a comment when you save or close a VI if
the only changes you made were changes to the history.
The options to the right of the VI SetupDocumentation dialog box
create access to online help files that you have created. Put your cursor
in the Help Tag box and type in a topic to display for this VI. Then type
in the path to the help file in the Help Path box, or click the Browse
button and find the file. The filename and path of the file appears in the
Help Path box. After you have set these options, clicking on the online
help icon at the bottom of the Help dialog box accesses the help file you
selected. See Chapter 1, Introduction to G Programming, for information
on creating your own help files.
Window Options
The window options apply to the VI when it is in run mode, but not in
edit mode. You can use these options to control the ability of a user to
interact with the program by restricting access to G features, and by
changing the way the window looks and behaves. You can make your
VI look and act like a dialog box, in that the user cannot interact with
other windows while this window is open. You also can remove the
scrollbars and the toolbar, and set a window to be centered or sized
automatically to fit the screen.
6-4
Chapter 6
Dialog Box prevents the user from interacting with other windows
while this option window is open, just as a system dialog box does.
If you turn off the Allow User to Close Window checkbox in the VI
Setup dialog box, the Window Options dialog box hides the close box
for the VI front panel, and dims the FileClose option. With this VI
setup option, you can ensure that a user cannot close a run-time or
pop-up VI front panel inadvertently.
Allow Run-Time Pop-Up Menu determines if objects on this front
panel can display a pop-up menu of data operations in run mode.
When you select the Hilite <Return> Boolean option, G highlights any
Boolean currently associated with the <Enter> (Windows and HP-UX),
or <Return> (Macintosh and Sun) key. You associate keys with
controls using the Key Navigation dialog box, which is described in the
Key Navigation Option for Controls section of Chapter 8, Introduction to
Front Panel Objects.
The Size to Screen option automatically resizes the panel of a VI to fit
the screen when the VI is switched to run mode and when it is loaded
into memory. The VI does not retain a record of its original size and
location, so it stays in the same place if you switch back to edit mode.
Auto-Center automatically centers the front panel on the user's
computer screen when the VI is opened or when it is switched to run
mode.
National Instruments Corporation
6-5
Chapter 6
If you hide the menu bar and the toolbar, there is no visible means of
changing from run mode back into edit mode. Use the <Ctrl-m>
(Windows); <command-m> (Macintosh); <meta-m> (Sun); or <Alt-m>
(HP-UX) hot key that corresponds to the OperateChange to Edit Mode
option to change the VI back to edit mode, where the menu bar and palette
are visible.
The options do not take effect until the VI starts running.
These options are a subset of the options in the VI Setup dialog box. The
difference between the two sets of options is that you use the SubVI
Setup dialog box to specify options that relate to a specific call to a
subVI, although you use the subVI execution options of VI Setup to
specify the behavior of all calls to that VI.
6-6
Chapter
Customizing Your
G Environment
Setting G Preferences
Preferences Dialog Box Options
To customize your application and configure some default parameters,
you use the various Preferences dialog boxes.
You access the Preferences dialog boxes by selecting
EditPreferences, as shown in the following illustration.
7-1
Chapter 7
Use the pull-down menu at the top of the dialog box to select among the
different categories of preferences, as shown in the following
illustration.
Path Preferences
You can specify the directories that G searches when looking for VIs as
well as the paths G uses for temporary files and the library directory. If
not already selected, select Paths from the pull-down menu in the
Preferences dialog box to bring up the dialog box shown in the
following illustration.
7-2
Chapter 7
Note:
In the dialog box that appears, many items are grayed out and inactive
because G is set to use the default path. If you want to change one of
these preferences, deselect the Use Default checkbox, as shown in the
following illustration.
7-3
Chapter 7
path, or browse the file dialog box to select a path. This is shown in the
following illustration.
path category
current value
new value
development environment.
7-4
Chapter 7
VI Search Path
The VI Search Path is used only when your G development
environment searches for a subVI, control, or external subroutine that
is not in the expected location. It lets you list the path of directories for
G to search. When you edit the search path, you are given more options
than for the other pathsyou can add new items in specific locations,
remove paths, and select from a list of special paths.
C:\VIs\*
/usr/home/gregg/vis/*.
7-5
Chapter 7
You can use the special pull-down menu shown in the following
illustration, which is located to the right of the Browse button, to
select from several special directories.
You also can remove a path using the Remove button, which places the
removed path into the string box, in case you decide to re-insert it
elsewhere in the list.
Note:
7-6
Chapter 7
7-7
Chapter 7
rates to the DAQ VIs, because they use the built-in timers of the DAQ
boards to control the acquisition rate.
You can increase the resolution of the Tick Count, Wait, and Wait Until
Next ms Multiple VIs to 1 ms by increasing the resolution of the built-in
timer of Windows to 1 ms. If you increase the timer resolution, your
software timing loops are more accurate.
Under certain circumstances, you might not want to increase the timer
resolution from 55 ms. Changing the resolution increases the number of
timer tick interrupts from 18 interrupts per second to 1000 interrupts
per second. If you are performing other interrupt intensive operations,
you might exceed the capacity of your PC to handle the interrupt load,
which might lock up or crash your PC.
DAQ operations that use programmed I/O instead of DMA to transfer
data between the DAQ board and PC memory are interrupt intensive.
Do not change the timer tick resolution to 1 ms if you plan to perform
any of the following operations at high transfer rates:
7-8
Chapter 7
Changes to the Check available disk space during launch option take effect
when you relaunch G. Changes to the Use default timer, Compact memory
during execution, and Cooperation level options take effect immediately.
7-9
Chapter 7
End text entry with Return key (same as Enter key)Makes the
<Enter> (Windows); <return> (Macintosh); <Return> (Sun); or
<Enter> (HP-UX) on the alphanumeric keyboard function like the
<Enter> key on the numeric keypad, ending text entry. If you select
this option, you can embed new lines by pressing <Ctrl-Enter>
(Windows); <option-return> (Macintosh); <meta-Return>
(Sun); or <Alt-Return> (HP-UX).
(Windows, Macintosh) Override system default function key settingsBy
default, your operating system might use some function keys for system
purposes. For example, on the PC, pressing F10 is the same as pressing
the <Break> key. On the Macintosh, F1 to F4 usually are treated as
Cut, Copy, Paste, and Clear. If you turn this override option on, the
function keys are not used for system purposes but are passed instead to
G as standard function keys.
Use localized decimal pointUses the decimal separator for the system
instead of the period. For example, in many countries, the comma is
used as a decimal point. Turn this option on if you want G to pay
attention to the way you have configured your system. Turn it off if you
want G to use periods in all cases for the decimal point.
Use smooth updates during drawingWhen G updates a control with
smooth updates off, it erases the contents of the control and draws the
new value. This can result in a noticeable flicker as the old value is
erased and replaced. Using smooth updates, G draws data to an
offscreen buffer and then copies that image to screen instead of erasing
a section of the screen. This avoids the flicker caused by erasing and
drawing. However, it can slow performance, and it requires more
application memory because an offscreen drawing buffer has to be
maintained.
Use transparent name labelsDirects G to use labels that you can see
through.
(Sun) Support numeric keypad on Sun keyboardsTurns on support
for the Sun keyboard, including keypads, arrow keys, and the Help key.
Do not turn this option on if you are using a non-Sun keyboard (for
example, if you are using an X terminal or a PC running X software).
Blink speedSets the blinking speed for front panel objects, to the
default 1,000 milliseconds or a speed that you type in. Blinking is a
basic attribute turned on with Attribute Nodes. See Chapter 20, Attribute
Nodes, for more information.
7-10
Chapter 7
Note:
Changes to options in the Front Panel Preferences dialog box take effect
immediately.
7-11
Chapter 7
Note:
Debugging Preferences
The Debugging Preferences dialog box is shown in the following
illustration.
7-12
Chapter 7
Note:
Color Preferences
The Color Preferences dialog box is shown in the following illustration.
This dialog box lets you change the colors used by G for various items.
If you do not select the Use default colors checkbox, you can click on
any rectangle to change the color. The options are the following:
Front PanelYou can select a color for the front panel of new VIs.
Changing the color does not affect old VIs.
Block DiagramYou can select a color for the block diagram of new
VIs. Changing the color does not affect old VIs.
ScrollbarYou can select a color for scrollbars. This option affects
only the VIs that are currently open.
Coercion DotsYou can select a color for the dots indicating coercion
of numerical data. This option affects only the VIs that are currently
open.
(Windows, UNIX) Menu TextYou can select a color for text used in
menus.
7-13
Chapter 7
Font Preferences
The Font Preferences dialog box lets you change three categories of
predefined fonts: the Application font, System font, and Dialog font.
You select the category of font you wish to change from the pop-up
menu above the text box. The dialog box with Application Font
selected is shown in the following illustration.
7-14
Chapter 7
G uses the three categories of fonts for specific portions of its interface.
The fonts are predefined according to the platform, as follows:
Use default fontUses the default font, as defined by G in keeping with
the different platforms, as described previously.
Custom fontThis checkbox is checked automatically if you change
any font characteristics through the Font Style option.
Font StyleBrings up a dialog box that lets you change font
characteristics.
Note:
7-15
Chapter 7
Printing Preferences
The Printing Preferences dialog box is shown in the following
illustration. Keep in mind that some options are available on certain
platforms only.
print data (front panel, diagram, icon, etc.) and print it using standard
drawing commands. Use this option if you want to print to a file
(assuming your printer driver supports printing to a file), if your printer
does not have PostScript support, or if you want your printer driver to
do the PostScript translation instead of G.
(Windows only) Allow printer ditheringDirects G to use printer
dithering when creating the drawing commands. Applicable for
black and white printing, printer dithering is a method of adding
gray scales to an image instead of only black and white areas. This
option is not dependent on printer type.
(Windows only) Scale printer fontsEnables a more complicated
algorithm to select a different font if the first one doesnt scale
correctly. If all of the text on your printed VI does not appear, or if
it is too large, you can try this option to see if it improves the
appearance of the printout. This option is not dependent on printer
type.
7-16
Chapter 7
data for that page into the bitmap, and then send the bitmap to the
printer. This method takes longer to print than the other two, but can
yield a more accurate representation of the text and fonts than standard
printing, even though the printout is not as high resolution as with
PostScript printing. The bitmap image is in color for color printers and
black and white otherwise.
Note:
History Preferences
As explained in Chapter 25, Managing Your Applications, each VI has a
History window that displays the development history of the VI. With
the History Preferences dialog box, you can choose the default settings
for the History window of new VIs.
7-17
Chapter 7
The options in the History dialog box are divided into two groups. The
first group contains five options for indicating when and how entries to
the History window are added for new VIs.
The second group of options in the History Preferences dialog box
concerns how you log in to G, which in turn determines the name G
inserts in the headers to comments entered in the VI History window.
Options concerning History window entries can be specified for
individual VIs through the VI SetupDocumentation dialog box. See
Documentation Options in Chapter 6, Setting up VIs and SubVIs, for
information about accessing the options.
The options in this dialog box are as follows:
Add an entry every time VI is savedDirects G to add an entry to the
VI history every time you save the VI. If you have not entered a
comment in the Comment box of the History window, only a header is
added to the history. (The header contains the revision number if that
option further down in this dialog box is checked, the date and time, and
the name of the VI.)
Prompt for comment when VI is savedDirects G to bring up the
History window when you save so that you can enter a comment. This
is useful if you prefer to comment on your changes when you finish
G Programming Reference Manual
7-18
Chapter 7
making them instead of as you are editing. If you do not set this option,
you will not have a chance to change the history of the VI after you
select Save until the save is finished.
Prompt for comment when VI is closedSimilar to the previous
option, except that G only prompts you when you close a VI, rather than
every time you save. You are prompted if the VI changed any time since
you loaded it, even if you have already saved the changes.
Note:
G does not prompt you to enter a comment when you save or close a VI if
the only changes you made were changes to the history.
Record comments generated by the editorCauses the editor to insert
comments into the History window when certain events occur. The
events that cause automatic comments are conversion to a new version
of LabVIEW or BridgeVIEW, subVI changes, and changes to the name
or path of the VI.
Show revision number in titlebarAdds the revision number to the
header of the History window. The revision number starts at zero and is
incremented every time you save the VI. It will not be incremented
however, if the only changes you made were changes to the VI history.
The login options are as follows:
(Windows and Macintosh only) Login automatically with the registration
7-19
Chapter 7
Note:
You can switch to another user name (the system user name or your
application registration name) in Windows or on the Macintosh, or the
system user name in UNIX, without having to type it in by using the
pull-down menu shown in the preceding illustration. You also can type
in a name, which appears in the list thereafter.
(Windows NT, Macintosh with file sharing only, and UNIX) Login automatically
with the system user nameAssuming that a user name has been
defined, causes G to use the system login name of the current user.
Note:
7-20
Chapter 7
The options in this dialog box control the default displays of time and
date in the digital displays of new controls and indicators. You can
override the defaults in this dialog box for individual digital displays,
as explained in the Format and Precision of Digital Displays section of
Chapter 9, Numeric Controls and Indicators.
The options in this dialog box are as follows:
Default date formatDetermines whether the month, day, or year
comes first in digital displays.
Default time formatDetermines whether time in digital displays is
based on a 12-hour or 24-hour clock.
Date SeparatorDetermines the character used to separate the month,
day, and year (in the order selected in the Default date format option)
of digital displays.
Time SeparatorDetermines the character used to separate the hours
and minutes past the hour in digital displays.
Note:
Changes to options in the Time and Date Preferences dialog box take effect
immediately.
7-21
Chapter 7
Miscellaneous Preferences
The Miscellaneous Preferences dialog box is shown in the following
illustration.
system's native file dialog boxes in G so that they look similar to those
of other applications on your machine (with a few exceptions discussed
at in the next paragraph). When this preference is not selected, G uses
its own platform-independent file dialog boxes, which add some
convenient features, such as providing a list of recent paths and
reducing the steps necessary to save VIs in VI libraries.
In a few cases, the native file dialog box of the operating system does
not have the functionality required by G. In such cases, G uses its own
file dialog box even when this option is selected. On the Macintosh, if
you wire the pattern input or if you wire the datalog type input and use
a select mode of 1 (select new file), 2 (select new or existing file), 4
(select new directory), or 5 (select new or existing directory), G uses its
own file dialog box. In Windows, even if you wire the pattern input, G
uses its own file dialog box.
7-22
Chapter 7
Use hot menusWith this option, you can navigate the menus using the
mouse without keeping the left mouse button pressed. This ergonomic
feature relieves strain on the hand.
Note:
The references to WIN.INI files applies only to Windows 3.1. If you are a
BridgeVIEW user, this information does not apply to the Windows
platform you are using.
You also can specify a preference file on the command line when you
start LabVIEW or BridgeVIEW. For example, to use a file named lvrc
instead of .labview.ini, type labview -pref lvrc.
7-23
Chapter 7
If you want, you can copy your LabVIEW Preferences file to the
LabVIEW folder. When launched, LabVIEW always looks for the
Preferences file in the LabVIEW folder. If not found there, it looks in
the System Folder, and if not found there, it creates a new one in the
System Folder. By moving Preferences files between desktop and the
LabVIEW folder, you can create multiple Preferences for multiple users
or uses.
(UNIX) Preference information normally is stored in a source file in your
home directory. If you change a parameter from the Preferences dialog
box, G writes the information to this file. The following information is
supplied for those who want more information on the storage format
and the rules for finding preference information.
7-24
Chapter 7
You also can specify a preference file on the command line when you
start LabVIEW. For example, to use a file named lvrc instead of
.labviewrc, type labview -pref lvrc.
Caution:
The labviewrc file is still read in this case. Also, keep in mind that
changes made in the Preferences dialog box are written to the lvrc file in
this example.
You can add your own VIs and controls to the palettes by saving
them in the user.lib or instr.lib directories.
You can add your own VIs and controls to the palettes by using the
EditEdit Control & Function Palettes option.
You can set up the palettes so they automatically change as you add
or remove files from specific directories.
You can rearrange the built-in palettes to make the functions you
use frequently more easily accessible.
You can set up different views for different users, hiding some
functions to make G easier to use for one user while providing the
full capabilities for another user.
7-25
Chapter 7
Palettes Editor
For more control over the layout and contents of the Controls and
Functions palettes, use the EditEdit Control & Function Palettes
option. When you have selected this option, you enter the Palettes
Editor. The Edit Palettes dialog box appears.
In this editor, you can rearrange the contents of palettes by dragging
objects to new locations. If you want to delete, customize, or insert
objects, pop up on a palette as shown in the following illustration, or
pop up on an object within a subpalette.
With the pop-up options, you can modify anything within the User
Libraries menu (corresponds to user.lib) or the Instrument I/O
menu (corresponds to instr.lib). If you want to edit the top-level
Controls or Functions palettes or any of the other predefined menus,
G Programming Reference Manual
7-26
Chapter 7
you must first create a new view by selecting new setup from the
menu setup ring in the Edit Palettes dialog box. After selecting a new
setup, any menu that you modify that is part of the default menu set is
copied to the directory of your view in the menus directory before
changes are made to it. This protection of the built-in palettes ensures
that you can experiment with the palettes without corrupting the default
view.
If you want to add a new object in a new row or column of a subpalette,
pop up in the space at the right edge or bottom of the subpalette. You
also can create new rows or columns by dragging objects to the area to
the right or bottom of the palette.
Creating Subpalettes
When you add a palette, you can move it to a new location, edit the
subpalette icon, or rename the palette using the Palettes Editor.
If you want to create a palette from scratch or hook in a palette that is
not in user.lib or vi.lib, you can use the InsertSubmenu option
from the pop-up menu in the Palettes Editor. When you select this
option, you are presented with the following dialog box.
7-27
Chapter 7
7-28
Chapter 7
setting, the palette for a library automatically updates as you add files
to the library.
Notice that you can mix VIs, functions, and subpalettes within a palette
freely. Also, a palette can contain VIs from different locations.
Moving Subpalettes
Because clicking on a subpalette opens it, you cannot move a subpalette
by dragging it. To move a subpalette, you can select the Move Submenu
option from its pop-up menu. As a shortcut, you can hold down
the <Shift> key while you click a subpalette to drag it instead of
opening it.
7-29
Chapter
This chapter introduces the front panel and its two components
controls and indicators. It also explains how to import graphics from
other programs to use in your controls.
If you idle your cursor over any square of the panel, the name of the
collection of controls is displayed.
The types of controls in the palette, from left to right, top to bottom, are
as follows:
8-1
Chapter 8
8-2
Chapter 8
8-3
Chapter 8
Replacing Controls
The Replace option of the pop-up menu of an object displays the
Controls palette from which you can choose a control or indicator to
take the place of the current item on the front panel.
Use Replace when you want to choose a different style of control, but
do not want to lose all of the editing options you have selected for the
control up to that point. Selecting Replace from the pop-up menu
preserves as much information as possible about the original control,
such as its name, description, default data, dataflow direction (control
or indicator), colors, size, and so on. However, the new control keeps
its own data type. Wires from the terminal of the control or local
variables remain connected on the block diagram.
The more similar the control is to the one being replaced, the more the
original characteristics can be preserved. As an example, the following
illustration shows a slide being replaced by a different style of slide.
8-4
Chapter 8
The new slide has the same height, scale, value, name, description, and
so on.
If you were to pop up and replace the slide with a string instead, only
the name, description, and data flow direction are preserved, because a
slide does not have much in common with a string.
Another way to replace a control that does not use the Replace pop-up
menu and does not preserve any characteristics of the old control
involves copying the control to the Clipboard. This method does keep
the connections on the block diagram and VI connector. Copy the new
control to the Clipboard. Then select the old control that you want to
replace with the Positioning tool, and select EditPaste. The old control
is discarded and the new control is pasted in its place.
The Key Navigation option is disabled for indicators, because you cannot
enter data into an indicator.
You also can use the Key Navigation option to indicate whether a
control should be included when the user tabs from control to control
while running.
8-5
Chapter 8
You can use the Key Navigation option to associate function keys
with various buttons that control the behavior of a panel. You can use it
to define a default button for VIs that behave like a dialog box, so that
pressing the <Enter> (Windows and HP-UX), or <Return>
(Macintosh and Sun) key becomes the same as clicking on the default
button.
If you associate the <Enter> or the <Return> key with a dialog box
button, G automatically draws that button with a special thick border
around it, as shown in the following illustration.
There are two important things to know about the <Enter> or the
<Return> key:
1.
2.
When you tab from control to control, buttons are treated specially.
If you tab to a button and press the <Enter> or <Return> key,
the button you tabbed to is toggled, even if another control has the
<Enter> or <Return> key as its key navigation setting.
You cannot assign the same key combination to more than one control
in a given front panel.
8-6
Chapter 8
When you select the Key Navigation option, G displays the following
dialog box.
You use the ring at the top left of this dialog box to select the key for
this control. You can define the key to be a single key, or a key held in
combination with a modifier key, such as the <Shift> key. In addition
to the <Shift> key modifier, you can choose the menu key, which is
the <Alt> (Windows and HP-UX); <command> (Macintosh); or
<meta> (Sun) key. The options in this ring are shown in the following
illustration.
8-7
Chapter 8
8-8
Chapter 8
The white boxes on the controls and indicators show their current places
in the panel order. Black boxes show the new place in the panel order
of the control or indicator. Clicking on an element with the panel order
cursor sets the position of the element in the panel order to the number
displayed inside the Tools palette. You can change this number by
typing a new number into it. When the panel order is the way you want
it, click on the Enter button to set it and exit the panel order edit mode.
Click on the X button to revert to the old panel order and exit the panel
order edit mode.
X Button
The panel order determines the order in which the controls and
indicators appear in the records of datalog files produced by logging the
front panel.
dialog button
There are several types of dialog box controls: dialog rings (which are
numeric), dialog buttons (which are Boolean), dialog checkmarks, and
dialog buttons.
The dialog controls change appearance depending on which platform
you are using. Each appears with the color and appearance typical of
that platform.
8-9
Chapter 8
Windows
Macintosh
Sun and
HP-UX
Because these controls change appearance, you can create VIs with
controls whose appearance is compatible with any of the computers that
can run G. Using these controls, along with the checkmark and radio
button Booleans, simple numeric controls, simple strings, and the
dialog fonts, you can create a VI that adapts its appearance to match any
computer you use the VI on. By using the VI Setup options to hide the
menu bar and scrollbars and control the window behavior, you can
create VIs that look like standard dialog boxes for that computer.
8-10
Chapter 8
Before you can use a picture in G, you have to load it into the G
Clipboard. There are one or two ways to do this, depending on your
platform, as described below.
(Windows) If you can copy an image directly from a paint program to the
Windows Clipboard and then switch to G, G automatically imports the
picture to the G Clipboard. Or, you can use the Import Picture from
File option from the Windows Edit menu to import a graphics file
into the G Clipboard. In Windows 3.1, you can use the latter method on
CLP, EMF, GIF, PCX, BMP, TARGA, TIFF, LZW, WMF, and WPG
files. On Windows 95/NT, you can use EMF, WMF, and CLP files.
(Macintosh) If you copy from a paint program to the Clipboard and then
switch to G, G automatically imports the picture to its Clipboard.
(UNIX) You can use the Import Picture from File option from the
a static picture on your front panel, or you can use the Import Picture
option of a pop-up menu, or the Import Picture options in the Control
Editor.
For an example of how to import graphics from other programs, see
general\controls\custom.llb.
8-11
Chapter
This chapter explains how to create, operate, and configure the various
styles of numeric controls and indicators.
When you select ControlsNumeric from the palette, a new palette of
controls and indicators appears, as shown in the following illustration.
Numeric controls and indicators are either digital, slide, rotary, ring,
enumerated, color box, or color ramp controls.
9-1
Chapter 9
Digital numerics are the simplest way to enter and display numeric data.
Use the Operating tool and any of the following methods to increase or
decrease the displayed value:
Operating tool
Enter button
Click inside the digital display window and enter numbers from the
keyboard.
Place the cursor to the right of the digit you want to change and
press the up or down keyboard arrow.
The Enter button appears on the Tools palette to remind you that the
new value replaces the old only when you press the <Enter> key on
the numeric keypad, click outside the display window, or click on the
Enter button. While the VI is running, any of these actions prevent G
from interpreting intermediate values as input. For example, while
changing a value in the digital display to 135, you do not want the VI
to receive the values 1 and 13 before getting 135. This rule does not
apply to values you change using the increment/decrement arrows.
Numeric controls accept only the followingdecimal digits, a decimal
point, +, , uppercase or lowercase e, and the terms Inf (infinity) and
NaN (not a number), and in absolute time format the following
characters: /, :, and uppercase or lowercase a, m, p, and m. If you exceed
the limit for the selected representation, G coerces the number to the
natural limit. For example, if you enter 1234 into a control set for byte
integers, G coerces the number to 127. If you incorrectly enter
non-numeric values such as aNN for NaN, or Ifn for Inf, G passes over
them and uses the previous value.
The increment buttons usually change the ones digit. Increasing a digit
beyond 9 or decreasing below 0 affects the appropriate adjacent digit.
9-2
Chapter 9
9-3
Chapter 9
9-4
Chapter 9
9-5
Chapter 9
Precision
Note:
Single
Double
Extended
(platformdependent)
Minimum
Positive
Number
1.5E45
5.0E324
1.9E4951
Maximum
Positive
Number
3.4E38
1.7E308
1.1E4932
Minimum
Negative
Number
1.5E45
5.0E324
1.9E4951
Maximum
Negative
Number
3.4E38
1.7E308
1.1E4932
Although G can process in the range shown in Table 9-1, the range of
extended floating-point numbers it can represent and display in text format
is 9.9999999999999999E999.
You can choose other limits within these natural bounds with the Data
Range option from the pop-up menu. The following dialog box
appears.
9-6
Chapter 9
Coerce
9-7
Chapter 9
Suspend
A top-level VI with controls whose values are invalid cannot run. If the
value of a control is invalid before a subVI runs (when a subVI is about
to execute), the VI is suspended. The front panel of the VI opens (or
becomes the active window) and the invalid control(s) are outlined in
red (or a thick black line on a black-and-white monitor). The toolbar on
the block diagram of a suspended subVI looks like the following
illustration.
You must set the control to a valid value before you can proceed. When
all control values are valid, the toolbar looks like the following
illustration, and you can click on the Run button to continue execution.
Run button
Return to Caller button
You must set indicators to valid values before you can return to the
calling VI. You also can change the control values to produce valid
outputs and run the subVI again by clicking on the Run button. When
9-8
Chapter 9
all indicator values are valid, the toolbar looks like the following
illustration, and you can click on the Return to Caller button to
continue execution.
9-9
Chapter 9
You can see an example at the top of the dialog box as you make
selections. Examples of format and precision settings on a digital
control are shown in the following illustration.
floating-point notation
4 digits of precision
scientific notation
6 digits of precision
engineering notation
3 digits of precision
relative time
seconds
To format absolute time and/or date, select Time & Date from the
Format ring at the top of the dialog box. The dialog box changes, as
shown in the following illustration.
You can format for either time or date, or both. If you enter only time
or only date, G infers the unspecified components. If you do not enter
time, G assumes 12:00 a.m. If you do not enter date, it assumes the
previous date value. If you enter date, but the control is not in a date
9-10
Chapter 9
format, G assumes the month, day, and year ordering based on the
settings in the Preferences dialog box. If you enter only two digits for
the year, G assumes the following: any number less than 38 is in the
twenty-first century, otherwise the number is in the twentieth century.
Though absolute time is displayed as a time and date string, it is
represented internally as the number of seconds since 12:00 a.m.
Jan. 1, 1904, Universal Time. G keeps track of these components
internally.
Note:
When a control is in absolute time format, you always have the option to
enter time, date, or time and date. If you do not want G to assume a date,
use relative time.
Notice the examples at the top right of the dialog box, which change as
you make selections.
The valid range for time and date differs across computer platforms as
follows:
(Windows) 12:00 a.m. Jan. 2, 1970 12:00 a.m. Feb. 4, 2106
(Windows NT) 12:00 a.m. Jan. 2, 1970 12:00 a.m. Jan. 17, 2038
(Macintosh) 12:00 a.m. Jan. 2, 1904 12:00 a.m. Jan. 2, 2040
(UNIX) 12:00 a.m. Dec. 15, 1901 12:00 a.m. Jan. 17, 2038
9-11
Chapter 9
Each slide has a digital display. You can use the digital displays to enter
data into slide controls, as explained in the Digital Controls and
Indicators section of this chapter. You can use the Operating tool on
such parts as the slider, the slide housing, the scale, and increment
buttons to enter data or change values. The slider is the part that moves
to show the value of the control. The housing is the stationary part that
the slider moves on or over. The scale indicates the value of the slider,
and the increment buttons are small triangles at either end of the
housing. An example of a slider is shown in the following illustration.
9-12
Chapter 9
You can drag the slider with the Operating tool to a new position. If the
VI is running during the change, intermediate values might pass to the
program, depending on how often the VI reads the control.
You also can click on a point on the housing and the slider snaps to that
location as shown in the following illustration. Intermediate values do
not pass to the program.
If you use a slide that has increment buttons, you can click on an
increment button, as shown in the following illustration, and the slider
moves slowly in the direction of the arrow. Hold down the <Shift>
key to move the slider faster. Intermediate values might pass to the
program.
9-13
Chapter 9
Slide Scale
The scale submenu options apply to the scale for the slide only. The
scale pop-up menu is shown in the following illustration.
9-14
Chapter 9
The Mapping item shows you the option of linear or logarithmic scale
spacing, as shown in the following illustration.
If you change to Logarithmic spacing, and the low scale limit is less
than or equal to 0, the limit automatically becomes a positive number,
and G revalues other markers accordingly. Keep in mind that scale
options, including the mapping functions, are independent of the slide
data range values, which you change with the Data Range pop-up
option. If you want to limit your data to logarithmic values, you need to
change the data range to eliminate values less than or equal to zero.
Scale Markers
The scale of a numeric control or indicator has two or more markers,
which are labels that show the value associated with the marker
position.
You can change the outer two markers, the scale limits, and you can
change any inner markers from even spacing to place them anywhere
you want.
9-15
Chapter 9
scale
range
data range
representation limits
If you type a new maximum value into its display, the minimum
stays the same, and G recalculates the increment automatically.
If you type a new minimum value into its display, the maximum
stays the same, and G recalculates the increment automatically.
If you type the current minimum value into the maximum display,
G flips the scale so that what was formerly the minimum is now the
maximum, and can flip the scale so that what was formerly the
maximum is now the minimum. G also recalculates the increments.
If you change the size of the slide, the increment adjusts so that the
markers do not overlap.
9-16
Chapter 9
Then, you can pop up on the slide and select ScaleAdd Marker or pop
up on the marker and select Add Marker. A marker appears at an
arbitrary location, as shown in the following illustration.
9-17
Chapter 9
key while dragging creates a new marker. (If the ticks are hidden, as
chosen in the ScaleStyle dialog box, you cannot drag them.)
The arbitrary markers affect only the inner markers, not the two end
markers. If no arbitrary markers are visible in the current range, the
scale reverts temporarily to uniform markers.
Text Scale
You also can use text labels on numeric scales. Labels are useful
because you can associate strings with integer values. This
configuration is useful for selecting mutually exclusive options. To
implement this option, select Text Labels from the slide pop-up menu.
The slide control appears with default text labels, min and max, and
you can begin typing immediately to enter the labels you want. Press
<Shift-Enter> (Windows and HP-UX), or <Shift-Return>
(Macintosh and Sun) after each label to create a new label, and <Enter>
on the numeric keypad after you have finished your last label.
You can use the Labeling tool to edit min and max labels in the text
display or on the slide itself.
9-18
Chapter 9
You can pop up on the text display and select ShowDigital Display to
find out what numeric values are associated with the text labels you
create. These values always start at zero (on the bottom of vertical slides
and on the left or right of horizontal slides) and increase by one for each
text label.
Use the Add Item After or Add Item Before option from the text
display pop-up menu to create new labels, as shown in the following
illustration.
9-19
Chapter 9
You also can show more than one value on the same slide. To do so,
choose Add Slider from the pop-up menu. A new slider appears along
with a new digital display as shown in the following illustration.
When you do this, two more options appear in the Fill Options palette:
Fill to Value Above and Fill to Value Below. These options apply to
the active slider. All five options appear in the following illustration.
9-20
Chapter 9
9-21
Chapter 9
The rotary objects have most of the same options as the slide. The
sliders (or needles) in rotary objects turn rather than slide, but you
operate them the same way you operate slides.
Rotary controls, like linear controls, can display more than one value,
as shown in the preceding illustration. You add new values by selecting
Add Needle from the pop-up menu, in the same way you add new
values to slides.
If you move the Positioning tool to the scale, the tool changes to a rotary
cursor. If you click on and drag the outer limits of the scale, you can
change the arc that the scale covers. If you click on and drag the inner
markers of the scale, you can rotate the arc; it still has the same range
but different starting and ending angles. This procedure is shown in the
following illustration. Hold down the <Shift> key to snap the arc to
45-degree angles.
Place the cursor on the knob scale, where it changes appearance to a
double arrow horseshoe.
9-22
Chapter 9
Tick marks of rotary scales can be dragged with the Operating tool, just
like linear scales. Ticks also can be unevenly distributed in a similar
manner to linear scales. See the section Selecting Non-Uniform Scale
Marker Distribution for more information.
For more information on ring controls and indicators, see Chapter 13,
List and Ring Controls and Indicators.
9-23
Chapter 9
Color Box
The color box displays a color corresponding to a specified value. The
color value is expressed as a hexadecimal number with the form
RRGGBB, in which the first two numbers control the red color value, the
second two numbers control the green color value, and the last two
numbers control the blue color value. An example is shown in the
following illustration.
You can set the color of the color box by clicking on it with either the
Operating or Color tool to display a Color palette, as shown in the
following illustration. Releasing your mouse button on the color you
want selects that color.
Color boxes typically are used on the front panel as indicators. The
easiest way to set the color of a color box is to use the color box
constant, from the FunctionsNumericAdditional Numeric Constants
palette in the block diagram window. Wire the color box constant to the
color box terminal on the block diagram. Clicking on the color box
constant with either the Operating tool or the Color tool displays the
same Color palette that you use to set the color box. If you want to
change the color box indicator on the front panel to various colors
which indicate different conditions, you can use a series of color box
constants inside a Case Structure.
The small T in the Color palette represents the transparent color.
9-24
Chapter 9
Color Ramp
The color ramp displays a color corresponding to a specified value. You
can configure a color scale, which consists of at least two arbitrary
markers, each consisting of a level and the display color corresponding
to that level. As the input value changes, the color displayed changes to
the color corresponding to that value. An example is shown in the
following illustration.
overflow color
ramp
underflow color
digital display
You create these pairs using the arbitrary markers of the color scale.
Each arbitrary marker specifies a level and has a color associated
with it.
When the color ramp first appears on the front panel, it is set to have
three levels. Level 0 is set to the value 0, and the color black. Level 1 is
set to the value 50 and the color blue. Level 2 is set to the value 100 and
the color white. You can add levels, change the values, and set the
colors as you choose.
Use the Interpolate Colors option of the color ramp pop-up menu to
select a color if the control interpolates colors to display shades of color
for values between the indicated levels, or changes to a specific color
only when the input value reaches a level specified in the color array. If
Interpolate Colors is off, the color is set to the color of the largest level
less than or equal to the current value.
9-25
Chapter 9
The color array always is sorted by level. The scale on the ramp
corresponds to the largest and smallest values in the array. When the
minimum or maximum of the scale changes, the color array levels are
redistributed automatically between the new values.
The color scale has a number of options, which you can display or hide.
These options include the unit label, the digital display, and the ramp.
The ramp component of this control has an extra color at the top and the
bottom of the scale. You can use these colors to select a color to display
if an overflow or an underflow occurs. Click on these areas with the
Operating tool and select your overflow and underflow colors from the
Color palette.
Both the color ramp and the color box are used to display a numeric
value as a color. With the color ramp, you can assign any range of
numbers to any range of colors. The color box, however, displays only
the color specified by the red, green, and blue components of the
numeric value; any given value always maps to the same color.
Note:
The color ramp can have as many colors as your monitor can handle, but
no more colors than what are available on your monitor.
You can use the color scale to indicate color tables for the Intensity
Graph and Intensity Chart controls. See Chapter 15,
Graph and Chart Controls and Indicators, for more information on these
controls.
Unit Types
Any numeric control can have physical units, such as meters or
kilometers/second, associated with it. Any numeric control with an
associated unit is restricted to a floating-point data type.
Units for a control are displayed and modified in a separate but attached
label, called the unit label. You can show this label by selecting the
option from the pop-up menu, as shown in the following illustration.
9-26
Chapter 9
When the unit label is displayed, you can enter a unit using standard
abbreviations such as m for meters, ft for feet, s for seconds, and so on.
If you are not familiar with which units are acceptable, enter a simple
unit such as m, then pop up on the unit label and select Unit. A dialog
box appears that contains information about the units that are available.
You can use this dialog box to replace your first unit with a more
appropriate choice.
The following numeric control is set to have units of meters per second.
9-27
Chapter 9
Table 9-6-1 through Table 9-6-5 list all the units you can use with the
units feature.
Table 9-2.
Quantity Name
Unit
Abbreviation
plane angle
radian
rad
solid angle
steradian
sr
time
second
length
meter
mass
gram
electric current
ampere
thermodynamic
temperature
kelvin
amount of
substance
mole
mol
luminous intensity
candela
cd
Table 9-3.
Quantity Name
Base Units
Unit
Abbreviation
frequency
hertz
Hz
force
newton
pressure
pascal
Pa
energy
joule
power
watt
electric charge
coulomb
9-28
Chapter 9
Table 9-3.
Quantity Name
Unit
Abbreviation
electric potential
volt
capacitance
farad
electric resistance
ohm
Ohm
conductance
siemens
magnetic flux
weber
Wb
magnetic flux
density
tesla
inductance
henry
luminous flux
lumen
lm
illuminance
lux
lx
Celsius
temperature
degree
Celsius
degC
activity
becquerel
Bq
absorbed dose
gray
Gy
dose equivalent
sievert
Sv
Table 9-4.
Quantity Name
Unit
Abbreviation
time
minute
min
time
hour
time
day
plane angle
degree
deg
9-29
Chapter 9
Table 9-4.
Quantity Name
Unit
plane angle
minute
'
plane angle
second
"
volume
liter
mass
metric ton
area
hectare
ha
energy
electron
volt
eV
mass
unified
atomic
mass unit
Table 9-5.
Quantity Name
CGS Units
Unit
Abbreviation
area
barn
force
dyne
dyn
energy
erg
erg
pressure
bar
bar
Table 9-6.
Abbreviation
Other Units
Quantity Name
Unit
Fahrenheit temperature
degree Fahrenheit
degF
Celsius temperature
difference
Celsius degree
Cdeg
9-30
Abbreviation
Chapter 9
Table 9-6.
Quantity Name
Unit
Abbreviation
Fahrenheit temperature
difference
Fahrenheit degree
Fdeg
length
foot
ft
length
inch
in
length
mile
mi
area
acre
acre
pressure
atmosphere
atm
energy
calorie
cal
energy
Btu
Entering Units
If you try to enter an invalid unit into a unit label, G flags the invalid
unit by placing a ? in the label, as shown in the following illustration.
Notice that you must enter units using the correct abbreviations or G
flags it, as shown in the following illustration.
9-31
Chapter 9
Also, keep in mind that you cannot enter ambiguous units. Thus, m/ss
is flagged in the following illustration, because it is not clear if it means
meters per second squared, or (meters/seconds) * seconds. To resolve
ambiguity, you have to enter the units differently, as shown in the three
examples to the right.
You cannot select units for a chart or graph unless you wire them to an
object that has an associated unit. Then, you can show the unit that the
chart or graph has acquired through the connection. You can change this
unit to another unit that measures the same phenomenon, but not to a
unit measuring a different class of quantity or quality. For example, if
an input to a chart carries the unit mi, you can edit the chart unit to ft,
in, or m, but not to N, Hz, min, acre, or A.
9-32
Chapter 9
9-33
Chapter 9
for the broken wire shown below, the List Errors window indicates that
the error is Wire: unit conflict.
Some functions are ambiguous with respect to units and cannot be used
with signals that have units. For example, the Add One function is
ambiguous with respect to units. If you are using distance units, Add
One cannot tell whether to add one meter, one kilometer, or one foot.
Because of this ambiguity, the Add One function and similar functions
cannot be used with data that has associated units.
One way around this difficulty is to use a numeric constant with the
proper unit and the addition function on the block diagram to create
your own Add One unit function.
Note:
9-34
Chapter 9
Polymorphic Units
If you want to create a VI that computes the root mean square value of
a waveform, you have to define the unit associated with the waveform.
A separate VI is necessary for voltage waveforms, current waveforms,
temperature waveforms, and so on. In order to have one VI to do the
same calculation, regardless of the units received by the inputs, G has
polymorphic unit capability.
Create a polymorphic unit by entering $x, where x is a number (for
example, $1). You can think of this as a placeholder for the actual unit.
When the VI is called, G substitutes the units you pass in for all
occurrences of $x in that VI. The $x place holder always gets passed a
unit that is expressed in base units, for example, meters, meters/sec, not
feet, inches, and so on.
A polymorphic unit is treated as a unique unit. It is not convertible to
any other unit and propagates throughout the diagram just as other units
do. When it is connected to an indicator that also has the abbreviation
$1, the units match and the VI can compile.
$1 can be used in combinations like any other unit. For example, if the
input is multiplied by 3 seconds and then wired to an indicator, the
indicator must be $1 s units. If the indicator has different units, the
block diagram shows a bad wire.
If you need to use more than one polymorphic unit, you can use the
abbreviations $2, $3, and so on.
A call to a subVI containing polymorphic units computes output units
based on the units received by its inputs. For example, suppose you
create a VI that has two inputs with the polymorphic units $1 and $2
that creates an output in the form $1 $2 / s. If a call to the VI receives
inputs with the unit m/s to the $1 input and kg to the $2 input, the
output unit is computed as kg m / s^2.
Suppose a different VI has two inputs of $1 and $1/s, and computes
an output of $1^2. If a call to this VI receives inputs of m/s to the $1
input and m/s^2 to the $1/s input, the output unit is computed as m^2
/ s^2. If this VI receives inputs of m to the $1 input and kg to the
$1/s input, however, one of the inputs is declared to be a unit conflict
and the output is computed (if possible) from the other. A polymorphic
VI can have a polymorphic subVI because the respective units are kept
distinct.
9-35
Chapter
10
10-1
Chapter 10
Note:
The dialog button, dialog checkmark, and dialog radio button look
different on each platform. For information about dialog box controls on
various platforms, see the Customizing Dialog Box Controls section in
Chapter 8, Introduction to Front Panel Objects.
Some Boolean indicators that simulate LEDs and lights are shown in the
following illustration.
10-2
Chapter 10
The options above the dotted line in the pop-up menu are common to all
controls and indicators and are described in the Front Panel Control and
Indicator Options section of Chapter 8, Introduction to Front Panel
Objects. The Data Range and Mechanical Action options are discussed
later in this chapter.
10-3
Chapter 10
By default, the text is centered on the button. If you want to move the
text, select Release Text from the pop-up menu.
At this point, use the Positioning tool to reposition the text, or choose
the option Lock Text in Center. Select the Boolean text, then use the
Text menu to change the font, size, and color of the text. You also can
remove the Boolean text from both states by toggling the Boolean Text
option on the Show submenu.
The Boolean controls that do not appear in the palette as labeled
Booleans are unlabeled by default. However, you can select Boolean
Text from the Show submenu to make them labeled. You can move the
Boolean text in these Booleans. Their text is not locked in the center of
the button unless you select Lock Text in Center from the pop-up menu.
If you want to change the font of either the name label or the Boolean
text without changing both, select what you want to change with the
Labeling tool, and then use the Font ring options to make the changes
you want.
10-4
Chapter 10
when you operate the control, V stands for the output value of the
control, and RD stands for the point in time that the VI reads the control.
The Switch When Pressed action changes the control value each time
you click on it with the Operating tool, in a manner similar to that of a
light switch. The action is not affected by how often the VI reads the
control.
The Switch When Released action changes the control value only after
you release the mouse button during a mouse click within the graphical
boundary of the control. The action is not affected by how often the VI
reads the control.
The Switch Until Released action changes the control value when you
click on it, and retains the new value until you release the mouse button.
At this time, the control reverts to its original value, similar to the
operation of a door buzzer. The action is not affected by how often the
VI reads the control.
With Latch When Pressed action, the control changes its value when
you click on it, and retains the new value until the VI reads it once. At
this point, the control reverts to its default value, whether or not you
keep pressing the mouse button. This action is similar to that of a circuit
breaker and is useful for stopping While Loops or for getting the VI to
do something only once each time you set the control.
10-5
Chapter 10
The Latch When Released action changes the control value only after
you release the mouse button within the controls graphical boundary.
When your VI reads it once, the control reverts to the old value. This
guarantees at least one new value.
The Latch Until Released action changes the control value when you
click on it, and retains it until your VI reads it once or you release the
mouse button, depending on which one occurs last.
For an example of Boolean controls and indicators, see
general\controls\booleans.llb.
10-6
Chapter
11
This chapter discusses how to use string controls and indicators, and the
table. You can access these objects through the ControlsString &
Table palette, shown in the following illustration.
You enter or change text in the string control using the Operating tool
or the Labeling tool. As with the digital control, new or changed text
does not pass to the diagram until you press the <Enter> key on the
numeric keypad, click on the Enter button in the Tools palette, or click
outside the control to terminate the edit session. Pressing the <Enter>
(Windows and HP-UX), or <Return> (Macintosh and Sun) key on the
alphanumeric keyboard enters a carriage return.
11-1
Chapter 11
When the text reaches the right border of the display window, the string
wraps to the next line, breaking on a natural separator such as a space
or tab character.
Note:
When running a VI, you use the <Tab> key to move to the next control.
When editing a VI, pressing the <Tab> key changes tools. To enter a tab
character into a string, select the \ Codes option from the string pop-up
menu and type \t. To enter a linefeed into a string, press the <Enter>
(Windows and HP-UX), or <Return> (Macintosh and Sun) key on the
alphanumeric keyboard, or select the \ Codes option from the string
pop-up menu and type \n. To enter a carriage return into a string, select
the \ Codes option from the string pop-up menu and type \r. LabVIEW
users should refer to Table 12-1, LabVIEW \ Codes, for a complete list of
\ codes.
For information on manipulating strings, see the Online Reference
Function and VI ReferenceString Functions topic. Also, see the
examples in general\strings.llb.
11-2
Chapter 11
Scrollbar Option
The Scrollbar option from the string pop-up Show submenu is
disabled unless you have increased the size of your string enough for a
scrollbar to fit. If you select this option, a vertical scrollbar appears on
the string control or indicator as shown in the following illustration so
that you can display text not visible in the string control. You can use
this option to minimize the space taken up on the front panel by string
controls that contain a large amount of text. If the menu item is dimmed,
you must make the string taller to accommodate the scrollbar before
choosing this option.
Display Types
Options in the middle section of the string pop-up menu let you select
whether a string displays data as it normally does, displays backslash
codes in place of nonprintable characters, displays in password mode
(using an * in place of each character), or displays hexadecimal
characters.
11-3
Chapter 11
Code
G \ Codes
G Interpretation
\00 - \FF
\b
\f
\n
\r
\t
\s
\\
11-4
Chapter 11
When you enable the mode, the following string appears because the
carriage return after left and the backslash characters following it are
shown in backslash form as \n\\.
left\n\\right\\3F
Suppose now that you select \ Codes Display and you enter the
following string.
left
\right\3F
When you disable the mode, the following string appears because
G originally interpreted \r as a carriage return and now prints one. \3F
is the special representation of the question mark (?) and prints this way.
left
ight?
Now if you select \ Codes Display again, the following string appears.
left\n\right?
11-5
Chapter 11
Tables
A table is a 2D array of strings. The following illustration is an example
of a table with all its features shown.
call indicated
by index values
column
headings
vertical
index
horizontal
index
vertical
scrollbar
row
headings
horizontal
scrollbar
A table has row and column headings which are separated from the data
by a thin, open border space. You enter headings when you place the
table on the front panel, and you can change them using the Operating
tool or Labeling tool. You can update or read headings using the
Attribute Node.
The index display indicates which cell is visible at the upper left corner
of the table. You can operate these indices just as you do on an array.
11-6
Chapter 11
to drag a line, one of the drag cursors shown in the following illustration
appears. Click on a line and drag it to resize the row or column.
You can use the <Shift> key while dragging a border line to size
multiple rows or columns to be all the same size. If the row or column
you are resizing is inside an area of the table you have selected (outlined
in blue or bold), all the rows or columns in the table also are equally
sized. Thus, the uneven horizontal rows in the following illustration to
the left become evenly spaced in the illustration to the right.
11-7
Chapter 11
indicate that they have been selected. You can turn scrolling on or off
using the Selection Scrolling option in the table pop-up menu.
You also can select all the data in a table, or all the data in a row or
column. Position the Operating tool at the upper left corner of the table
to select all data. A special, double-arrow cursor appears when the tool
is positioned properly as shown in the following illustration. Click on
the area to select the data.
You can copy, cut and paste data, using the Copy Data, Cut Data, and
Paste Data options in the Data Operations submenu of the pop-up
menu.
If you cut any row or rows of data, all rows below it move up, as shown
in the top portion of the following illustration. If you cut any column of
data, all columns to the right scroll left, as shown in the bottom portion
of the illustration.
11-8
Chapter 11
Selecting a row
Selecting a column
To show a selected area of data, you can turn the option on or off by
selecting or deselecting Data OperationsShow Selection.
The row and column headings of a table are not part of the table data.
Table headings are a separate piece of data, and you can read and set
them using the Attribute Node.
The table is the same as a two-dimensional array of strings as far as the
block diagram is concerned. Because of this, string functions can
manipulate tables. See the Online ReferenceFunction and VI
ReferenceString Functions topic for information on using these
functions.
11-9
Chapter
12
This chapter describes how to use file path controls and refnums, which
are available from the ControlsPath & Refnum palette, shown in the
following illustration.
12-1
Chapter 12
You can use path controls and indicators to enter and display,
respectively, the location of a file or directory in a file system using the
standard syntax for a given platform. If a function that is supposed to
Path Symbol
return a path fails, it returns an invalid path. When an invalid path is
displayed by a path control or indicator, the Path symbol changes to the
Not a Path symbol, and <Not A Path> appears in the text field to
Not a Path Symbol indicate that the path is invalid.
You can change the value of a path control from a valid path to an
invalid path by clicking on the Path symbol and selecting the Not a
Path option from the menu. This is shown in the following illustration.
In the same way, you can change the value of a path control or indicator
from an invalid path to a valid empty path by clicking on the Not a Path
symbol and selecting the Valid Path option from the menu.
You might use this Not a Path value as the default value for a path
control on your VI. In this way, you can detect when the user has not
entered a path, in which case the user can use a file dialog box for
choosing a path.
Refnums
The Path & Refnums palette contains several refnum controls, shown
in the following illustration. These refnums generally are used to
identify I/O operations. G has seven refnum data types for various kinds
12-2
Chapter 12
Data
Log
File
RefNum
VISA
Session
RefNum
Device
RefNum
Occurrence
RefNum
Network
Connection
RefNum
VISA
Address
RefNum
To open a file, you must specify the path of the file you want to open.
Because you can open more than one file at a time, you need to indicate
which operations apply to which open file. The path control is not
sufficient for this, because you can open one file more than once,
concurrently.
When you open a file, G returns a refnum that identifies that file. You
use this refnum in all subsequent operations that relate to that file. You
can think of this refnum as a unique number produced each time you
open a file to identify it. When you close the file, the refnum is
disassociated from it.
Note:
You only need to use a refnum control or indicator if you want to pass a
refnum between two VIs.
If you are a LabVIEW user, refer to Chapter 5, VISA Transition Library
Reference in the LabVIEW Instrument I/O VI Reference Manual, for
information on the two VISA refnums.
There are two kinds of file refnums, one for datalog files and one for
byte stream files.
Because datalog files have an inherent structure, the Data Log File
RefNum is used to pass the refnum as well as a description of the file
type to (or from) calling VIs. The Data Log File RefNum is resizeable,
like a cluster. You place a control inside the refnum that defines the
12-3
Chapter 12
structure of the file. For a file that contains numbers, you create a
datalog refnum containing a number. If each record in the file contains
a pair of numbers, you place a cluster inside the refnum, and then place
two numeric controls inside the cluster.
The remaining refnums are easy to use, because they do not have any
options. The Byte Stream File RefNum is used with byte stream files,
either text or binary files. Typically, you use it when you open or create
a file in one VI but want to perform I/O on the file in another VI. You
need a refnum control on the front panel of the VI that performs I/O, and
a refnum indicator on the front panel of the VI that opens or creates the
file.
The Device RefNum is used with the device I/O functions available for
the Macintosh. It is used only when you open a device in one VI but
want to perform I/O on the device in another VI.
Note:
You rarely need to use a Device RefNum control on your front panel. These
controls are used in the Instrument I/O VIs in vi.lib to access the G
GPIB and serial device drivers. You only need to use a Device RefNum
control if you have to write a special-purpose G device driver for the
Macintosh.
The Network Connection RefNum is used with the TCP/IP VIs. You
generally use it when you open a network connection in one VI but want
to perform I/O on the network connection in another VI.
The Occurrence RefNum is used with the occurrence functions. You use
it only when you generate an occurrence in one VI but want to set or
wait for the occurrence in another VI.
The following illustration shows the front panel and block diagram of a
VI that uses and returns an Occurrence RefNum generated in
another VI.
front panel
12-4
block diagram
Chapter 12
The following illustration shows the front panel and block diagram of a
VI that uses and returns a Byte Stream File RefNum generated in
another VI.
front panel
block diagram
The following illustration shows the front panel and block diagram of a
VI that uses and returns a Data Log File RefNum generated in
another VI. Datalog files can contain any data type. The datalog file in
the following example contains numeric data.
front panel
block diagram
The following illustration shows the front panel and block diagram of a
VI that uses and returns a Network Connection RefNum generated in
another VI.
front panel
12-5
block diagram
Chapter
13
This chapter describes the listbox and ring controls and indicators,
which are available from the ControlsList & Ring palette, shown in
the following illustration.
The List & Ring palette contains eight controlsText Ring, Menu
Ring, Dialog Ring, Pict Ring, Text & Pict Ring, Single Selection
Listbox, Multiple Selection Listbox, and Enumerated Type. This
chapter discusses the ring controls, listbox controls, and the enumerated
type controls, in that order. For information about the attributes of
listbox and ring controls, see Chapter 20, Attribute Nodes.
Listbox Controls
Listbox controls are used to present users with a list of options. An
example is shown in the following illustration. There are two types of
listbox controlsSingle Selection in which only one option can be
13-1
Chapter 13
13-2
Chapter 13
Typing part of the name of the option you wantType the name of
the option to select the item. You also can use the left or right arrow
keys to go to the previous or next items that match the typed letters.
13-3
Chapter 13
Show
You use Show from the pop-up menu, shown in the following
illustration, to select which components of the listbox are visible. You
also can choose to show or hide the label, the scrollbar, and the symbols.
If you select ShowSymbols, the listbox adds an extra column to the left
side of the list for symbols. An example of this is shown in the
following illustration. Initially, no items have symbols. You can add
symbols using the Attribute Node.
Selection Mode
You use Selection Mode from the pop-up menu to indicate how many
items you can select at once.
13-4
Chapter 13
For a Single Selection Listbox, you have selection mode options to set
the listbox to support zero or one selections, or one selection, shown in
the following illustration.
If you select 1 Item (the default setting), then one option in the listbox
always is selected (highlighted). When you click on a different option,
the new option is selected (highlighted), and the previous option is
deselected. If you select 0 or 1 Item, the behavior is the same, with the
exception that a user can deselect the current option by
<Shift>-clicking on it, leaving no options selected.
In a Multiple Selection Listbox, you have the same selection mode
options as the Single Selection Listbox. In addition, you can indicate
that multiple options can be selected, as shown in the following
illustration.
13-5
Chapter 13
Keyboard Mode
You use Keyboard Mode from the pop-up menu, shown in the
illustration that follows, to indicate how the listbox should treat upper
and lower case characters when you select options by typing their initial
letters.
13-6
Chapter 13
Ring Controls
Rings are special numeric objects that associate unsigned 16-bit
integers with strings, pictures, or both. The different styles of rings are
shown in the following illustration.
In the preceding example, the ring labeled Trigger Mode has three
mode descriptors, one after another, in the text display of the ring. G
arranges items in a circular list (like a Rolodex) with only one item
visible at a time. Each item has a numeric value, which ranges from zero
to n 1, where n is the number of items (three in this example). The
value of the ring, however, can be any value in its numeric data range.
It displays the last item (External, above) for any value greater than
or equal to two and the first item (Continuous, above) for any value
less than or equal to zero.
13-7
Chapter 13
13-8
Chapter 13
Use the Remove Item command from the ring pop-up menu to delete
any item. As with the add item commands, the numeric values of the
item adjust automatically.
If you set a ring indicator or control to a value smaller than zero or
greater than the number of items included, the control or indicator
displays the first or the last item, respectively.
13-9
Chapter 13
13-10
Chapter 13
Front panel
object
digital display
Block diagram
One advantage of enumerated types over ring controls is that if you use
an enumerated type on the connector pane of a subVI, then popping up
to create a constant, control, or indicator will create an enumeration
with the proper strings.
You enter items into an enumerated type the same way you enter items
into a ring, using Add Item After or Add Item Before. Or, you can use
the Labeling tool. Press <Shift-Enter> (Windows and HP-UX), or
<Shift-Return> (Macintosh and Sun) to enter a new item. Click on
any area outside the enumerated type when you have finished entering
items.
If an enumerated type is wired to a Case Structure, the Case Structure
must have one frame for each item in the enumerated type. Pop up on
the Case Structure and select Add Case After if you need more frames.
Like a ring, the value of an enumerated type is the index of its current
items. You can pop up and select ShowDigital Display.
All arithmetic operations except Add One and Subtract One treat the
enumerated type the same as an unsigned numeric. Add One increments
the last enumeration to the first, and Subtract One decrements the first
enumeration to the last.
13-11
Chapter 13
13-12
Chapter
14
This chapter describes how to use arrays and clusters. You access arrays
and clusters from the ControlsArray & Cluster palette, shown in the
following illustration.
Arrays
An array is a variable-sized collection of data elements that are all the
same type, as opposed to a cluster, which is a fixed-sized collection of
data elements of mixed types. Array elements are ordered, and you
access an individual array element by indexing the array. The index is
14-1
Chapter 14
11-element
array
Melissa
Greg
Gregg
Don
Duncan
Thad
index (continued)
10
11-element array
(continued)
Dean
Stepan
Kate
Mary
Mark
Jeff
Paul
Kevin Tom
index
volts
0
0.4
0.9
1.4
0.8
-0.1
-0.7
-0.3
0.3
0.2
14-2
Chapter 14
index
X coord
0.4
Y coord
0.2
2.2
3.3
3.2
2.4
1.8
1.9
0.5
1.3
2.3
2.6
1.9
1.2
column index
1 2 3 4
row
1
index
6 Column by 4 Row
Array of 24 Elements
A simple example is a chess board. There are eight columns and eight
rows for a total of 64 positions, each of which can be empty or have one
chess piece. You can represent a chess board as a two-dimensional array
of strings. Each string has the name of the piece occupying the
corresponding location on the board, or it is an empty string if the
location was empty. Other familiar examples include calendars, train
schedule tables, and even television pictures, which can be represented
as two-dimensional arrays of numbers giving the light intensity at each
point. Familiar to computer users are spreadsheet programs, which have
rows and columns of numbers, formulas, and text.
All of the one-dimensional array examples can be generalized to two
dimensions. A collection of waveforms represented as a
two-dimensional array of numbers is shown in the following
14-3
Chapter 14
illustration. The row index selects the waveform and the column index
selects the point on the waveform.
1
2
3
4
5
6
7
8
point index
0
waveform 0 0.4 0.9 1.4 0.8 - 0.1 - 0.7 - 0.3 0.3 0.2
1.6 1.4 0.9 1.1
indices 1 - 0.5 0.6 0.4 0.2 0.8
2 1.6 1.4 0.7 0.5 - 0.5 - 0.6 - 0.2 0.3 0.5
Multiple Waveforms in a 2D Array of Numbers
volts
Arrays can have an arbitrary number of dimensions, but one index per
dimension is required to locate an element. The data type of the array
elements can be a cluster containing an assortment of types, including
arrays whose element type is a cluster, and so on. You cannot have an
array of arrays. Instead, use a multidimensional array or an array of
clusters of arrays.
Consider using arrays when you need to work with a collection of
similar data. Arrays are frequently helpful when you need to perform
repetitive computations or I/O functions. Using arrays makes your
application smaller, faster, and easier to develop because of the large
number of array functions and VIs in G.
14-4
Chapter 14
element display
A new array shell has one index display, an empty element display, and
an optional label.
14-5
Chapter 14
There are two ways to define an array type. You can drag a valid control
or indicator into the element display window, or you can deposit the
control or indicator directly by popping up in the element display area
of the array and selecting a control. Either way, the control or indicator
you insert fills the empty display.
For example, if you want to define an array of Booleans, you either can
drag a Boolean into the element display area, or you can pop up in the
empty element area and select a Boolean control. Both methods are
shown in the following illustrations.
or
14-6
Chapter 14
Array Dimensions
A new array has one dimension and one index display. You resize the
index vertically or select the Add Dimension option from the index
display pop-up menu to add a dimension. You shrink the index
vertically or select Remove Dimension to delete it. An additional index
14-7
Chapter 14
display appears for each dimension you add. Two methods for resizing
are shown in the following illustrations.
The dimension of an array is a choice you make when you decide how
many identifiers it takes to locate an item of data. For example, to locate
a word in a book you might need to go to the sixth word on the
twenty-eighth line on page 192. You need three indices, 6, 28, and 192
to specify the word, so one possible representation for this book is a
three-dimensional array of words. To locate a book in a library you
indicate the position on the shelf, which shelf, which bookcase, which
aisle, and which floor, so if you represented this as an array it uses five
dimensions. To locate a word in a library then requires eight indices.
14-8
Chapter 14
row
value at row, column
column
For example, say you have an array of 3 rows and 4 columns, with
values as shown in the following figure.
Rows and columns are zero-based, meaning that the first column is
column 0, the second column is column 1, and so forth. Changing the
index display to row 1, column 2 displays a value of 6, as shown in the
following illustration.
14-9
Chapter 14
is over the array shell resizing handles, and the cursor changes to the
usual symbol when you begin to resize. An example is shown in the
following illustration.
Usual Resizing
symbol
The index display contains the index of the element in the left or upper
left corner of the table. By changing the index, you can display different
sections of a large or multidimensional array. For one-dimensional (1D)
arrays, the index identifies the column of the left-most visible element.
For two-dimensional (2D) or higher arrays, the bottom two indices
identify the coordinates of the upper left visible element. In the left
portion of the following illustration, this element is [3,4].
G Programming Reference Manual
14-10
Chapter 14
page
row
column
If you want to hide the array indices, pop up on the outer frame and turn
off the ShowIndex Display option from the array pop-up menu. The
following illustration shows an example of what a tabular array looks
like without the index display.
Operating Arrays
You operate the element of the array exactly as if it were not part of the
array. You operate the index display the same way you operate a digital
control. To set the value of an array control element, bring the element
into view with the index display, then set the value of the element.
14-11
Chapter 14
to have a large default value, all of the default data is saved along with
the VI, thus increasing the size of your file.
A new array shell without an element is undefined. It has no data type
and no elements and it cannot be used in a program. After you assign an
element to the array, it is an empty array (its length is 0). Although it
also has no defined elements, you still can use it in the VI. The array
control dims all elements, indicating they are undefined.
The following illustrations show an array control in single-element
form that is wired to an array indicator in tabular form with five
elements displayed. The first figure shows that both arrays are empty
(element values are undefined).
If you set the index display of the array control to 9 and set the element
value at index 9 to 5.4, the data in the array expands to 10 elements
(0 to 9). The value of element 9 is the value you set, 5.4 in this example.
G assigns to the other elements the default value of the digital control,
0.00. After running the VI, the indicator displays the same values.
14-12
Chapter 14
value of 1.0, and element 12 has the assigned value of 7.0. This example
is shown in the following illustration.
If you now select Reinitialize to Default from either the shell or the
index pop-up menus, the array reverts to the 10-element array shown in
the previous example.
To increase the size of an array from [Ni by Nj by Nk] to [Mi by Mj
by Mk], assign a value to the new last element [Mi 1, Mj 1,
Mk 1]. To decrease the size, first execute the Data
OperationsEmpty Array command from the index array pop-up
menu, then set the array and values to the size you want, or select the
unwanted subset of the array and select the Data OperationsCut Data
option from the pop-up menu, as explained in the following sections.
Array Elements
When in run mode, you can use the <Tab> key either to move the key
focus between front panel controls or between elements within a single
array. Initially, the <Tab> key moves the key focus between front panel
controls. To have it move between the elements within a specific array,
first <Tab> to that array. Then use the <Ctrl> (Windows);
<command> (Macintosh); <meta> (Sun); or <Alt> (HP-UX) key and
the down arrow, which you can use to move between the array elements.
If you want to return to tabbing between controls, use the <Ctrl>
(Windows); <command> (Macintosh); <meta> (Sun); or <Alt>
(HP-UX) key and the up arrow.
14-13
Chapter 14
To select the data, set the array index to the first element in the data
set you want to copy.
2.
3.
Next, set the array index to the last element in the data set you want
to copy.
4.
When you are in run mode, these options are directly available when
you pop up on an array. The selection process is detailed in the
following example.
14-14
Chapter 14
You define the cells for selection with the array index. The following
example uses a two dimensional array.
Set the array index for 1,1. Choose Start Selection from the pop-up
menu. Set the array index to 3,3. Choose End Selection from the
pop-up menu. The selected cells are surrounded by a blue border (thick
black on a monochrome system).
The selection includes the cells denoted by lower index numbers but not
the cells denoted by the higher index numbers. If you want to include
14-15
Chapter 14
the cells from 1,1 to 3,3, you need to set the index to 4,4 before
choosing End Selection.
After you select cells, you can cut or copy the data to paste into other
cells. When you finish, notice that one border line remains highlighted.
This is an insertion point, and remains in the array. To hide this line, you
can deselect the Show Selection option from the pop-up menu. You can
eliminate this line without deselecting Show Selection by emptying the
selection. Set the index to 0 in all dimensions, and then select Start
Selection and End Selection. This makes the selection run from 0 to 0
in all dimensions, which is what the selection is set to when you first
place it on the front panel.
14-16
Chapter 14
. . .
sum = 0
for (i = 0; i < 100; i ++ )
sum += x[i] * x[i];
. . .
C Code Fragment
sum
G Direct Translation
sum
x
G Auto-Indexing Version
sum
x
G Optimal Version
Index Array
function icon
14-17
Chapter 14
bottom left terminal, and the array element value is wired to the right
terminal.
The following example shows the fundamental operation of replacing
an array element. The fragment of FORTRAN code generates a
histogram of random numbers (the random number generator produces
values between 0 and 1), and so does the G version. You can disregard
the +1 in the FORTRAN computation of J; the addition is needed
because FORTRAN arrays are one-based.
. . .
DO 10 I = 1, 10000
J = 100.0 * RAND( ) + 1
H(J) = H(J) + 1
10 CONTINUE
. . .
G Direct Translation
Replace Array
Element function
14-18
Chapter 14
Clusters
A G cluster is an ordered collection of one or more elements, similar to
structures in C and other languages. Unlike arrays, clusters can contain
any combination of G data types. Although cluster and array elements
are both ordered, you access cluster elements by unbundling all the
elements at once rather than indexing one element at a time. Clusters are
also different from arrays in that they are of a fixed size. As with an
array, a cluster is either a control or an indicator; a cluster cannot
contain a mixture of controls and indicators.
You can use clusters to group related data elements that appear in
multiple places on the diagram, which reduces wire clutter and the
number of connector terminals subVIs need.
Most clusters on the block diagram have a common wire pattern,
although clusters of numbers (sometimes referred to as points) have a
special wire pattern.
Common Cluster Wire Pattern
You can connect terminals only if they have the same type. For clusters,
this means that both clusters must have the same number of elements,
and corresponding elementsdetermined by the cluster ordermust
match in type. G coerces numbers of different representations to the
same type.
14-19
Chapter 14
Creating Clusters
You create a cluster control or indicator by installing any combination
of Booleans, strings, charts, graph scalars, arrays, or even other clusters
into a cluster shell. You access the cluster shell from the Controls
palette, as shown in the following illustration.
14-20
Chapter 14
indicators the same way you configure controls and indicators that are
not in a cluster.
Cluster Elements
When in run mode, you can use the <Tab> key either to move the key
focus between front panel controls, or between elements within a single
cluster. Initially, the <Tab> key moves the key focus between front
panel controls. To have it move between the elements within a specific
cluster, first <Tab> to that cluster. Then use the <Ctrl> (Windows);
<command> (Macintosh); <meta> (Sun); or <Alt> (HP-UX) key and
the down arrow, which you can use you to move between the cluster
elements. If you want to return to tabbing between controls, use the
<Ctrl> (Windows); <command> (Macintosh); <meta> (Sun); or
<Alt> (HP-UX) key and the up arrow.
14-21
Chapter 14
Cluster Order option from the cluster pop-up menu. The appearance
of the element changes, as shown in the following illustration.
new place
in order
Enter button
current place
in order
The white boxes on the elements show their current places in the cluster
order. The black boxes show the new position of the element in the
order. Clicking on an element with the cluster order cursor sets the
position of the element in the cluster order to the number displayed
inside the Tools palette. Change this order by typing a new number into
that field. When the order is as you want it, click on the enter button to
set it and exit the cluster order edit mode. Click on the X button to revert
to the old order.
X button
The cluster order determines the order in which the elements appear as
terminals on the Bundle and Unbundle functions in the block diagram.
For more information on these functions, see the Online Reference
Function and VI ReferenceString Functions topic.
14-22
Chapter 14
Cluster Assembly
G has three functions for assembling or building clusters. The Bundle
and Bundle By Name functions assembles a cluster from individual
elements or replaces individual elements with elements of the same
14-23
Chapter 14
Bundle Function
Bundle function
The Bundle function, which you obtain from the Array & Cluster
palette of the Functions palette, appears on the block diagram with two
element input terminals on the left side. You can resize the icon
vertically to create as many terminals as you need. The element you
wire to the top terminal becomes element 0 in the output cluster, the
element you wire to the second terminal becomes element 1 in the
output cluster, and so on.
As you wire to each input terminal, a symbol representing the data type
of the wired element appears in the formerly empty terminal shown in
the following illustration. You must wire all the inputs that you create.
In addition to input terminals for elements on the left side, the Bundle
function also has an input terminal for clusters in the middle as shown
in the following illustration. You use this terminal to replace one or
more elements of an existing cluster wire without affecting the other
elements.
14-24
Chapter 14
Because the name does not denote a position within the cluster, you
must wire a cluster to the middle terminal as well. You can use the
Bundle By Name function only to replace elements by name, not to
create a new cluster. You might, however, wire a data type cluster to the
middle terminal, and then wire all of the new values as names to
produce this same behavior.
For example, suppose you have a cluster containing a string called
Name and a number called Age. After placing the Bundle By Name
function, you first need to connect an input cluster to the middle
terminal of the Bundle By Name function.
After you have wired the middle terminal, you can select elements you
want to modify by popping up on any of the left terminals of the Bundle
By Name function. You then see a list of the names of the elements in
the source cluster. After you select a name, you can wire a new value to
14-25
Chapter 14
You can resize the Bundle By Name function to show as many or as few
elements as you need. This is different from the Bundle function, which
requires you to size it to have the same number of elements as are in the
resulting cluster.
14-26
Chapter 14
14-27
Chapter 14
elements of the cluster, you can avoid breaking the VIs that use the
cluster.
See the Type Definitions section of Chapter 22, Custom Controls and
Type Definitions, for more information on type definitions. Also, see
the Unbundle By Name Function section of this chapter.
The Array To Cluster function, which you select from the Array palette
of the Functions palette, converts the elements of a 1D array to
elements of a cluster. This function is useful when you want to display
elements within a front panel cluster indicator, but you also want to
manipulate the elements by index value on the block diagram.
Use the Cluster Size option from the function pop-up menu to
configure the number of elements in the cluster. The dialog box that
appears is shown in the following illustration.
The function assigns the 0th array element to the 0th cluster element,
and so on. If the array contains more elements than the cluster, the
function ignores the remaining elements. If the array contains fewer
elements than the cluster, the function assigns the extra cluster elements
the default value for the element data type.
The illustration that follows shows how to display an array of data in a
front panel cluster indicator. With this technique, you can organize the
array elements on the front panel to suit your application. You might
use a tabular array indicator instead, but that limits you to a fixed
display formathorizontal with the lowest element at left and an
attached index display.
14-28
Chapter 14
Cluster Disassembly
G has three functions for disassembling clusters. The Unbundle and
Unbundle By Name functions disassemble a cluster into individual
elements, and the Cluster To Array function converts a cluster of
identically typed elements into an array of elements of that type.
Unbundle Function
Unbundle function
The Unbundle function, which you obtain from the Array & Cluster
palette of the Functions palette, has two element output terminals on
the right side. You adjust the number of terminals with the Resizing tool
the same way you adjust the Bundle function. Element 0 in the cluster
order passes to the top output terminal, element 1 passes to the second
terminal, and so on.
The cluster wire remains broken until you create the correct number of
output terminals. When the number of terminals is correct, the wire
14-29
Chapter 14
becomes solid. The terminal symbols display the element data types, as
shown in the following illustration.
The Unbundle By Name function, also in the Array & Cluster palette
of the Functions palette, is similar to the Unbundle function. Instead of
referencing fields by position, however, you reference them by name.
Unlike the Unbundle function, you can read only the elements that you
want to read; you do not have to have one output for every cluster
element.
For example, the following is a panel with a cluster of three elements,
weight, height and age.
14-30
Chapter 14
You can resize the function to read other elements, shown in the
following illustration. Keep in that you do not have to read all of the
elements and that you can read them in arbitrary order.
14-31
Chapter 14
For example, with the previous cluster, you add a string for birthdate,
and the diagram still is correct. This example is shown in the following
illustration.
The Cluster To Array function, which you obtain from the Conversion
palette of the Functions palette, converts the elements of a cluster into
a 1D array of those elements. The cluster elements must all be the same
type. The array contains the same number of elements as the cluster.
Cluster elements cannot be array elements. If you have a cluster of
N-dimensional arrays that you want to convert to an
(N + 1)-dimensional array, you must unbundle the cluster elements with
the Unbundle function and wire them to a Build Array function.
The Cluster To Array function is useful when you want to group a set
of front panel controls in a particular order within a cluster, but you also
14-32
Chapter 14
14-33
Chapter
15
This chapter describes how to create and use the graph and chart
indicators in the ControlsGraph palette.
A graph indicator is a two-dimensional display of one or more plots.
The graph receives and plots data as a block. A chart also displays plots,
but it receives the data and updates the display point by point or array
by array, retaining a certain number of past points in a buffer for display
purposes.
In addition to the information in this chapter, you might find it helpful
to study the graph and chart examples. These examples are located in
general\examples\general\graphs.
G has three kinds of graphs and two kinds of charts. These are shown in
the following illustration starting at the top from left to right
waveform chart, waveform graph, XY graph, intensity chart, and
intensity graph.
15-1
Chapter 15
The waveform graph plots only single-valued functions with points that
are evenly distributed with respect to the x-axis, such as acquired
time-varying waveforms. The XY graph is a general-purpose, Cartesian
graphing object you can use to plot multivalued functions such as
circular shapes or waveforms with a varying timebase. Both graphs can
display any number of plots.
Each of these graphs can accept several data types. This minimizes the
extent to which you need to manipulate your data before displaying it.
These data types are described in the next section.
Following the section on graph data types are sections describing some
of the more advanced options of the graph. These include customizing
the appearance of the graph, displaying and manipulating cursors, and
displaying a legend for the graph.
15-2
Chapter 15
15-3
Chapter 15
The first data type that the XY graph accepts is a cluster containing an
x array and a y array. The following diagram illustrates how you can
create this kind of data.
15-4
Chapter 15
If you select the Transpose Array option from the graph pop-up menu,
each column of data is handled as a plot. This is particularly useful
when sampling multiple channels from a data acquisition board,
because that data is returned as 2D arrays, with each channel stored as
a separate column.
The following example shows how you use a graph to display two
signals, where each signal is a separate row of a two-dimensional array.
15-5
Chapter 15
multiple signals that were all sampled at the same regular rate. The
following diagram illustrates how you can create this kind of data.
The third data type is an array of clusters of an array of y data. The graph
interprets this data as points, with the points starting at x = 0 and
incremented by one.
15-6
Chapter 15
15-7
Chapter 15
of clusters can vary. The following diagram illustrates how you can
create this kind of data.
Notice that the arrays are bundled into clusters using the Bundle
function, and the resulting clusters built into an array with the Build
Array function. You can use the Build Cluster Array, which creates
arrays of clusters of specified inputs, instead.
The fifth data type is an array of clusters of an x value, a x value, and
an array of y data. This is the most general of the waveform graph
multiplot data types, because you can specify a unique starting point
15-8
Chapter 15
and increment for the x-axis of each plot. The following diagram
illustrates how you can create this kind of data.
15-9
Chapter 15
15-10
Chapter 15
15-11
Chapter 15
label
major grids
minor grids
legend
y-scale
x-scale
palette
Graphs have many options you can use to customize your data display.
The graph pop-up menu is shown in the following illustration.
Transpose Array is available with the waveform graph only.
Scale Options
Graphs automatically adjust their horizontal and vertical scales to
reflect the array of points you wire to them. You can turn this
15-12
Chapter 15
Marker Spacing
By default, marker values for x and y scales are uniformly distributed.
If you prefer, you can specify marker locations anywhere on the x or y
15-13
Chapter 15
scale. This is useful for marking a few specific points on a graph (such
as a set point or threshold).
If you want non-uniform marker distribution, choose X or Y Scale
Marker SpacingArbitrary Markers from the pop-up menu for the
scale. After making this selection, if you move the Operating tool over
a tick mark, the cursor changes to the double arrow cursor shown in the
following illustration. You can now create a new marker by dragging
the existing tick mark with the <Ctrl> (Windows); <option>
(Macintosh); <meta> (Sun); or <Alt> (HP-UX) key selected, or you
can move the existing tick mark anywhere on the scale you want by
dragging it.
You can add or delete a marker by popping up on the graph or the scale
and selecting Add Marker or Delete Marker. When a marker is created,
you can type a number in the marker to change its location.
15-14
Chapter 15
Formatting
Click on Formatting to bring up the dialog box shown in the
following illustration.
Select the options in this dialog box to set the following graph
properties.
Scale StyleUse this option to select major and minor tick marks for
the scale. Major tick marks are points corresponding to scale labels and
minor tick marks are interior points between labels. You also use this
palette to decide if you want the markers for a particular axis to be
visible.
Mapping ModeUse this option of the scale menus to decide if the
scale displays data using a linear or a logarithmic format.
Grid OptionsClicking on these options brings up a palette of grid
types to select if you want no gridlines, gridlines only at major tick
mark locations (points corresponding to scale labels) or major and
minor tick marks (minor tick marks are interior points between labels).
The control next to the grid pop-up is a color ring you can use to select
the color for the gridlines.
Scaling FactorsYou use the scaling factors to specify the initial
value and spacing between points on a waveform chart or graph, or
along the scales of an intensity chart or graph. You also can use these
15-15
Chapter 15
scaling factors to scale your data for display. For example, if your data
was binary sampled data in a range of 2,048 to 2,047, you scale this
data to its appropriate voltage values of 10 to 10 by specifying an
additive offset of 2,038, and a scaling factor of 4,096/20 = 204.8.
Format & PrecisionAt the top of the dialog box is a pop-up menu
from which you can decide if the X or Y scale is formatted for numerics
or for time and date.
If you select Numeric formatting, you can choose if the notation is
floating-point, scientific, engineering, or relative time in seconds; if the
notation is (decimal, unsigned decimal, hexadecimal, octal, and
binary); and you can select the precision, that is how many digits are
displayed to the right of the decimal point, from 0 through 20. The
precision you select affects only the display of the value; the internal
accuracy still depends on the representation. Examples are shown in the
dialog box as you select each combination of options.
If you select Time & Date formatting, the dialog box changes, as shown
in the following illustration.
You can format for either absolute time or date, or both. If you edit a
scale and enter only time or only date, the unspecified components are
inferred. If you do not enter time when editing, it assumes 12:00 a.m. If
you do not enter a date, the previous date value is assumed. If you enter
date, but the scale is not in a date format, the month, day, and year
15-16
Chapter 15
When a scale is in absolute time format, you always have the option to enter
time, date, or time and date. If you do not want G to assume a date, use
relative time.
Notice the examples at the top right of the dialog box, which change as
you make selections.
The valid range for time and date differs across computer platforms as
follows:
(Windows NT) 12:00 a.m. Jan. 1, 1970 12:00 a.m. Jan. 3, 2040
(UNIX) 12:00 a.m. Dec. 15, 1901 12:00 a.m. Jan. 17, 2038
Autoscale
Use AutoScale (X or Y) to turn the autoscaling option on or off.
Loose Fit
Normally, G rounds the end markers of the scale to whole numbers. If
you want the scales to be set to exactly the range of the data, turn off the
Loose Fit option in the graph pop-up menu. With a loose fit, the
numbers are rounded to a multiple of the increment used for the scale.
For example, if the markers increment by five, the minimum and
maximum values are set to a multiple of five.
15-17
Chapter 15
of a graph) and for zooming in and out of sections of the graph. A graph
with its accompanying Graph palette is shown in the following
illustration.
If you press the x autoscale button, shown at the left, the graph
autoscales the X data. If you press the y autoscale button, shown at the
left, the graph autoscales the Y data. If you want the graph to autoscale
either of the scales continuously, click on the lock switch, shown at the
left, to lock autoscaling on.
By using the scale format buttons, shown left, you can maintain
run-time control over the format of the X and Y scale markers
respectively.
You use the remaining three buttons to control the operation mode for
the graph.
Normally, you are in standard operate mode, indicated by the plus or
crosshatch. In operate mode, you can click in the graph to move cursors
around.
If you press the Panning tool, shown to the left, you switch to a mode
in which you can scroll the visible data by clicking on and dragging
sections of the graph.
If you press the Zoom tool, shown at the left, you can zoom in on a
section of the graph by dragging a selection rectangle around that
section. If you click on the Zoom tool, you see a pop-up menu you can
15-18
Chapter 15
Zoom in about a point. If you hold down the mouse on a specific point,
the graph continuously zooms in until you release the mouse button.
Zoom out about a point. If you hold down the mouse on a specific point,
the graph continuously zooms out until you release the mouse button.
Note:
For the last two modes, zoom in and zoom out about a point,
<Shift>-clicking on zooms in the other direction.
Legend Options
The graph uses a default style for each new plot unless you have created
a custom plot style for it. If you want a multiplot graph to use certain
characteristics for specific plots (for instance, to make the third plot
blue), you can set these characteristics using the legend, which can be
shown or hidden using the Show submenu of the graph pop-up menu.
You also can indicate a name for each plot using the legend.
15-19
Chapter 15
When you select Legend, only one plot appears. You can create more
plots by dragging down a corner of the legend with the Resizing tool.
After you set plot characteristics, the graph assigns those characteristics
to the plot, regardless of if the legend is visible. If the graph receives
more plots than are defined in the legend, the graph draws them in
default style.
When you move the graph body, the legend moves with it. You can
change the position of the legend relative to the graph by dragging the
legend to a new location. Resize the legend on the left to make more
room on the labels, or on the right to make more room on the plot
samples.
By default, each plot is labeled with a number, beginning with zero.
You can modify this label the same way you modify other labels. To the
right of the plot label is the plot sample. Each plot sample has its own
pop-up menu to change the plot, line, color, and point styles of the plot.
The array of points you wire to the graph are displayed with the
characteristics you assign it in the graph legend.
The plot sample pop-up menu is shown in the following illustration.
The Common Plots option helps you configure a plot for any of six
popular plot styles, including a scatter plot, a bar plot, and a fill to zero
15-20
Chapter 15
plot. Options in this subpalette are preconfigured for the point, line, and
file styles in one step.
The Point Style, Line Style, and Line Width options display styles you
can use to distinguish a plot. The line width subpalette contains widths
thicker than the default 1 pixel, as well as the hairline option. The latter
option has no effect on the screen display, but prints a very thin line if
the printer and print mode support hairline printing.
Note:
15-21
Chapter 15
option at the top right plots the y-axis first, although the option at the
bottom right plots the x-axis first.
The Color option displays the palette for selecting the plot color. You
also can color the plots on the legend with the Color tool, and you can
change the plot colors while running the VI.
To change the properties of highlighted text, use the Font ring in the
toolbar.
Waveform Charts
The waveform chart is a special type of numeric indicator that displays
one or more plots. Charts are different from graphs in that charts retain
previous data, up to a maximum which you can define. New data is
appended to the old data, letting you see the current value in context
with previous data.
For an example of a waveform chart, see
general\examples\general\graphs\charts.llb.
15-22
Chapter 15
Following are diagrams illustrating how you can use the chart for each
of these kinds of data.
You receive the best performance from a chart when you pass it
multiple points at a time, because the chart has to be redrawn only once
for each waveform instead of once for each point.
You can pass data for multiple plots to a waveform chart in several
ways. The first method is to bundle the data together into a cluster of
scalar numerics, where each numeric represents a single point for each
of the plots. An example of this is shown in the following illustration.
15-23
Chapter 15
If you want to pass multiple points for plots in a single update, you can
wire an array of clusters of numerics to the chart. Each numeric
represents a single point for each of the plots. An example of this is
shown in the following illustration.
15-24
Chapter 15
You can use the Transpose Array option of the waveform chart pop-up
menu to handle columns as new data for each plot.
15-25
Chapter 15
With the Show submenu of the chart pop-up menu, you can show or
hide optional digital display(s) and a scrollbar. The Digital Display
option displays the latest value being plotted. The last value passed to
the chart from the diagram is the latest new value for the chart. There is
one digital display per plot.
You can view past values contained in the buffer by scrolling the x-axis
to a range of previously plotted values using the scrollbar, or by
changing the x scale range to view old data.
The chart has a limit to the amount of data it can remember to avoid
running out of memory. When the chart reaches that limit, the oldest
point(s) are thrown away to make room for new data. The default size
of this buffer is 1,024 points. You can change the length of this buffer
using the Chart History Length option from the chart pop-up menu.
15-26
Chapter 15
The strip chart mode has a scrolling display similar to a paper tape strip
chart recorder. As each new value is received, it is plotted at the right
margin, and old values shift to the left.
The sweep chart mode acts much like the scope chart, but it does not
blank when the data hits the right border. Instead, a moving vertical line
marks the beginning of new data and moves across the display as new
data is added.
15-27
Chapter 15
You can display multiple plots alternatively by stacking one above the
other, with a different Y scale for each plot, by selecting the Stack Plots
option from the chart pop-up menu. If you do this, the Y scale for each
15-28
Chapter 15
When you input data to the chart as a cluster, the chart automatically
stacks the correct number of plot displays. When you input data as a 2-D
array, you must create the correct number of plot displays using the
Legend, available in the Show submenu of the pop-up menu. As you
enlarge the Legend display to increase the number of plots, the number
of stacked plot displays increases to match.
Intensity Graphs
The intensity graph is essentially the same as the intensity chart, except
it does not retain previous data. Each time it is passed new data, the new
data replaces old data as it arrives.
For an example of an intensity graph, see
general\examples\graphs\ intgraph.llb.
15-29
Chapter 15
previous data, it does not have a scrollbar, and it does not have history
options.
The intensity graph can have cursors like other graphs. Each cursor
displays the X, Y, and Z values for a specified point on the graph. See
the Graph Cursors section of this chapter for more information on
manipulating the cursors on the graph.
You set the color mapping in the same way that you set it for the
intensity chart.
Graph Cursors
For each graph, you can display a Cursor palette that you use to put
cursors on the graph. You can label the cursor on the plot. You also can
use a cursor as a marker. When you use a cursor as a marker, you lock
the cursor to a data plot so that the cursor follows the data.
Cursors can be set and read programmatically using the Attribute Node.
You can set a cursor to lock onto a plot, and you can move multiple
cursors at the same time. There is no limit to the number of cursors that
a graph can have.
15-30
Chapter 15
Waveform Graph
Intensity Graph
15-31
Chapter 15
A label
A button that marks the plot for movement with the plot cursor pad
Y position
X position
Z position
Cursor display
control
Lock
control
The Cursor palette behaves like an array. You can stretch it to display
multiple cursors, and you can use the index control to view other
cursors in the palette. Use the Show options on the pop-up menu to
display the index control.
15-32
Chapter 15
To delete a cursor, you must select it using the Start Selection and End
Selection options on the Data Operations pop-up menu, and then cut
the cursor with the Cut option on the same menu. See the Selecting
Array Cells section of Chapter 14, Array and Cluster Controls and
Indicators, for more information.
You can move a cursor on a graph or chart by dragging it with the
Operating tool, or by using the cursor movement control. Clicking the
arrows on the cursor movement control causes all cursors selected to
move in the specified direction. You select cursors either by moving
them on the graph with the Operating tool, or by clicking on the select
button for a particular cursor. In the following example, the top two
cursors can be moved vertically downwards.
cursor display
control
Clicking on the cursor display control with the Operating tool displays
a pop-up menu that you can use to control the look of the cursor and the
visibility of the cursor name on the plot. This pop-up menu is shown in
the following illustration.
From this menu you can select the style of the cross hairs. The cross
hairs can consist of a vertical and/or horizontal line extending to
infinity, a smaller vertical and/or horizontal line centered about the
cursor location, or no cross hairs, as shown in the following illustration.
15-33
Chapter 15
You also can choose the style of point to use for marking the cursor
location and the color for the cursor as shown in the following
illustration.
15-34
Chapter 15
Select the Visible Name option from this menu to make the cursor name
visible on the plot, as shown in the following illustration.
Selecting Bring into View moves the cursor back into the displayed
region of the graph. This is helpful when the cursor has moved out of
visible range. Selecting this option changes the (x,y) coordinate position
of the cursor.
Selecting Goto Cursor moves the displayed region of the graph so that
the cursor is visible. The cursor position remains constant, but the
scales change to include the cursor selected. The size of the displayed
region also stays constant. This feature is helpful when the cursor is
used to identify a point of interest in the graph, such as a minimum or a
maximum, and you want to see that point.
unlocked
locked
You can use the last button for each cursor to lock a cursor onto a
particular plot. By clicking on the lock button you see a pop-up menu
that you can use to lock the cursor to a specific plot. If you lock the
cursor onto a plot, the button changes to a closed lock. This pop-up
menu is shown in the following illustration.
15-35
Chapter 15
The Allow Drag option determines if you can move the cursor with the
mouse. If Allow Drag is selected, you can move, or drag the cursor. If
Allow Drag is deselected, you cannot move the cursor around on the
plot. If you have Allow Drag selected, the options below the dotted line
of the menu determine how you can move the cursor with the mouse.
Select Free if you want to place or move the cursor anywhere on the
graph. Select Snap to Point if you want the cursor to always attach itself
to the nearest point on any plot. Select Lock to Plot to attach the cursor
to a specific point. The first time you select Lock to Plot, the cursor
attaches itself to the first point on the plot. After freeing the locked
cursor and moving it to any new position, selecting Lock to Plot moves
the cursor to the last location of the locked cursor.
Below the second dotted line of this menu is a list of the plots you can
lock to (for example, Plot 0, Plot 1, Plot 2, and so on).
A large number of options are available for creating, controlling, and
reading cursors or markers programmatically using the Attribute Node
for a graph. See Chapter 20, Attribute Nodes, for further information.
Intensity Charts
The intensity chart is a way of displaying three dimensions of data on a
two-dimensional plot by placing blocks of color on a Cartesian plane.
The intensity chart accepts a two-dimensional array of numbers. Each
number in the array represents a specific color. The indices of an
element in the two-dimensional array set the plot location for this color.
15-36
Chapter 15
Column = y
Row = x
10
50
13
45
61
10
13
Array
Element
=z
Color
5
6
blue
purple
10
lt red
13
dk red
45
orange
50
yellow
61
green
Resulting Plot
3
dk red
lt red
blue
yellow
green
dk red
lt red
orange
purple
You can define the colors for the intensity chart interactively, by using
the color scale, or you can define them programmatically through the
chart Attribute Node. The Color Mapping section later in this chapter
explains the procedure for assigning a color to a number.
The array indices correspond to the lower left vertex of the block of
color. The block has a unit area, as defined by the array indices. The
intensity chart can display up to 256 discrete colors.
After a block of data has been plotted, the origin of the Cartesian plane
is shifted to the right of the last data block. When new data is sent to the
15-37
Chapter 15
intensity chart, the new data appears to the right of the old data, as
shown in the following illustration.
Row = x
61
45
45
61
Resulting Plot
3
dk red
lt red
blue
blue
green
yellow
green
dk red
orange
blue
lt red
orange
purple
green
orange
3
(0)
4
(1)
5
(2)
When the chart display is full, the oldest data scrolls off the left side of
the chart.
See examples of intensity charts in
general\examples\general\graphs\intgraph.llb.
15-38
Chapter 15
color ramp control is used to define the range and mappings of values
to colors.
Following is a picture of a graph showing all of these optional
components except for the Cursor palette, which is discussed in the
Graph Cursors section of this chapter.
z scale color scale
y scale
x and y grids
scale
x scale
palette
scrollbar
Intensity charts have many options you can use to customize your data
display. The intensity chart pop-up menu is shown below in the
following illustration.
15-39
Chapter 15
Most of these options are identical to the options for the waveform
chart. With the Show menu, you can show and hide the color scale for
the z scale. The X Scale and Y Scale menus are identical to the
corresponding menus for the waveform chart.
The intensity chart maintains a history of data from previous updates.
You can configure this buffer by selecting Chart History Length
from the chart pop-up menu. The default size for an intensity chart is
128 points. Notice that the intensity chart display can be very memory
intensive. For example, to display a single precision chart with a history
of 512 points and 128 y values requires 512 * 128 * 4 bytes (size of a
single), or 256 kilobytes. If you want to display large quantities of data
on an intensity chart, make sure enough memory is available to G.
The intensity chart supports the standard chart update modes of strip
chart, sweep chart, and scope chart. As with the waveform chart, you
select the update mode from the Data Operations menu.
Color Mapping
You can set the color mapping interactively in the same way that you
define the colors for a color ramp numeric control. See the description
of the color ramp control in Chapter 9, Numeric Controls and
Indicators, for more details.
You can set the colors used for display programmatically using the
Attribute Node in two ways. First, you can specify the value-to-color
mappings to the Attribute Node in the same way you do it with the color
scale. For this method, you specify the Z Scale Info: Color Array
attribute. This attribute consists of an array of clusters, in which each
cluster contains a numeric limit value, along with the corresponding
color to display for that value. When you specify the color table in this
manner, you can specify an upper out-of-range color using the Z Scale
Info: High Color attribute, and a lower out-of-range color using the Z
Scale Info: Low Color. The total number of colors is limited to 254
colors, with the lower and upper out of range colors bringing the total
to 256 colors. If you specify more colors, then the 254 color table is
created by interpolating between the specified colors.
Another way to set the colors programmatically is to specify a color
table using the Color Table attribute. With this method you can specify
an array of up to 256 colors. Data passed to the chart is mapped to
indices in this color table based upon the color scale. If the color scale
ranges from zero to 100, a value of zero in the data is mapped to index
15-40
Chapter 15
one, and a value of 100 is mapped to index 254, with interior values
interpolated between one and 254. Anything below zero is mapped to
the out of range below color (index zero), and anything above 100 is
mapped to the out of range above color (index 255).
Note:
The colors you want your intensity chart (or graph) to display are limited
to the exact colors and number of colors that your video card has. You are
also limited by the number of colors that G allocates for your display.
15-41
Chapter
Introduction to the
Block Diagram
16
Terminals
G has many types of terminals. In general, a terminal is any point to
which you can attach a wire. G has control and indicator terminals, node
terminals, constants, and specialized terminals on structures.
Terminals that supply data, such as front panel control terminals, node
output terminals, and constants, also are called source terminals. Node
input terminals and front panel indicator terminals also are called
destination or sink terminals because they receive the data.
16-1
Chapter 16
Control
Indicator
Description
Extended-precision
floating-point
Orange
Double-precision
floating-point
Orange
Single-precision
floating-point
Orange
Complex
extended-precision
floating-point
Orange
Complex double-precision
floating-point
Orange
Complex single-precision
floating-point
Orange
16-2
Color
Blue
Chapter 16
Table 16-1.
Control
Indicator
Description
Color
Blue
Blue
Blue
Blue
8-bit integer
Blue
Cluster
Brown or Pink
Array
Varied
Path
Aqua
Refnum
Aqua
Boolean
Green
String
Pink
Constants
Constants are terminals on a block diagram that supply data values
directly to the block diagram. User-defined constants are defined prior
to program execution, and you cannot change their values during
execution. Universal constants have fixed values.
User-Defined Constants
The easiest way to create a constant is to pop up on an input or output
and select Create Constant. These constants are also available from
various palettes in the Functions palette, depending on their type. Most
are located at the bottom or top of the relevant palette, such as the
numeric, enumerated, and ring constants in the bottom row or the
Numeric palette. Three constantsthe color box, listbox symbol ring,
and error ring constantsare located in the NumericAdditional
16-3
Chapter 16
You can label your constant by popping up on the constant and selecting
ShowLabel. A highlighted text box appears, indicating that you can
type into it immediately without changing the tool.
The user-defined constants, like labels, resize automatically as you
enter information into them. If you resize or change the shape of a label
or string constant, you can select Size to Text from its pop-up menu,
and the constant or label resizes itself automatically to fit its contents.
You use the Operating tool to set the value of a user-defined constant
the same way you set the value of a digital control, Boolean slide
switch, or string control on the front panel. The numeric and string
constants resemble front panel numeric controls and have pop-up
menus similar to the pop-up menus of controls, as shown in the
following illustration.
16-4
Chapter 16
You can use the arrow keys to increment or decrement a new numeric
constant or one with its value selected. This is particularly useful when
programming control parameters with low values like 1, 2, or 3.
16-5
Chapter 16
The enumerated constant is similar to the ring constant except that the
mnemonics (strings associated with an integer value) are considered
part of the type. When an enumeration is wired to the selection terminal
of a Case Structure, cases are named according to the mnemonics of the
enumeration rather than traditional numeric values. The numeric
representation of an enumeration is always an unsigned byte, word, or
long.
The ring constant associates text with a number, the same way a ring
control on the front panel does. The value of the ring constant is an
unsigned 16-bit integer. Although you can change the representation of
a ring constant to any numeric type except complex, the value is still
always an integer from zero to n 1.
You can select colors from the color box constant to use with the color
box control, a control whose values correlate to specific colors. Set the
color box by clicking on it with the Color tool or the Operating tool and
choosing the color you want from the Color palette.
The listbox symbol ring constant is used to assign symbols to items in a
listbox control.
The error ring constant is a predefined ring. You click on the constant
with the Operating tool and select the error message you want from the
dialog box that appears, which is shown in the following illustration.
This ring is useful with the file I/O functions, because it makes the
diagrams more descriptive. For example, if you try to open a
nonexistent file using the Open File function, the function returns an
error code of 7. You can test for this condition by comparing the error
code output to an error ring set to a value of File Not Found (7).
16-6
Chapter 16
You can use the path constant to create a constant path value on the
block diagram.
The path, string, and color box constants are resizable, yet the Boolean,
numeric, ring, and enumeration constants are not. The default
representation of the numeric constant is a double-precision
floating-point number if you enter a floating-point number, a long
integer if you enter an integer, or a double-precision complex number if
you enter a complex number. For example, the representation is long
integer if you enter '123' and a double-precision floating-point number
if you enter '123.'. You can change the representation with the
Representation option from the constant pop-up menu.
Universal Constants
Universal constants are of two types: universal numeric constants and
universal string constants.
16-7
Chapter 16
Nodes
Nodes are the execution elements of a block diagram. The six types of
nodes are functions, subVIs, structures, Code Interface Nodes (CINs),
Formula Nodes, and Attribute Nodes. Functions and subVI nodes have
similar appearances and roles in a block diagram, but they have
substantial differences. They are explained in the following sections.
CINs are interfaces between the block diagram and code you write in
conventional programming languages, such as C or Pascal. If you are a
LabVIEW user, refer to the LabVIEW Code Interface Reference Manual
for more information.
Structures, which supplement the G dataflow programming model to
control execution order, are discussed briefly in the Structures section
of this chapter; for in-depth information, see Chapter 18, Structures.
Formula Nodes, which supplement G functions by using formulas on
the block diagram, are discussed in Chapter 19, Formula Nodes.
Attribute Nodes, which change control attributes programmatically, are
discussed in Chapter 20, Attribute Nodes.
Functions
Functions are elementary nodes built into G. They perform elementary
operations like adding numbers, file I/O, and string formatting.
G functions do not have front panels or block diagrams. When
compiled, they generate inline machine code. See Online
ReferenceFunction and VI Reference for detailed descriptions of
individual functions.
You select functions from the Functions palette, as shown in the
following illustration.
16-8
Chapter 16
When you select a function, its icon appears on the block diagram. To
display its label, pop up on the icon and select ShowLabel. You can
change the label if you want by highlighting the text with the Labeling
tool and typing over it. You can use the label of the function to annotate
its purpose in the block diagram.
You can use the Help window to see how to wire the function, or you
can select ShowTerminals from the icon pop-up menu, as shown in
the following illustration to see precisely where the terminals are
located.
16-9
Chapter 16
You also can change the number of terminals with the Add and Remove
commands from the pop-up menu for a terminal, as shown in the
illustration that follows. The Remove command removes the terminal
on which you popped up and disconnects the wire, if the terminal is
16-10
Chapter 16
wired, although the Add command adds a terminal immediately after it.
The full names of these commands vary with the function.
Structures
When you are programming, you sometimes need to repeat sections of
code a set number of times or while a certain condition is true. In other
situations, you need to execute different sections of code when different
conditions exist or execute code in a specific order. G contains four
special nodes, called structures. They help you to control code
execution, which otherwise is not possible within the G dataflow
framework.
Each structure has a distinctive, resizable border that you use to enclose
the code that executes under the structure's special rules. For this
reason, the diagram inside the structure border is called a subdiagram.
You can nest subdiagrams.
G uses the following structures to execute code.
16-11
Chapter 16
Because structures are nodes, they have terminals that connect them to
other nodes. For example, the terminals that feed data into and out of
structures are called tunnels. Tunnels are relocatable connection points
for wires from outside and inside the structures. See Chapter 18,
Structures, for more information.
When using Replace, if you select a VI whose name is the same as one
already in memory, the replaced node refers to the VI that was already in
memory, not the VI you selected.
Wire pop-up menus have an Insert option. Choosing Insert accesses
the Functions palette, from which you can choose any function or VI
on the palette. The editor then splices the node you choose into the wire
on which you popped up. You must be careful to check the wiring if the
node has more than one input or output terminal, however, because the
wires might not connect to the terminal you expected.
16-12
Chapter 16
16-13
Chapter
17
Wiring Techniques
You use the Wiring tool to connect terminals. The cursor point or hot
spot of the tool is the tip of the unwound wire segment, as shown in the
following illustration.
The symbol to the left represents the mouse. In the wiring illustrations
in this chapter, the arrow at the end of this mouse symbol shows what
area to click on, and the number printed on the mouse button indicates
how many times to click on it.
To wire from one terminal to another, click the Wiring tool on the first
terminal, move the tool to the second terminal, and then click on the
second terminal as shown in the preceding illustration. It does not
matter which terminal you click on first. The terminal area blinks when
the hot spot of the Wiring tool is correctly positioned on the terminal.
Clicking on that terminal connects a wire to it. When you have made the
first connection, the spool icon draws a wire as you move the cursor
17-1
Chapter 17
across the diagram, as if the wire were unwinding from a spool. You do
not need to hold down the mouse button.
To wire from an existing wire, perform the operation just described,
starting or ending the operation on the existing wire. The wire blinks
when the Wiring tool is correctly positioned to fasten a new wire to the
existing wire.
You can wire directly from a terminal outside a structure to a terminal
within the structure using the basic wiring operation. G creates a tunnel
where the wire crosses the structure boundary, as shown in the
following illustration.
17-2
Chapter 17
terminals, regardless of the exact position of the hot spot when you click
the mouse button on it as shown in the following illustration.
You can bend your wire s at a ninety degree angle once without clicking
on it. You click on the mouse to tack the wire and change direction, as
shown in the following illustration.
Note:
You also can change between horizontal and vertical directions by pressing
the spacebar. You can untack the last tack point by pressing
<Ctrl-click> (Windows); (<option-click> (Macintosh);
<meta-click> (Sun); <Alt-click> (HP-UX). If the last tack point is
the terminal or wire on which you first clicked, untacking removes the wire
completely.
17-3
Chapter 17
You can double-click with the Wiring tool to begin or terminate a wire
in an open area as shown following.
When wires cross, a small gap appears in the first wire drawn, as if it
were underneath the second wire, as shown here.
17-4
Chapter 17
You also might want to take advantage of the Help window feature that
highlights each connector pane terminal. With this feature, you can see
exactly where wires need to connect. The three connections of the Add
function are shown as a simple example in the following illustration.
Block Diagram
Note:
Help Window
The feature just illustrated does not work for expanding functions, like the
Array Bundle function for example.
Wire Stretching
You can move wired objects individually or in groups by dragging the
selected objects to the new location using the Positioning tool. The
17-5
Chapter 17
If you duplicate the selected objects or move them from one diagram
into anotherfor example, from the block diagram into a structure
subdiagramthe connecting wires remain behind, unless you select
them as well.
Note:
17-6
Chapter 17
segment
segment
junction
bend
One click
selects a segment.
Two clicks
select a branch.
17-7
Chapter 17
17-8
Chapter 17
17-9
Chapter 17
To select the parts of a wire inside and outside a loop structure at the
same time, select the part of the wire on one side of the structure and
hold down the <Shift> key while you select the part of the wire on the
other side of the structure. You can add an object to a group of
previously selected objects by holding down the <Shift> key while
you select the new object. Also, you can drag a selection rectangle
around both parts of the wire. The structure is not selected unless you
completely surround it with a selection rectangle. Other nodes need
only to touch the rectangle to be selected.
Wiring Off-Screen
If a block diagram is too large to fit on the screen, you can use the
scrollbars to move to an off-screen area and drag the objects you need
there.
17-10
Chapter 17
You can scroll the diagram automatically while you are wiring by
dragging the Wiring tool slightly past the edge of the block diagram
window.
For more information, see the Debugging Broken VIs and Debugging
Executable VIs sections in Chapter 4, Executing and Debugging VIs
and SubVIs.
17-11
Chapter 17
The following figure shows a list of some possible wire errors. They
cannot all occur simultaneously for a single wire.
A file refnum conflict results when you wire refnums for two datalog
files of different record types.
The dimension conflict and element conflict errors occur in similar
situationswhen you wire two arrays together whose elements match
but whose dimensions do not, and when you wire two clusters whose
elements have type differences, respectively. The unit conflict occurs
when you wire together two objects that do not have commensurable
units.
These problems typically arise when you inadvertently connect a wire
to the wrong terminal of a function or subVI. Select and remove the
wire and rewire to the correct terminal. You can use the Help window
to avoid this type of error. In other situations, you might have to change
the type of one of the terminals.
17-12
Chapter 17
No Wire Source
Two examples of wires with no sources are shown in the following
illustration. In one case, a tunnel supplies data to the Reciprocal
function, but nothing supplies data to the tunnel. In the other case, two
function inputs are wired together, but there is no data source for them.
The solution to the problems is to wire a data source to the tunnel and
to the Add and Increment functions, respectively. You also see this
error if you wire together two front panel indicator terminals when one
should be a control. In this case, pop up on one terminal and select the
Change To Control command.
17-13
Chapter 17
Loose Ends
Loose ends, shown in the illustration that follows, are wire branches that
do not connect to a terminal. These can result from wire stretching, from
retracing during the wiring process, or from deleting wired objects.
Selecting EditRemove Bad Wires disposes of loose ends.
Wire Stubs
When you wire to a terminal, you seldom click on the terminal when the
cursor is exactly at its center. When you are off-center, a wire segment
automatically attaches itself from the click point to the terminal center.
If you then remove the wire going to the terminal, a wire stub can
remain, causing a Broken Run button. This problem is shown in the
following illustration.
click point
added segments
terminal center
17-14
Chapter 17
Wire Cycles
Wires must not form cycles. That is, wires must not form closed loops
of icons or structures as shown in the following illustration. The
execution system cannot execute cycles because each node waits on the
other to supply it data before it executes.
Remember, when you are unsure of what connects to a wire, you can
double-click on the wire to select the branch or triple-click to select the
entire wire.
Looping Wires
A loop of wire is not an error but is a poor design because it
unnecessarily clutters the diagram. Double-click on one of the branches
to select it, then delete it. A wire loop is shown in the following
illustration.
17-15
Chapter 17
You can create hidden wire segments inadvertently, such as when you
move a tunnel or enlarge a structure, as shown in parts 1 and 2 of the
preceding example. Parts 3 and 4 of this example show one way you can
make this diagram less confusing. You can drag the wire segment
connected to the constant so that the hidden wire segments reappear.
Press the <Shift>key to constrain the wire drag and reduce the
likelihood of creating loose ends.
17-16
Chapter 17
17-17
Chapter
18
Structures
This chapter describes how to use the For Loop, While Loop, Case
Structure, and Sequence Structure. These structures are in the
FunctionsStructures palette, as shown in the following illustration.
18-1
Chapter 18
Structures
For Loop
While Loop
Case Structures
Boolean
Case Structure
Multiframe Numeric
Case Structure
Single Frame
Sequence Structure
Multiframe
Sequence Structure
18-2
Chapter 18
Structures
visible at a time. You construct subdiagrams the same way that you
construct the top-level block diagram; subdiagrams can contain block
diagram terminals, nodes (including other structures), and wires.
You create terminals for passing data into and out of a structure
automatically where wires connecting outside nodes and inside nodes
cross the structure boundary. These boundary terminals are called
tunnels. Tunnels always have one edge exposed to the inside of the
structure and one edge exposed to the outside. A tunnel always resides
on the border of the structure, but you can move it anywhere along that
border by dragging it with the Positioning tool. You can think of tunnels
as way stations for data flowing into or out of a structure. Depending
upon the type of structure, the data can be transformed by the tunnels.
Structures also have other terminals that are particular to each type of
structure. These terminals are described with the appropriate structures
in the following sections.
For Loop
count terminal
A For Loop executes its subdiagram count times, where the count
equals the value contained in the count terminal. You can set the count
explicitly by wiring a value from outside the loop to the left or top side
of the count terminal, or you can set the count implicitly with
auto-indexing (see the Auto-Indexing section in this chapter for more
information). The other edges of the count terminal are exposed to the
inside of the loop so you can access the count internally.
18-3
Chapter 18
Structures
While Loop
A While Loop executes its subdiagram until a Boolean value you wire
to the conditional terminal is FALSE. G checks the conditional terminal
value at the end of each iteration, and if the value is TRUE, another
iteration occurs, so the loop always executes at least once. The default
value of the conditional terminal is FALSE, so if it is unwired, the loop
iterates only once.
The iteration terminal behaves exactly as it does in the For Loop.
conditional terminal
iteration terminal
Both loop structures can have terminals called shift registers that you
use for passing data from the current iteration to the next iteration. See
the Shift Registers section of this chapter for more information.
18-4
Chapter 18
Structures
18-5
Chapter 18
Structures
size the structure after you have dropped it on the diagram by clicking
on any corner with the Resizing cursor and dragging.
18-6
Chapter 18
Structures
If you place the terminal of the Boolean control outside the While Loop,
as shown below, you create an infinite loop.
If the control was TRUE at the start, changing the value of the front
panel control to FALSE does not stop the execution of this loop because
the value is not propagated until the loop stops and the VI is re-run. If
you inadvertently create an infinite loop, you can stop it by aborting the
VI. Click on the abort button to stop execution.
Auto-Indexing
For Loop and While Loop structures can index and accumulate arrays
at their boundaries automatically. These capabilities collectively are
called auto-indexing. When you wire an array of any dimension from an
external node to an input tunnel on the loop border and enable
auto-indexing on the input tunnel, components of that array enter the
loop one at a time, starting with the first component. The loop indexes
scalar elements from one-dimensional arrays, one-dimensional arrays
from two-dimensional arrays, and so on. The opposite action occurs at
output tunnelselements accumulate sequentially into one-dimensional
arrays, one-dimensional arrays accumulate into two-dimensional
arrays, and so on.
18-7
Chapter 18
Structures
You often use For Loops to process arrays sequentially. For this reason,
array tunnels have auto-indexing enabled by default when you wire an
array into or out of a For Loop. While Loops are not commonly used for
that purpose, so they are not enabled for auto-indexing by default. To
enable or disable auto-indexing on a tunnel on the loop border, you must
pop up on the tunnel at the loop border and choose Enable Indexing or
Disable Indexing.
18-8
Chapter 18
Structures
Auto-indexing with a While Loop that iterates too many times can cause
you to run out of memory. If you are a LabVIEW user, see Chapter 4,
Arrays, Clusters, and Graphs, of the LabVIEW Tutorial Manual for further
information about building arrays with While Loops to prevent this
problem.
The output from an initialized shift register is the initial value. See
the Shift Registers section of this chapter for more information.
The loop count is set to zero or defaults to zero in two ways. You can
auto-index an empty input array, or you can wire a zero or a negative
number to the count terminal explicitly. You must wire to the count
terminal unless you auto-index an input array.
When you auto-index input arrays or set the loop count with a variable,
analyze the diagram to determine whether a zero count can occur, and
if so, what the effects would be.
18-9
Chapter 18
Structures
Shift Registers
Shift registers, which are available in For Loops and While Loops, are
local variables that feed back or transfer values from the completion of
one iteration to the beginning of the next. By selecting Add Shift
Register from the loop border pop-up menu, you can create a register
anywhere along the vertical boundary, as shown in the following
illustration. This menu item is not available from the top or bottom edge
of the structure. You can reposition a shift register along the vertical
boundary by dragging it.
18-10
Chapter 18
Structures
Resizing cursor
18-11
Chapter 18
Structures
The left, topmost terminal holds the value from the previous iteration,
i 1. The terminal immediately under the uppermost terminal contains
the value from iteration i 2, and so on, with each successive terminal.
If you initialize one left terminal of a shift register, you must initialize
all of them.
The following pseudocode shows a three-value running average routine
equivalent to the G block diagram.
a = b = 0
for i = 0 to N 1
avg = (x[i] + a + b)/3
b = a
a = x[i]
18-12
Chapter 18
Structures
Boolean
Case Structure
Multiframe Numeric
Case Structure
Case Structures
Single frame
Sequence Structure
Multiframe
Sequence Structure
Sequence Structures
18-13
Chapter 18
Structures
Case Structures
selector
The Case Structure has one or more subdiagrams, or cases, exactly one
of which executes when the structure executes. This depends on the
value of the Boolean or numeric scalar you wire to the external side of
the selection terminal or selector. If a Boolean is wired to the selector,
the structure must have two cases, True and False. If a numeric is wired
to the selector, the structure can have from 0 to 215 1 cases. If you wire
an enumeration to the selector, there must be one subdiagram for each
enumeration item. The case identifiers are the same as the enumeration
item names. If the structure does not have the appropriate number of
cases, the VI in which it appears is broken.
To add more cases, follow the procedure outlined in the Adding
Subdiagrams section of this chapter. (If you wire a floating-point
number to the selector, G rounds it to the nearest integer value. G
coerces negative numbers to zero and values higher than the
highest-numbered case to the last case.)
Note:
18-14
Chapter 18
Structures
Incorrect
Correct
Adding, moving, and deleting Case subdiagrams are discussed after the
following section on the Sequence Structure, because these operations
are similar for both structures.
18-15
Chapter 18
Structures
Sequence Structures
The Sequence Structure, which looks like a frame of film, consists of
one or more subdiagrams, or frames, that execute sequentially. For an
example of a VI that uses a Sequence Structure, see
general\structs.llb\TimingTemplate.vi.
Determining the execution order of a program by arranging its elements
in sequence is called control flow. BASIC, C, and most other
programming languages have inherent control flow, because statements
execute in the order in which they appear in the program. The Sequence
Structure is a way of obtaining control flow when data dependencies are
not sufficient. A Sequence Structure executes frame 0, followed by
frame 1, then frame 2, until the last frame executes. Only when the last
frame completes does data leave the structure.
Within each frame, as in the rest of the block diagram, data dependency
determines the execution order of nodes.
You use the Sequence Structure to control the order of execution of
nodes that are not data dependent. A node that receives its data directly
or indirectly from another node has a data dependency on the other node
and always executes after the other node completes. You do not need to
use the Sequence Structure when data dependency exists or when the
execution order is unimportant.
This situation occurs often when you want to determine how long a
function takes. The Tick Count VI returns the start and end time in
milliseconds. The time is not needed to perform the function, so there
is no data dependency between time measurement and the function. As
shown in the following illustration, the Tick Count VI to the left of the
sequence structure executes before the sequence structure. Then the
function executes in frame 0 and the time elapsed calculation is done in
frame 1. The sequence structure enforces the proper execution order.
18-16
Chapter 18
Structures
Output tunnels of Sequence Structures can have only one data source,
unlike Case Structures. The output can emit from 4any frame, but keep
in mind that data leaves the structure only when it completes execution
entirely, not when the individual frames finish. Data at input tunnels is
available to all frames, as with Case Structures.
To pass data from one frame to any subsequent frame, use a terminal
called a sequence local. To obtain a sequence local, choose Add
Sequence Local from the structure border pop-up menu. This option is
not available if you pop up on a sequence local or over the subdiagram
display window. You can drag the terminal to any unoccupied location
on the border. Use the Remove command from the sequence local
pop-up menu to remove a terminal.
An outward-pointing arrow appears in the sequence local terminal of
the frame containing the data source. The terminal in subsequent frames
contains an inward-pointing arrow, indicating that the terminal is a
source for that frame. In frames before the source frame, you cannot use
18-17
Chapter 18
Structures
Sequence local
cannot be used.
Sequence local
is sink of data.
Sequence local is
source of data.
Cannot wire an
input value to a
sequence local
that is a source.
18-18
Chapter 18
Structures
Adding Subdiagrams
You can add subdiagrams several ways.
If you select the Add Case After command from the structure border
pop-up menu, as shown in the illustration that follows, G inserts an
empty subdiagram after the currently visible one. For example, an
empty subdiagram at position 3 is created from subdiagram 2 using Add
Case After. A complementary command, Add Case Before, appears in
the same pop-up menu. These commands also appear in the diagram
identifier pop-up menu.
18-19
Chapter 18
Structures
If you select Duplicate Case from either the structure border pop-up
menu or the diagram identifier pop-up menu, as shown below, a copy of
the visible subdiagram is inserted after itself.
Deleting Subdiagrams
To delete the visible subdiagram, choose Remove Case from the
structure border pop-up menu, shown below. The values of higher
numbered subdiagrams adjust automatically. This command is not
available if only one subdiagram exists.
18-20
Chapter 18
Structures
Reordering Subdiagrams
To move a subdiagram to another location, select Make This Case from
the structure border pop-up menu, as shown below, and choose a new
value from the hierarchical menu that appears. The editor automatically
adjusts the diagram identifiers of other subdiagrams.
18-21
Chapter 18
Structures
18-22
Chapter 18
Structures
Overlapping Tunnels
Because G creates tunnels as you wire, tunnels sometimes overlap.
Overlapping tunnels do not affect the execution of the diagram, but they
can make editing difficult. Avoid creating overlapping tunnels. If they
occur, drag one tunnel away to expose the other. Look at the following
example.
18-23
Chapter 18
Structures
18-24
Chapter 18
Structures
When the Wiring tool crosses the left border of the structure, a
highlighted tunnel appears to indicate that the editor will create a tunnel
at that location as soon as you click on the mouse button. If you
continue to drag the tool through the structure without clicking on the
mouse until the tool touches the right border of the structure, a second
highlighted tunnel appears on the right border. If you continue to drag
the Wiring tool past the right border of the structure without clicking on
it, both tunnels disappear, and the wire passes underneath the structure
rather than through it.
18-25
Chapter 18
Structures
If you tack down the wire inside the structure, however, the wire goes
through the structure even if you continue dragging the Wiring tool past
the right border.
18-26
Chapter
19
Formula Nodes
19-1
Chapter 19
Formula Nodes
19-2
Chapter 19
Formula Nodes
19-3
Chapter 19
Formula Nodes
19-4
Chapter 19
Formula Nodes
Function
Corresponding G
Function Name
Description
abs(x)
Absolute Value
acos(x)
Inverse Cosine
acosh(x)
Inverse Hyperbolic
Cosine
asin(x)
Inverse Sine
asinh(x)
Inverse Hyperbolic
Sine
atan(x)
Inverse Tangent
atanh(x)
Inverse Hyperbolic
Tangent
19-5
Chapter 19
Formula Nodes
Table 19-1.
Function
Corresponding G
Function Name
Description
ceil(x)
Round to +Infinity
cos(x)
Cosine
cosh(x)
Hyperbolic Cosine
cot(x)
Cotangent
csc(x)
Cosecant
exp(x)
Exponential
expm1(x)
Exponential (Arg) 1
floor(x)
Round to Infinity
getexp(x)
getman(x)
int(x)
Round To Nearest
integer
intrz(x)
Round Toward 0
ln(x)
Natural Logarithm
19-6
Chapter 19
Table 19-1.
Function
Formula Nodes
Corresponding G
Function Name
Description
lnp1(x)
Natural Logarithm
(Arg + 1)
log(x)
Logarithm Base 10
log2(x)
Logarithm Base 2
max(x,y)
min(x,y)
mod(x,y)
rand( )
Random Number
(01)
rem(x,y)
Remainder
sec(x)
Secant
sign(x)
Sign
sin(x)
Sine
sinc(x)
Sinc
sinh(x)
Hyperbolic Sine
19-7
Chapter 19
Formula Nodes
Table 19-1.
Function
Corresponding G
Function Name
Description
sqrt(x)
Square Root
tan(x)
Tangent
tanh(x)
Hyperbolic Tangent
x^y
xy
19-8
Chapter 19
Formula Nodes
assignment
? :
conditional
||
logical or
&&
logical and
!= ==
inequality, equality
+ -
addition, subtraction
* /
multiplication, division
+ - !
exponentiation
Error Message
syntax error
bad token
Unrecognized character.
19-9
Chapter 19
Formula Nodes
Table 19-2.
Error Message
missing variable
missing colon
missing semicolon
19-10
Chapter
20
Attribute Nodes
This chapter describes how to use Attribute Nodes to set and read
attributes of front panel controls programmatically. Some useful
attributes include display colors, control visibility, menu strings for a
ring control, graph or chart plot colors, and graph cursors.
20-1
Chapter 20
Attribute Nodes
Selecting this option creates a new node on the diagram located near the
terminal for the control, as shown in the following illustration. If the
control has a label associated with it, the label for the control is used for
the initial label of the Attribute Node. You can change the label after
the node has been created.
If you pop up on an attribute terminal, and then choose Select Item, you
see a menu of attributes that you can set for or read from the control, as
shown in the following illustration. You can use a shortcut to the list of
attributes by clicking on the Attribute Node with the Operating tool.
20-2
Chapter 20
Attribute Nodes
You can set an attribute when the small direction arrow is located on the
left side of the terminal. You can read an attribute when the arrow is
located on the right side of the terminal.
direction arrow
You can read or set more than one attribute with the same node by
enlarging the Attribute Node. New terminals are added as the node
enlarges.
20-3
Chapter 20
Attribute Nodes
You can create more than one Attribute Node by cloning an existing
node, or by selecting the CreateAttribute Node option again. To clone
an existing node, click on that node and drag it with the Positioning tool
while holding down the <Ctrl> (Windows); <option> (Macintosh);
<meta> (Sun); or <Alt> (HP-UX) key. However, you cannot copy and
paste an Attribute Node using the Edit menu commands. Each node can
have both read and write attribute terminals.
20-4
Chapter 20
Attribute Nodes
The attributes for a cluster and for a numeric control inside the cluster
are shown in the following illustration.
Some controls, such as the graph, have a large number of attributes you
can read or set. Some of these attributes are grouped into categories and
listed in submenus, such as the Format & Precision category for a
numeric control. You can choose to set all of the attributes at once by
selecting the All Elements option of the submenu. You also can set one
or more of the elements individually by selecting the specific
20-5
Chapter 20
Attribute Nodes
After you create an Attribute Node, the Find Control and Find
Terminal options of the terminal and control pop-up menus change to
submenus that help you find Attribute Nodes. In the same way, the
Attribute Node has options to find the control and the terminal it is
associated with.
See general\attribute.llb for an example of how to use an
Attribute Node.
20-6
Chapter 20
Attribute Nodes
Base Attributes
There are many attributes available for modifying the various front
panel objects in your application. This section discusses Visible,
Disable, Key Focus, Blinking, Position, and Bounds attributes, which
are common to nearly all front panel objects.
Visible Attribute
You can set or read the visibility of a front panel object with the Visible
Attribute. The associated object is visible when TRUE, hidden when
FALSE.
In the following illustration, the digital control is set to an invisible
state. A Boolean TRUE value makes the control visible again, as shown.
Block Diagram
Front Panel
Visible = TRUE
Visible = FALSE
Disabled Attribute
You can control whether a user has access to an object, by
implementing the Disabled Attribute. A value of zero enables an object
so that the user can operate it. A value of one disables the object,
preventing operation. A value of two disables and grays out the object.
You can disable user access to a digital control. The control does not
change appearance when disabled in the first example. In the second
20-7
Chapter 20
Attribute Nodes
example, the user access to the digital control is disabled and is grayed
out.
Blinking Attribute
By using the Blinking Attribute, you can read or set the blink status of
an object. If you set this attribute to TRUE, a front panel object blinks.
The blink rate and colors are set in the Preferences dialog box. When
you set this attribute to FALSE, the object stops blinking.
G Programming Reference Manual
20-8
Chapter 20
Attribute Nodes
Position Attribute
You can set or read the position of the upper left corner of an object on
the front panel with the Position Attribute. The position is determined
in units of pixels relative to the origin of the Panel window, which is
initially the top left corner of the window but may be somewhere else if
you have scrolled the window. This attribute consists of a cluster of two
unsigned long integers. The first item in the cluster (Left) is the location
of the left edge of the control relative to the origin of the Panel window,
and the second item in the cluster (Top) is the location of the top edge
of the control relative to the top edge of the Panel window.
By activating the Position Attribute Node, the digital control changes
its location on the front panel in the following illustration.
20-9
Chapter 20
Attribute Nodes
20-10
Chapter 20
Attribute Nodes
number plot changes color when the values go above a limit set by the
user. Notice that the active plot is specified before the plot color is
changed.
20-11
Chapter 20
Attribute Nodes
You can set the display strings for the Switch controls to the string
choices Stop, Run, and Stop? and Run? The following illustration
shows how to set the display strings.
Block Diagram
Front Panel
The block diagram shown in the illustration that follows reads a list of
valid tests from a file and passes the list, represented as an array of
strings, to an Attribute Node for the ring control. The diagram then
20-12
Chapter 20
Attribute Nodes
loops, waiting for the user to click on the Execute Test button. This
gives the user a chance to select a test from the ring control, or to fill in
information for other controls. When the user selects a test, the string
corresponding to the numeric value of the ring control is read and then
passed to a VI that executes the test.
20-13
Chapter 20
Attribute Nodes
The False Case is executed when double-click is 1 and the True Case
is executed when the user has double-clicked on a test number in the
listbox.
One option is to use pop-up subVIs. You can create subVIs that
have the options you want to present to the user. By using the Show
Front Panel when Called and Close Afterwards if Originally
Closed options of VI SetupExecution Options when you create
your subVI, you can have one of these subVIs open when called.
2.
3.
20-14
Chapter 20
Attribute Nodes
Working through a While Loop, the VI first activates the Min Value
cursor, and reads its numerical value. Next, the VI activates and reads
the Max Value Cursor. Then the VI calculates and displays information
about the cursor selection on the front panel. When you press the
Confirm button, the VI exits the loop and confirms the cursor positions.
See the examples in general\graphs\zoom.llb for an application
of programmatically reading graph cursors.
20-15
Chapter
21
This chapter describes how to define and use global and local variables.
You can use global variables to access a particular set of values easily.
Local variables serve a similar purpose within a single VI.
Global and local variables are advanced G concepts. Be sure to study
this chapter carefully before using them.
For examples of how to use global and local variables, see
general\globals.llb and general\locals.llb.
Global Variables
A global variable is a built-in G object. You define a global variable by
creating a special kind of VI, with front panel controls that define the
data type of the global variable.
There are two ways to create multiple global variables. You can create
several VIs, each with one item, or you can create one multiple global
VI by defining multiple data types on the one global variable front
panel. The multiple global VI approach is more efficient, because you
can group related variables together.
You can create a global variable by selecting the global variable from
the FunctionsStructures palette.
global node
21-1
Chapter 21
Double-click on the node to open a front panel. You use this panel to
define the data type for one or more global variables.
Note:
Assign a name to each control, because you must refer to a specific global
variable by name. After you have defined the data types for the global
variables, save the global VI.
The following illustration is an example front panel describing three
global typesa number, a string, and a cluster containing two values.
After you place a global variable on a block diagram and define a front
panel for it, the node is associated with the front panel. Because a global
variable can define multiple globals, you must select which global you
want to access from a particular node. Select a global variable by
popping up on the node and selecting the item by name from the Select
Item menu as shown in the following illustration. Or, you can click on
the node with the Operating tool and select the item you want.
21-2
Chapter 21
You either can write to a global variable or read from a global variable.
Writing to a global variable means the value of the global is changed;
reading from a global means the global is accessed as a data source. If
you want to write to or read from a global, select the Change to Write
Global or the Change to Read Global option of the global variable
pop-up menu.
After you define a global variable, you can place it in other VIs using
FunctionsSelect a VI. If you select a global variable from the file
dialog box, G places the global variable node on the diagram. You also
can clone, copy and paste, or drag-copy a global from the Hierarchy
window.
Local Variables
With a local variable you can write or read one of the controls or
indicators on the front panel of your VI. Writing to a local variable has
the same result as passing data to a terminal, except that you can write
to it even though it is a control, or read from it even though it is an
indicator. Also, you can have any number of local variable references
21-3
Chapter 21
to a particular front panel control, with some in write mode, and others
in read mode.
In effect, with a local variable reference you can use a front panel
control as both an input and an output.
Note:
You must make sure that the label you choose for your local variable is
associated with a front panel object. If your local variable is not associated
with a front panel object, it will not work.
local variable
icon
The easiest way to create a local variable is to pop up on the front panel
control or terminal and select CreateLocal. A local is created
automatically on the block diagram. Another way to create a local is to
select the local variable from FunctionsStructures, shown below.
local variable
node
If there are no controls on the front panel of your VI, a node that looks
similar to a global variable appears. If you already have placed controls
on the front panel, the local variable node appears with the name of one
of your controls showing.
You can pop up on the node, or click on it with the Operating tool to
select the control you want to read or set from a list of the top-level front
panel controls, as shown in the following illustration. You also can
determine whether you want to write to or read from the control by
selecting either the Change to Write Local or the Change to Read
Local options.
21-4
Chapter 21
21-5
Chapter
22
Custom Controls
Using the Control Editor
Make certain that you are in edit mode to customize a control. On the
front panel, place a control that is most like the one you want to create.
For example, to create a slide with its scale on the right, start by placing
any vertical slide on the front panel.
With the Positioning tool, select the slide control and then choose
EditEdit Control. This option is available only when you have
22-1
Chapter 22
selected a control. You can edit only one control at a time from a front
panel.
The Control Editor window looks like a front panel, but it is used only
for editing and saving a single control; it has no block diagram and
cannot run.
edit
mode
customize
mode
A Control Editor has an edit mode and a customize mode; the current
mode is indicated by a button in the toolbar, as shown to the left of this
text. A Control Editor is in edit mode when it first opens. In edit mode
you can change the size or color of a control, and select options from its
pop-up menu just as you do in edit mode of any front panel. In
customize mode you can change the parts of a control individually.
Customize mode is described in detail later in this chapter.
22-2
Chapter 22
After you have edited a control, you can use it in place of the original
control on the front panel that you were building when you opened the
Control Editor. You also can save it to use on other front panels.
The file dialog box appears, asking you to name and select a location
for your custom control. If your original front panel is the only place
you use the custom control, you can close the Control Editor window
without saving the control. Be sure to save the original VI with the
custom control in place to preserve your work. If you want to use the
custom control on other front panels in the future, you must save it as
described in the Saving Custom Controls section of this chapter.
The Apply Changes option is only available after you make changes to
the control. Apply Changes is disabled if there is no original control to
update. This happens when you delete or replace the original control,
when you close the original front panel, or when you have opened a
custom control that you saved earlier by selecting FileOpen.
not-OK button
If the Control Editor has more than one control in it, the not-OK button
appears. A valid custom control must be a single control, though it can
be a cluster of other controls. The not-OK button appears temporarily
while you move controls in and out of a cluster or array. To see an
22-3
Chapter 22
explanation for the error, click on the not-OK button. If there is more
than one control in the Control Editor the error message reads:
There are extra objects on the front panel that do not
belong to the custom control.
If you try to put a type definition control on the front panel of the
Control Editor, the error message reads:
You cannot use a Type Definition in the control editor
unless it is inside another control, such as a cluster
or array.
See the Type Definitions section later in this chapter for more
information.
22-4
Chapter 22
Making Icons
control icon
If you save your controls so that they appear in the Controls palette,
you should make an icon representing the control before you save it.
Pop up or double-click on the icon square in the top right corner of the
Control Editor window to create an icon for the control. This icon
represents the control in the palette when you save the control in a
library directory.
22-5
Chapter 22
Mode from the Operate menu while the Control Editor is the active
window, as shown in the following illustrations.
Independent Parts
All G controls are built from smaller parts. For example, a slide control
consists of a scale, a housing, a slider, the increment and decrement
arrows, a digital display, and a name label. The parts of a slide are
pictured in the following illustration.
22-6
Chapter 22
increment arrow
name label
digital display
scale
slider
housing
unit label
decrement arrow
A Slide Control
When you switch to customize mode in the Control Editor, the parts of
your control become independent. You can make changes to each part
without affecting any other part. For example, when you click and drag
on the scale of the slide with the Positioning tool, only the scale moves.
You can select parts and align or distribute them using the Alignment
or Distribution rings from the toolbar; or change their layering order by
selecting Move Forward or Move Backward from the Edit menu.
Customize mode shows all parts of the control, including any that were
hidden in edit mode, such as a name label or the radix on a digital
control.
Because the parts of a control are detached from each other, you cannot
operate or change the value of the control while in customize mode.
Notice that the Operating tool is disabled. The Wiring tool is always
disabled in a Control Editor because you are not using the block
diagram when you are in Customize mode.
22-7
Chapter 22
Current Part display in the Parts window displays a picture and the
name of the part currently selected in your Control Editor window. You
can see a menu of all the parts by clicking on the current part display.
You also can scroll through the parts of the control by clicking on the
current part display increment or decrement arrow. When you change
the part shown in the current part display, that part is selected on the
control in the Control Editor window. When you select, change, or pop
up on another part of the control in the Control Editor window, the part
showing in the current part display also changes.
The illustration that follows shows the Control Editor window on the
left overlaid by the Control Parts window on the right. The name label
of the slide is the current part, and is selected in the Control Editor
window. The Control Parts window shows the menu of parts that you
see when you click on the current part display. This example shows that
the name label is the current part, but that you are about to change to the
scale part.
The Control Parts window shows you the exact position and size of the
current part. These values are pixel values. When you move or resize a
part in the Control Editor, the position and size in the Parts window are
updated. You also can enter the position and size values directly in the
Control Parts window to move or resize the part in the Control Editor.
This is useful when you need to make two parts exactly the same size,
or align one part with another. In the preceding illustration, the Parts
G Programming Reference Manual
22-8
Chapter 22
window displays the position and size of name label of the slidethe
upper left corner of the label is at the pixel coordinates (74, 84), and the
label is 20 pixels high by 45 pixels wide.
The Control Parts window disappears if you switch to some other
window. The Control Parts window reappears when you return to the
Control Editor.
Cosmetic parts, such as the slide housing, slider, and the increment
and decrement arrows, are the most common. Cosmetic parts
display a picture.
Text parts, such as the name label of the slide. Text parts consist of
a picture for the background (usually just a rectangle) and some
text.
The following sections describe the different parts and their pop-up
options in more detail.
Cosmetic Parts
A cosmetic part is a par that has no dynamic user interaction or
indication. The following illustration shows a pop-up menu for a
cosmetic part, such as a slide housing. To pop up on a cosmetic part, you
22-9
Chapter 22
must be in customize mode. You must pop up on the part itself, not on
the picture of the part in the Control Parts window.
The following list describes the options available from the pop-up
menu.
22-10
Chapter 22
22-11
Chapter 22
A cosmetic part with more than one picture has the Picture Item option
on its pop-up menu, as shown in the following illustration.
Picture Item displays all the pictures belonging to a cosmetic part. The
picture item that is currently displayed has a dark border around it.
When you import a picture, you change only the current picture item.
To import a picture for one of the other picture items, first select that
picture item and then import the new picture.
22-12
Chapter 22
A Boolean switch also has more than one picture. Each picture can be a
different size and have different colors. A Boolean switch has four
different picturesthe first shows the false state; the second shows the
true state. You use the third and fourth pictures when you set the
mechanical action of a Boolean control to either Switch When Released
or Latch When Released.
Until you release the mouse button, the value of the Boolean does not
change with these two mechanical actions. Between the time you click
on the button and the time you release the click, the Boolean shows the
third or fourth picture as an intermediate state. The third picture is for
the true to false transition state, and the fourth is for the false to true
state. In the following illustration of a toggle switch, the third and
fourth pictures are the same, but this is not always the case.
1: False
2: True
22-13
3: T
4: F
Chapter 22
When a cosmetic part can have different sized pictures, the part has the
Independent Sizes option on its pop-up menu, as shown in the
following illustration.
Independent Sizes is an option you can turn on only when you are in
customize mode if you want to move and resize each picture
individually without changing the other pictures of the cosmetic part.
Normally, this option is not checked; and, when you move or resize the
current picture of the cosmetic part, its other pictures also move the
same amount or change size proportionally.
Text Parts
A text part is a picture with some text. The pop-up menu for a text part,
such as a name label, has some items identical to those on the pop-up
menu of a cosmetic part. The other items on this menu are the same as
the text pop-up menu in front panel edit mode. An example pop-up
menu for a text part is shown in the following illustration.
22-14
Chapter 22
Only the background picture for the text part is shown in the Parts
window, not the text itself. The background picture can be customized,
not the text.
Scale Parts
A scale is a special kind of text part with markers for the text. A picture
of the scale is the background for each of its markers. This background
is usually a transparent rectangle and therefore not visible, but you can
see it if you color one of the scale markers. A scale has the same options
on its pop-up menu as a text part, along with other options relating only
to scales. This menu is shown in the following illustration.
Reverse Ticks changes the tick marks on a vertical scale from the right
side to the left, or from left to right. On a horizontal scale, it changes
the tick marks from the top to the bottom, or from bottom to top. On a
rotary scale, such as the scale on a knob, dial, gauge or meter, it changes
the tick marks from the outside to the inside, or from the inside to the
outside. Reverse Ticks does not move the scale.
You can position the scale by dragging it when you are in customize
mode. Hold the <Shift> key down when dragging the scale of the
slide to restrict the movement to one direction only.
Controls as Parts
A control can include other controls as parts. A common example of this
is the digital display on a slide, knob, meter, or chart. There is no
difference between the digital display and the ordinary, front panel
22-15
Chapter 22
22-16
Chapter 22
22-17
Chapter 22
When you use a custom control on other front panels, you can change
the size of any decoration parts that you added, but you cannot move
them.
You cannot change the way a control behaves when you edit it,
especially when you resize it.
For example, when you make a ring control taller, the
increment and decrement arrows also increase in height. If you
move the increment and decrement arrows so they are side by
side at the bottom of the ring, the ring continues to make them
become taller when it increases, and you produce some strange
results.
22-18
Chapter 22
Type Definitions
A type definition is a master copy of a control. You use the Control
Editor to create the master copy, or type definition. Type definitions are
useful when you use the same kind of control in many VIs. You can save
the control as a type definition, and use that type definition in all your
VIs. Then, if you need to change that control, you can update the single
type definition file instead of updating the control in every VI that
uses it.
22-19
Chapter 22
The only aspects of a control that can be different from the master copy
of a strict type definition is the name, description, and default value. As
an example, suppose you make a strict type definition that is a
double-precision digital control with a red frame. Like the general type
definition, if you change the strict type definition to an integer, you
automatically update every VI that uses it, or you can check to make
sure if they need to be updated. Unlike the general type definition,
however, other changes to the strict type definition, such as changing
the red frame color to blue, also requires VIs using the strict type
definition to be updated.
Note:
Many Attribute Nodes are not available for strict type definitions. However,
the attributes that are available for strict type definitions are those that
affect the appearance of the control, such as Visible, Disabled, Key Focus,
Position and Bounds.
You can open any type definition you have saved by selecting
FileOpen. A type definition always opens in a Control Editor window.
Any changes you make to a type definition affect all VIs that are using
it.
You cannot edit a strict type definition on your front panel except to change
its name, description, or default value.
22-20
Chapter 22
You can tell that a control is a type definition when you see the type
definition options in its pop-up menu, as shown in the following
illustration. You can recognize a strict type definition on your front
panel because you cannot edit it, and most of its pop-up menu options
are missing.
For each type definition that you use on a front panel, the VI keeps a
connection to the file or VI library in which it is saved. You can see this
connection in action if you place a type definition on a front panel and
then select it and choose EditEdit Control. The Control Editor that
opens is the type definition you saved, with the name you gave it,
instead of the generic Control N.
22-21
Chapter 22
22-22
Chapter
23
within your VIs. You can use the simple System Exec VI from the
FunctionsCommunication palette to execute a command line from
your VI. The command line can include any parameters supported by
the application you plan to launch.
If you can access the application through TCP/IP (or DDE in Windows),
you might be able to pass data or commands to the application. See the
reference material for the application you plan to use to see the extent
of its communication capability. If you are a LabVIEW user, you also
can refer to Chapter 1, Communication Applications in LabVIEW, of the
LabVIEW Communications VI Reference Manual, for more information
on techniques for using networking VIs to transfer information to other
applications.
(Macintosh) You use Apple Event VIs to execute other applications from
within your VIs. Apple Events are a Macintosh-specific protocol
through which applications can communicate with each other. They can
be used to send commands between applications. You also can use them
to launch other applications. If you are a LabVIEW user, see Chapter 1,
Communication Applications, of the LabVIEW Communications VI
23-1
Chapter 23
Reference Manual for details of different methods for using Apple Event
VIs in G to launch and control other applications.
23-2
Chapter 23
If you are a LabVIEW user, you can refer to the LabVIEW Code
Interface Reference Manual for information on how to create Code
Interface Nodes.
23-3
Chapter 23
Note:
23-4
Chapter 23
Parameter Lists
Initially, the Call Library Function has no parameters, and has a return
value of void. You can click on the Add a Parameter Before and Add
a Parameter After buttons to add parameters to the function. You can
click on the Delete this Parameter button to remove a parameter.
You can use the parameter ring to select different parameters or the
return value. When selected, you can change the parameter name to
something more descriptive. The parameter name does not affect the
call, but it is propagated to output wires. Descriptive names make it
easier to switch between parameters.
Indicate the type of each parameter using the type ring. The return type
is limited to either Void, meaning the function does not return a value,
or Numeric, shown in the following illustration.
For parameters, you can select Numeric, String, or Array data types, as
shown in the following illustration.
When you select an option from the type ring, you see more options you
can use to indicate details about the data type and how to pass the data
to the library function. The Call Library Node has a number of different
options for data types, because of the variety of data types required by
different libraries. Refer to the documentation for the library you call to
determine which data types to use.
VoidThe type void is only accepted for the return value. This
option is not available for parameters. Use it for the return value if
your function does not return any values.
23-5
Chapter 23
Note:
ArraysYou can indicate the data type of arrays (using the same
options as for numeric data types), the number of dimensions, and
the format to use in passing the array. Use the Format option to
select if you want to pass a pointer to the array data, or pass a
pointer to a G array, which includes a four-byte value for each
dimension followed by the data. If you select Array Data Pointer,
you probably need to pass the array dimension as separate
parameter(s).
In Windows 3.1, the Call Library Node uses only the array data pointer
format for arrays. Additionally, in Windows 3.1 you can indicate that the
data should be passed using a Huge pointer. You can use a Huge pointer if
you need to pass more than 64 K. You should only turn this option on if the
DLL you are calling expects a Huge pointer of data. If you try to pass a
Huge pointer to a function that expects a normal pointer, the application
might crash.
If the library function that you are calling is written specifically for G,
you should use the G array format, because it explicitly includes the size
information. For most conventional libraries, however, use the array
data pointer, and pass the size of the array as a separate parameter(s).
23-6
Chapter 23
Caution:
StringsYou can specify the string format for strings. The options
for string format are C, Pascal, or G.
Base your selection of the string format on the type of string that
the library function expects. Most standard libraries expect either a
C string (string followed by a character) or a Pascal string (string
preceded by a length byte). If the library function that you are
calling is written specifically for G, then you might want to use the
string format, which consists of four bytes for length information,
followed by string data.
Caution:
23-7
Chapter 23
Conversion Process
If you select FileConvert CVI FP File, a dialog box appears asking
you to select a LabWindows/CVI Function Panel file. When you have
selected an FP file, you see the following dialog box, in which you can
indicate where to save new VIs and what driver functions to convert.
23-8
Chapter 23
23-9
Chapter 23
23-10
Chapter 23
23-11
Chapter 23
panel tree have unique names. Setting this option causes the
converter to construct VI names from the actual C function names
that the FP items correspond to, thereby guaranteeing unique
results.
To avoid problems caused by duplicate names, the converter checks
to see if all items are unique when it builds the list of function panel
items to be displayed. Non-unique items are flagged with a null
symbol and are not selectable by double-clicking on them. To
prevent problems caused by duplicate names, the converter brings
up a one-button alert when it first opens its dialog box if it detects
such name conflicts, and automatically turns on the Use C Function
Names option. If you prefer to use the function panel names
instead, you can turn off this option manually, and then
individually rename the items that have name conflicts. Renamed
items retain their user-supplied names even when the Use C
Function Names option is changed.
Capitalize and Remove Underscores in NamesBecause names
built from C function names tend to be less pretty than those
derived from the function panel item names, this option attempts to
make them prettier by capitalizing initial letters and replacing
underscores with spaces. Because it cannot expand abbreviations,
the results still might not be as pleasing as the FP names, but this is
inevitable if you have duplicate FP item names you do not want to
rename individually.
Convert All Control Names to LowercaseConverts control
names to lowercase to conform to VXI Plug&Play standards.
Assign Instrument Driver Icon Based on NameAssigns icons to
VIs based on the name of the generated VIs. The converter searches
for keywords such as initialize, close, self-test, reset, configure, or
measure in the name of the function and uses the corresponding
icon. If no keywords are found, a default icon is used. Additionally,
the instrument prefix is stamped into the icon at the top left, up to
a maximum of seven characters.
Default Size for Array ParametersWhen an instrument driver
DLL outputs an array, the memory into which the DLL writes the
array must be preallocated and passed into the DLL. With this
option, you can select the default size, in elements, to allocate for
arrays. When a Call Library Node function has an array as an
argument, the converter drops an Initialize Array function to create
an array to pass into the node. The initial size of such arrays is
specified by the Default Size for Array Parameters option. A
23-12
Chapter 23
warning is generated in the .out file so that you can easily find VIs
containing this construct and handle special cases individually.
Selecting OK at the main LabWindows/CVI Function Panel Converter
dialog box brings up a file dialog box so you can select the library
corresponding to the FP file being converted (if the Create Library Call
option is set). Canceling this dialog box simply leaves the library path
unspecified in the Call Library Function node; it does not abort
conversion.
After you click OK, the converter brings up a working status dialog box
to display the name of each new VI as it is created. A log file named
prefix.out is created, listing all the VIs that were created, and any
warnings or errors that occurred during conversion. If any warnings or
errors do occur, you are notified to look at this file when conversion is
complete.
23-13
Chapter
Understanding the G
Execution System
24
Multitasking
Most computers have only one processor, meaning only one task can
execute at any given time. Multitasking is achieved by running one task
for a short amount of time and then having other tasks run. As long as
the amount of time that each task has is small enough, you have the
appearance of having multiple tasks running simultaneously.
There are two kinds of multitaskingpreemptive and cooperative.
With a preemptive multitasking system, each task is given a limited
amount of time to execute. When the time is up for a given task, one task
is forced to pause while another starts execution. Preemptive
multitasking is not currently available on all operating systems and is
not used currently by the execution system.
Cooperative multitasking, which is more common in current, small
computer operating systems, relies on each task being written to share
time. Each task is responsible for deciding when it should relinquish
24-1
Chapter 24
time to other tasks. If any task fails to share time, that task ends up
locking out other tasks until it is ready to share time.
The execution system is a cooperative multitasking system, which
means it can execute multiple tasks in parallel. Because it is
cooperative, you have no assurances that a given task executes within a
specific amount of time. Some nodes in G are synchronous, meaning
they do not multitask (a complete list of these nodes is given in the
Synchronous Nodes section later in this chapter). If any synchronous
nodes execute a lengthy process, other tasks temporarily might be
locked out of execution. In practice, this rarely causes problems
because the number of synchronous nodes is relatively limited, and the
actions they execute generally take only a small amount of time.
Cooperation
When the compiler compiles a diagram into machine code, the code is
generated so that it periodically checks to see whether there are any
other pending tasks and if it is time to have other tasks execute.
The execution system maintains a queue of active tasks. Assuming all
tasks have the same priority, the first task executes for a certain amount
of time. Then, that task is put at the end of the queue, and the next task
executes for a time. When a task completes execution, the execution
system removes it from the queue.
The execution system executes the first element of the queue by calling
the generated code of the VI. At some point, the generated code of that
VI checks with the execution system to see if it should assign another
task to execute. If not, the code for the VI continues to execute.
Task Switching
The currently executing task surrenders execution to other tasks in a
number of situations described in the following list.
1.
2.
24-2
Chapter 24
3.
4.
When a VI wait completes, or the I/O finishes, the VI is put back on the
queue in order of its priority.
Synchronous Nodes
As mentioned previously, a few nodes are synchronous, meaning they
do not multitask with other nodes. Code Interface Nodes (CINs) and all
computation functions execute synchronously. Most analysis VIs
contain CINs and therefore execute synchronously. For example, an
FFT executes to completion without assigning other tasks to execute in
parallel, regardless of how long the FFT executes.
Almost all other nodes are asynchronous. Structures, I/O functions,
timing functions, and subVIs that you build all execute asynchronously.
24-3
Chapter 24
24-4
Chapter 24
Reentrant Execution
Under normal circumstances, the execution system cannot execute
multiple calls to the same subVI simultaneously. If you try to call a
non-reentrant subVI from more than one place, one call executes and
the other call waits for the first to finish before executing. If you make
a VI reentrant (using VI Setup), each instance of the call maintains its
own state of information. Then, the execution system runs the same
subVI simultaneously from multiple places. Reentrant execution is
useful in the following situations.
Execution highlighting
Single-stepping
These options are disabled because the subVI must switch between
different copies of the data and different execution states with each call,
making it impossible to display its current state continuously.
24-5
Chapter 24
The Get Time In Seconds function reads the current time in seconds and
the Seconds to Date/Time and converts this value to a cluster of time
values (year, month, day, hour, minute, second, and day of week). A
Bundle function replaces the current hour and minute with values
representing a later time on the same day in the front panel Time To
Wake Me cluster control. The adjusted record then is converted back to
seconds, and the difference between the current time in seconds and the
future time is multiplied by 1,000 to obtain milliseconds. The result
passes to a Wait function.
Lunch and Break are two VIs that use Snooze as a subVI. The Lunch
VI, whose front panel and block diagram are shown in the following
illustration, waits until noon and pops up a front panel reminding the
operator to go to lunch. The Break VI pops up a panel reminding the
operator to go on break at 10:00 a.m. The Break VI is identical to the
Lunch VI, except that the pop-up subVIs are different.
24-6
Chapter 24
If you are a BridgeVIEW user, refer to Chapter 10, Loops and Charts
of the BridgeVIEW User Manual.
Next, suppose you have a VI that uses ExpAvg to calculate the running
average of two data acquisition channels. For example, you are
monitoring the voltages at two points in a process and want to view the
exponential running average on a strip chart. The diagram contains two
ExpAvg nodes. The calls alternate, one for Channel 0, then one for
Channel 1. Assume Channel 0 executes first. If ExpAvg is not reentrant,
the call for Channel 1 uses the average computed by the call for
24-7
Chapter 24
Channel 0, and the call for Channel 0 uses the average computed by the
call for Channel 1. By making ExpAvg reentrant, each call can execute
independently without danger of sharing the data.
24-8
Chapter
25
25-1
Chapter 25
dialog box. There is no similar option for directories, but you can
emphasize your top-level VIs by placing subVIs into subdirectories.
Distributing VIs
When you are ready to distribute your VIs, consider whether you want
to distribute the VIs with or without the block diagrams. Using the Save
with Options dialog box, you can remove diagrams from your VIs. If
you save your VIs without a diagram, the VI cannot be modified by
other users. If you save your VIs without diagrams, be careful not to
overwrite your original versions.
Note:
25-2
Chapter 25
25-3
Chapter 25
hierarchy. The Save with Options dialog box is shown in the following
illustration.
By selecting from the options on the left of the Save with Options dialog
box, you can select from a set of predefined save options. As you select
options, the area at the right shows the behavior of your current
selection. You can customize the behavior by selecting specific options
from the right section of the dialog box.
25-4
Chapter 25
VI History Window
In addition to its front panel and block diagram, a VI has a History
window that displays the development history of the VI, including
revision numbers. Each user who changes a VI can record any changes
made in the history. This feature should help users keep track of
changes to a VI as they are made. However, the VI history does not
25-5
Chapter 25
As you edit the VI, you can type a description of important changes into
the Comment box near the top of the window. When you are finished
making changes, you add the comment to the history by clicking on the
Add button. If there is a comment in the Comment box when you save
the VI, it is added to the history automatically. Once you add a
comment, it is a permanent part of the history. You cannot rewrite the
history, so be sure to check your comments before adding them.
G Programming Reference Manual
25-6
Chapter 25
The box at the bottom of the window displays the history of the VI. The
dialog box shows a header for each comment in the history that includes
the revision number of the VI, the date and time, and the name of the
person who made the change. You can see that three comments have
been added to this history, and each is displayed with a header. Because
the preceding illustration is only an example, the comments are short;
you can make them as long as you want when editing your own VIs.
The History window is fairly large with the history showing, but you
can hide the history by clicking on the History arrow (the small black
triangle to the left of the word). This makes the window small enough
that it stays out of your way while you are editing the VI. When you
want to see the history again, click on the same arrow and the history
reappears. An example is shown in the following illustration.
You can also change the size of the history and comment boxes by
resizing the window.
Revision Numbers
The revision number is also a part of the history of the VI and is an easy
way to see if the VI has changed (and how it changed, if you commented
on your changes). The revision number starts at zero and is incremented
every time you save the VI. The current revision number (the one on
disk) is displayed in the Get Info dialog box. It is also displayed in the
titlebar of the VI if the option to do so is checked in the dialog box of
EditPreferencesHistory.
25-7
Chapter 25
The revision number is not incremented when you save the VI if the only
changes you made were changes to the VI History.
In many cases, there are gaps in revision numbers between comments
because you saved the VI without entering a comment. This is not a
problem. In fact, the revision number is useful because it is
independent. Suppose you receive a copy of a VI from another user.
Later, you want to know if the other user updated the VI since you
received your copy. You can easily tell by looking at the revision
numbers, even if the other user made a change without adding
comments.
If the revision number only changed when you added a comment, it
would be a comment number, not a revision number. The revision
number is even more effective when combined with the history. If users
have been adding comments to the history, you can tell what changes
were made since you last received a copy.
25-8
Chapter 25
25-9
Chapter
26
Performance Issues
This chapter is divided into three sections. The first section discusses
the Performance Profiler, a feature that shows you data about execution
time of your VIs. The second section discusses factors that affect
run-time speed. The third section discusses factors that affect memory
usage.
Performance Profiling
The VI Performance Profiler is a powerful tool for determining where
your application is spending its time, as well as how it is using memory.
This information is invaluable in finding the hot spots of your
application so that you can make the best use of the VIs that take up the
most time. It has an interactive tabular display of time and memory
usage for each VI in your system. Each row of the table contains
information for a specific VI. The time spent by each VI is broken down
into several categories as well as summarized in a few statistics. The
Profile window calculates the minimum, maximum, and average time
spent per run of a VI.
You can use the interactive tabular display to view all or parts of this
information, sort it by different categories, and look at the performance
data of subVIs when called from a specific VI.
26-1
Chapter 26
Performance Issues
There are several things to notice about the window. First, the collection
of memory usage information is optional. This is because the collection
process can add a significant amount of overhead to the running time of
your VIs. You must choose whether to collect this data before starting
the Profiler by checking the Profile Memory Usage checkbox
appropriately. This checkbox cannot be changed once a profiling
session is in progress. The following buttons are available on the Profile
window.
26-2
Chapter 26
Performance Issues
26-3
Chapter 26
Performance Issues
Timing Information
When the Timing Statistics checkbox is checked, the following
columns become visible in the tabular display:
DrawTime spent drawing the front panel of this VI. Draw time
includes the following:
The time it takes simply to draw a front panel when its window
just has been opened, or when it is being revealed after being
obscured by another window.
26-4
Chapter 26
Performance Issues
Memory Information
When the Memory Usage checkbox is checked (remember that this is
only available if the Profile Memory Usage checkbox was selected
before you began the profiling session), you can view information about
how your VIs are using memory. These values are a measure of the
memory used by the data space for the VI and do not include the support
data structures necessary for all VIs. The data space for the VI contains
not just the data explicitly being used by front panel controls, but also
temporary buffers that are implicitly created by the compiler.
The memory sizes are measured at the conclusion of the run of a VI and
might not exactly reflect its total usage. For instance, if a VI creates
large arrays during its run but reduces their size before the VI finishes,
the sizes displayed do not reflect the intermediate larger sizes.
Two sets of data are displayed in this sectiondata related to the
number of bytes used, and data related to the number of blocks used.
The execution system uses independent blocks of memory for arrays,
strings, paths, and pictures (from the Picture Control Kit). Large
numbers of blocks in the memory heap of your application can cause an
overall degradation of performance (not just execution).
The categories of Memory Usage are the following:
26-5
Chapter 26
Performance Issues
Other factors, such as execution overhead and subVI call overhead can
have an effect, but these are usually minimal and not the most critical
source of slow execution.
Input/Output
Input/Output calls generally incur a lot of overhead. They often take an
order of magnitude more time than the time it takes to perform a
computational operation. For example, a simple serial port read
operation might have an associated overhead of several milliseconds.
This amount of overhead is true for any application that uses serial
ports. The reason for this overhead is that an I/O call involves
transferring information through several layers of an operating system.
The best method for addressing too much overhead is to minimize the
number of I/O calls you make. Your performance improves if you can
structure your application so that you transfer a lot of data with each
call, instead of making multiple I/O calls using smaller amounts of data.
For example, if you are creating a data acquisition (NI-DAQ) VI, you
have a couple of options for reading data. You can use a single-point
data transfer function such as the AI Sample Channel VI or you can use
a multi-point data transfer function such as the AI Acquire Waveform
G Programming Reference Manual
26-6
Chapter 26
Performance Issues
VI. If you need to acquire 100 points, you could use the AI Sample
Channel VI in a loop with a Wait function to establish the timing. Or
you can use the AI Acquire Waveform VI with an input indicating that
you want 100 points.
You can produce much higher and more accurate data transfer rates by
using the AI Acquire Waveform VI, because it uses hardware timers to
manage the data transfer. In addition, overhead for the AI Acquire
Waveform VI is roughly the same as the overhead for a single call to the
AI Sample Channel VI, even though it is transferring much more data.
Screen Display
Updating controls on a front panel can frequently be one of the most
time expensive operations in an application. This is especially true if
you use some of the more complicated displays, such as graphs and
charts.
This overhead is minimized to a certain extent by the fact that most of
the controls are intelligent; they do not redraw when they receive new
data if the new data is the same as the old data. Graphs and charts are
exceptions to this rule.
If redraw rate becomes a problem, the best solutions are to reduce the
number of controls you use, and keep the displays as simple as possible.
In the case of graphs and charts, you can turn off autoscaling, scale
markers, and grids to speed up displays.
If you have controls that are overlapped with other objects, their display
rate is cut down significantly. The reason for this is that if a control is
partially obscured, more work has to be done to redraw that area of the
screen. Unless you have the Smooth Updates preference on, you will
probably see more flicker when controls are overlapped.
As with other kinds of I/O, there is a certain amount of fixed overhead
in the display of a control. You can pass multiple points to an indicator
at one time using some controls, such as charts. You can minimize the
number of chart updates you need to make by passing more data to the
chart each time. You can see much higher data display rates if you
collect your chart data into arrays so that you can display multiple
points at a time, instead of displaying each point as it comes in.
When you design subVIs whose front panels are closed during
execution, you do not need to worry about display overhead. If the front
26-7
Chapter 26
Performance Issues
panel is closed, you do not have the drawing overhead for controls, so
graphs are no more expensive than arrays.
Other Issues
Parallel Diagrams
When you have multiple diagrams running in parallel, the execution
system switches between them periodically. If some of these loops are
less important than others, use the Wait function to ensure that the less
important loops use less time.
For example, consider the following diagram.
There are two loops in parallel. One of the loops is acquiring data, and
needs to execute as frequently as possible. The other loop is monitoring
user input. The loops receive equal time because of the way this
program is structured. The loop monitoring the users action has a
chance to run several times a second.
In practice, it is usually acceptable if the loop monitoring the button
executes only once every half second, or even less often. By calling the
Wait (ms) function in the user interface loop, you allot significantly
more time to the other loop.
26-8
Chapter 26
Performance Issues
SubVI Overhead
When you call a subVI, there is a certain amount of overhead associated
with the call. This overhead is fairly small (on the order of tens of
microseconds), especially in comparison to I/O overhead and display
overhead, which can range from milliseconds to tens of milliseconds.
However, this overhead can add up in some cases. For example, if you
call a subVI 10,000 times in a loop, this overhead might take up a
significant amount of time. In this case, you might want to consider
whether the loop can be embedded in the subVI.
Another option that you might consider is turning certain subVIs into
subroutines (using the VI Setup Priority option). When a VI is marked
as a subroutine, the execution system minimizes the overhead to call a
subVI. There are a few trade-offs, however. Subroutines cannot display
front panel data (G does not copy data from or to the front panel controls
of subroutines), they cannot contain timing or dialog box functions, and
they do not multitask with other VIs. Subroutines are short, frequently
executed tasks and are generally most appropriate when used with VIs
that do not require user interaction.
26-9
Chapter 26
Performance Issues
The result of the division is the same every time through the loop;
therefore you can increase performance by moving the division out of
the loop, as shown in the following illustration.
26-10
Chapter 26
Performance Issues
If you know that the value of the global variable is not going to be
changed by another concurrent diagram or VI during this loop, this
diagram wastes time by reading from the global variable and writing to
the global every time through the loop.
If you do not need the global variable to be read from or written to by
another diagram during this loop, you might use the following diagram
instead.
Notice that you need the shift registers to pass the new value from the
subVI to the next iteration of the loop. The following diagram is a
common mistake that some beginning users make. Since there is no
shift register, the results from the subVI never pass back to the subVI
as its new input value.
26-11
Chapter 26
Performance Issues
Memory Usage
G handles many of the details which you normally have to worry about
in a conventional programming language transparently. One of the main
challenges of a conventional language is memory usage. In a
conventional language, you, the programmer, have to take care of
allocating memory before you use it, and deallocating it when you
finish. You also have to be particularly careful not to accidentally write
past the end of the memory you allocated in the first place. Failure to
allocate memory or to allocate enough memory is one of the biggest
mistakes that programmers make in conventional, text-based languages.
Inadequate memory allocation is also a difficult problem to debug.
The dataflow paradigm for G removes much of the difficulty of
managing memory. In G, you do not allocate variables, nor assign
values to and from them. Instead, you create a diagram with connections
representing the transition of data.
Functions that generate data take care of allocating the storage for that
data. When data is no longer being used, the associated memory is
deallocated. When you add new information to an array or a string,
enough memory is allocated automatically to manage the new
information.
This automatic memory handling is one of the chief benefits of G.
However, because it is automatic, you have less control over when it
happens. If your program works with large sets of data, it is important
to have some understanding of when memory allocation takes place. An
understanding of the principles involved can result in programs with
significantly smaller memory requirements. Also, an understanding of
how to minimize memory usage can also help to increase VI execution
speeds because memory allocation and copying data can take a
considerable amount of time.
Virtual Memory
If you have a machine with a limited amount of memory, you might
want to consider using virtual memory to increase the amount of
memory available for applications. Virtual memory is a capability of
your operating system by which it uses available disk space for RAM
storage. If you allocate a large amount of virtual memory, applications
perceive this as memory that is generally available for storage.
26-12
Chapter 26
Performance Issues
Macintosh Memory
When you launch an application on the Macintosh, the system allocates
a single block of memory for it, from which all memory is allocated.
When you load VIs, components of those are loaded into that memory.
Similarly, when you run a VI, all the memory that it manipulates is
allocated out of that single block of memory.
You configure the amount of memory that the system allocates at
launch time using the FileGet Info command from the Finder. Keep in
mind that if your application runs out of memory, it cannot increase the
size of this memory pool. Therefore, you should set up this parameter
to be as large as is practical. If you have a 16 MB machine, consider the
applications that you want to run in parallel. If you do not plan to run
any other applications, set the memory preference to be as large as
possible.
Front panel
Block diagram
When you load a VI, the front panel, the code (if it matches the
platform), and the data for the VI are loaded into memory. If the VI
needs to be recompiled because of a change in platform or a change in
the interface to a subVI, then the diagram is loaded into memory as
well.
You also can load the code and data space of subVIs into memory.
Under certain circumstances, you can load the front panel of some
subVIs into memory as well. This can occur, for example, if the subVI
26-13
Chapter 26
Performance Issues
26-14
Chapter 26
Performance Issues
The input array and the output array contain the same number of
elements, and the data type for both arrays is the same. Think of the
incoming array as a buffer of data. Instead of creating a new buffer for
the output, the compiler reuses the input buffer. This saves memory, and
also results in faster execution, because no memory allocation needs to
take place at run time.
The compiler cannot reuse memory buffers in all cases, however, as
shown in the following illustration.
26-15
Chapter 26
Performance Issues
As before, the input branches to three functions are the same. However,
in this case none of them need to modify the data. If you pass data to
multiple locations, all of which read the data without modifying it, G
does not need to make a copy of the data. This diagram uses up about
4 KB of data.
Finally, consider the following diagram.
In this case, the input branches to two functions, one of which wants to
modify the data. There is no dependency between the two functions.
Therefore, you can predict that at least one copy needs to be made so
the replace array element function safely modifies the data. In this case,
the compiler schedules the execution of the functions in such a way that
the function that wants to read the data executes first, and the function
that wants to modify the data executes last. This way, the Replace Array
Element function reuses the incoming array buffer without generating a
duplicate array. If the ordering of the nodes is important, you should
26-16
Chapter 26
Performance Issues
26-17
Chapter 26
Performance Issues
Do not worry too much about copies of scalar values; it takes a lot
of scalars to make a dent in memory usage.
On open front panels, do not display large arrays and strings unless
it is necessary. Indicators on open front panels retain a copy of the
data that they display.
Use consistent data types for arrays and watch for coercion dots
when passing data to subVIs and functions; when you change data
types, the output is a new buffer.
26-18
Chapter 26
Performance Issues
When you run the VI, the data of the front panel control is passed to the
diagram. The increment function reuses the input buffer. The indicator
then makes a copy of the data for display purposes. Thus, there are three
copies of the buffer.
This data protection of the front panel control prevents the case in
which you enter some data into a control, run the associated VI, and see
the data change in the control as it is passed in-place to subsequent
nodes. Likewise, data is protected in the case of indicators so that they
can reliably display the previous contents until they receive new data.
With subVIs, you can use controls and indicators as inputs and outputs.
The execution system makes a copy of the control and indicator data of
the subVI in the following conditions.
The VI has been changed, but has not been saved (all
components of the VI remain in memory until the VI has been
saved).
Chapter 26
Performance Issues
A few of these reasons are not intuitive and need further explanation.
One reason concerns attributes such as chart history. For an Attribute
Node to be able to read the chart history in subVIs that are not open, the
control or indicator needs to go through the motions of displaying the
data that is passed to controls and indicators. Because there are
numerous other attributes like this, the execution system keeps subVI
panels in memory if the subVI uses Attribute Nodes.
If a front panel uses front panel datalogging or data printing, then
controls and indicators maintain copies of their data. In addition, panels
are kept in memory for data printing so that the panel can be printed out.
If a VI uses Suspend data range checking, data is copied to and from all
front panel controls and indicators. The front panel values are retained
so that the front panel can be displayed if any data goes out of range. Do
not use Suspend range checking if memory and speed are a major
concern.
Remember, if you have set a subVI to display its front panel when
called using VI Setup or SubVI Setup, the panel is loaded into memory
when the subVI is called. If you have set the Close if Originally Closed
option, the panel is removed from memory when the subVI finishes
execution.
26-20
Chapter 26
Performance Issues
you read from a local variable, you create a new buffer for the data from
its associated control.
If you use local variables to transfer large amounts of data from one
place on the diagram to another, you generally use more memory, and
consequently have slower execution speed than if you can transfer data
using an alternative wire path.
After the Mean VI has executed, the array of data is no longer needed.
Because determining when data is no longer needed can become very
complicated in larger diagrams, the execution does not deallocate the
data buffers of a particular VI during its execution.
26-21
Chapter 26
Performance Issues
26-22
Chapter 26
Performance Issues
26-23
Chapter 26
Performance Issues
26-24
Chapter 26
Performance Issues
If you want to add a value to the array with every iteration of the loop,
you can see the best performance by using auto-indexing on the edge of
a loop. With For Loops, the VI can predetermine the size of the array
(based on the value wired to N), and resize the buffer only once.
26-25
Chapter 26
Performance Issues
Auto-indexing assumes that you are going to add a value to the resulting
array with each iteration of the loop. If you need to conditionally add
values to an array, but you can determine an upper limit on the array
size, you might consider preallocating the array and then using Replace
Array Element to fill up the array.
When you are finished filling up the array values, you can resize the
array to the correct size. The array is created only once, and Replace
Array Element can reuse the input buffer for the output buffer. The
performance for this is very similar to the performance of loops using
auto-indexing. If you use this technique, you need to be careful that the
array in which you are replacing values is large enough to hold the
resulting data, because Replace Array Element does not resize arrays
for you.
An example of this process is shown in the following illustration.
26-26
Chapter 26
Performance Issues
One problem with this diagram is that it uses Build Array in the loop to
concatenate the new value to the previous value. Instead, you can use
auto-indexing to accumulate values on the edge of the loop. Notice that
National Instruments Corporation
26-27
Chapter 26
Performance Issues
you end up seeing an extra, unwanted value in the array from the last
iteration of the loop where Match Pattern fails to find a match. A
solution is to use array subset to remove the extra unwanted value. This
is shown in the following illustration.
The other problem with this diagram is that you create an unnecessary
copy of the remaining string every time through the loop. Match Pattern
has an input you can use to indicate where to start searching. If you
remember the offset from the previous iteration, you can use this
number to indicate where to start searching on the next iteration. This
technique is shown in the following illustration.
26-28
Chapter 26
Performance Issues
This is quite efficient because no extra copies of the overall array need
to be generated. Also, the element produced by the Index Array function
is a scalar, which can be created and manipulated efficiently.
The same is true of an array of clusters, assuming the cluster contains
only scalars. In the following diagram, manipulation of elements
becomes a little more complicated, because you now have to use
Unbundle and Bundle. However, because the cluster is probably small
(scalars use very little memory), there is no significant overhead
involved in accessing the cluster elements and replacing the elements
back into the original cluster.
26-29
Chapter 26
Performance Issues
26-30
Chapter 26
Performance Issues
26-31
Chapter 26
Performance Issues
Given this data structure, you can replace an array element directly
using the Replace Array Element function, as shown in the following
illustration.
26-32
Chapter 26
Performance Issues
Obvious Implementation
With this set of functions, there are several data structures you could
consider for the underlying table. First, you might use a global variable
containing an array of clusters, where each cluster contains the gain,
lower limit, upper limit, and the channel name.
As described in the previous section, this data structure is difficult to
manipulate efficiently, because you generally have to go through
several levels of indexing and unbundling to access your data. Also,
because the data structure is a conglomeration of several pieces of
information, you cannot use the Search 1D Array function to search for
a channel. You can use Search 1D Array to search for a specific cluster
in an array of clusters, but you cannot use it to search for elements that
match on a single cluster element.
Alternative Implementation 1
As with the previous example, you could choose to keep the data in two
separate arrays. One could contain the channel names. The other array
can contain the channel data. The index of a given channel name in the
array of names is used to find the corresponding channel data in the
other array.
Notice that because the array of strings is separate from the data, you
can use the search 1D Array function to search for a channel.
In practice, if you are creating an array of 1,000 channels using the
Change Channel Info VI, this implementation is roughly twice as fast
as the previous version. This change is not very significant because
there is other overhead that is affecting performance.
If you have read through the Memory Usage section of this chapter, you
might have seen a note indicating that you should avoid overusing local
and global variables. When you read from a global variable, a copy of
the data of the global variable is generated. Thus, a complete copy of
the data of the array is being generated each time you access an element.
The next method shows an even more efficient method that avoids this
overhead.
Alternative Implementation 2
There is an alternative method for storing global data, and that is to use
an uninitialized shift register. Essentially, if you do not wire an initial
value, a shift register remembers its value from call to call. If you are a
26-33
Chapter 26
Performance Issues
LabVIEW user and are not familiar with uninitialized shift registers, see
Chapter 3, Loops and Charts, of the LabVIEW Tutorial Manual before
continuing with this discussion. If you are a BridgeVIEW user, see
Chapter 10, Loops and Charts in your BridgeVIEW User Manual for
similar information.
The compiler handles access to shift registers efficiently. Reading the
value of a shift register does not necessarily generate a copy of the data.
In fact, you can index an array that is stored in a shift register and even
change and update its value without generating extra copies of the
overall array. The only problem with a shift register is that only the VI
that contains the shift register can access the data of the shift register.
On the other hand, the shift register has the advantage of modularity.
What you can do is make a single subVI with a mode input that specifies
whether you want to read, change, or remove a channel, or whether you
want to zero out the data for all channels, as shown in the following
illustration.
The subVI would contain a While Loop with two shift registersone
for the channel data, and one for the channel names. Neither of these
shift registers should be initialized. Then, inside the While Loop you
would place a Case Structure connected to the mode input. Depending
on the value of the mode, you could read and possibly change the data
in the shift register.
26-34
Chapter 26
Performance Issues
26-35
Chapter 26
Performance Issues
26-36
Chapter
27
Portability Issues
VIs containing CINs. You see an object code not found error
if the CIN is from a different platform. If you write your CIN source
code in a platform independent manner, you can recompile it on
another platform and relink it to the ported VI.
VIs containing the Call Library function. The VI can port, but is
broken unless it can find a library of the same name.
In Port and Out Port Utility VIs for Windows and the Peek and Poke
Utility VIs for Macintosh.
27-1
Chapter 27
Portability Issues
27-2
Chapter 27
Portability Issues
The Dialog font is the font G uses for text in dialog boxes.
font.
When you take a VI that contains one of these fonts to another platform,
your application ensures that the font maps to something similar on that
platform.
If you do not use the predefined fonts, but instead select a specific font
such as Geneva or New York, the font can change size on the new
platform because of the differences in the fonts available and
differences in the resolution of the display. If you select Geneva or New
York on the Macintosh, the application cannot match it on the Sun or
HP-UX, and the application uses the font named fixed. If you take a VI
with unrecognized fonts to Windows, you might not have a good
mapping to a new font.
27-3
Chapter 27
Portability Issues
Overlapping Labels
When you move a VI to a new platform, controls and labels might
change size, depending on if the fonts are smaller or larger. G tries to
keep labels from overlapping their owners by moving them away from
the owning control. Also, every label and constant has a default
attribute called Size to Text. When you first create a label or constant,
this attribute is set, so the bounds of the object resize as necessary to
display all of the enclosed text.
If you ever manually resize the object, the application turns off this
attribute (the item in the pop-up menu is no longer checked). With Size
to Text turned off, the bounds of the object stay constant, and the
application clips (or crops) the enclosed text as necessary. If you do not
want the application to clip text when you move between systems or
platforms, leave this attribute on for labels and constants.
Most Sun and HP monitors are much larger and have a higher resolution
than PC and Macintosh monitors. If you are a Sun or an HP-UX user,
do not make your front panels very large if you want them to port well.
For best results, avoid overlapping controls and leave extra space. If a
label even partially overlaps another object and the font is enlarged, it
might end up overlapping the control.
Picture Differences
The most basic type of picture contains a bitmap, a series of values
specifying the color of each pixel in the picture. More complex pictures
might contain any number of commands that are executed every time
the picture is drawn. Pictures containing drawing commands are created
by drawing programs or in the draw layer of a graphics application.
Bitmap-based pictures are created by paint programs or in the paint
layer of a graphics application.
27-4
Chapter 27
Portability Issues
27-5
Appendix
This appendix discusses the formats in which you can save data. This
information is most useful to advanced users, such as those using code
interface nodes (CINs) and those reading from or writing to files used
by the file I/O functions. This appendix explains how data is stored in
memory, the relationship of type descriptors to data storage, and the
method by which data is flattened for file storage on disk.
Numerics
Extended
When extended-precision numbers are saved to disk, they are stored in
a platform-independent 16-bit format. In memory, the size and
precision varies depending on the platform.
(Windows) Extended-precision floating-point numbers have 80-bit
format (80287 extended-precision format).
A-1
Appendix A
head
tail
Double
Double-precision floating-point numbers have 64-bit IEEE
double-precision format (format default).
Single
Single-precision floating-point numbers have 32-bit IEEE
single-precision format.
A-2
Appendix A
Long Integer
Long integer numbers have 32-bit format, signed or unsigned.
Word Integer
Word integer numbers have 16-bit format, signed or unsigned.
Byte Integer
Byte integer numbers have 8-bit format, signed or unsigned.
Arrays
You can store arrays through the size of each dimension of any array in
long integers, followed by the data. Because of alignment constraints of
certain platforms, the dimension size might be followed by a few bytes
of padding so that the first element of the data is correctly aligned. If
you are a LabVIEW user, see the Alignment Considerations section of
Chapter 2, CIN Parameter Passing, of the LabVIEW Code Interface
Reference Manual for further information. The example that follows
shows a one-dimensional array of single-precision floating-point
A-3
Appendix A
A-4
Appendix A
Strings
G stores strings as if they were one-dimensional arrays of byte integers
(8-bit characters).
Paths
Paths are stored with the path type and number of path components in
word integers, followed immediately by the path components. The path
type is 0 for an absolute path and 1 for a relative path. Any other value
of path type indicates that the path is invalid. Each path component is a
Pascal string (P-string) in which the first byte is the length, in bytes, of
the P-string (not including the length byte).
Clusters
A cluster stores elements of varying data types according to the cluster
order. You store scalar data directly in the cluster. Arrays, strings,
handles, and paths are stored indirectly. The cluster stores a handle that
points to the memory area in which the data actually has been stored.
A-5
Appendix A
(Windows)
(Macintosh)
(Sun)
A-6
Appendix A
(HP-UX)
In the next example, the embedded clusters are not stored indirectly.
Instead, the data is stored inside the embedded clusters directly, as if the
data were not embedded in the subcluster. Only arrays, strings and
handles are stored indirectly.
Type Descriptors
Each wire and terminal in the block diagram has a data type associated
with it. You can keep track of this type with a structure in memory
called a type descriptor. This descriptor is a string of word integers that
can describe any data type in G. Numeric values are written in
hexadecimal, unless otherwise noted.
The generic format of a type descriptor is: <length> <typecode>.
Some type descriptors have additional information following the type
code. Arrays and clusters are structured or aggregate data types because
National Instruments Corporation
A-7
Appendix A
they include other types. For example, the cluster type contains
additional information about the type of each of its elements.
The first word (16 bits) in any type descriptor is the length, in bytes, of
that type descriptor (including the length word). You can reserve the
high-order byte of the type code for internal use. When comparing two
type descriptors for equality, it is a good idea to ignore this byte; two
descriptors are equal even if the high-order bytes of the type codes are
not.
The type code encodes the actual type information, such as
single-precision or extended-precision floating-point number, as listed
in the following table. These type code values might change in future
versions. The xx in the type descriptor columns represent reserved
values and should be ignored.
Data Types
The following tables list scalar numeric and non-numeric data types, the
type codes, and type descriptors.
Scalar Numeric Data Types
Table A-1.
Data Type
Type Code
Type Descriptor
(numbers in
hexadecimal)
(numbers in
hexadecimal)
Byte Integer
01
0004 xx01
Word Integer
02
0004 xx02
Long Integer
03
0004 xx03
05
0004 xx05
06
0004 xx06
07
0004 xx07
Single-Precision
Floating-Point Number
09
0004 xx09
Double-Precision
Floating-Point Number
0A
0004 xx0A
A-8
Appendix A
Table A-1.
Data Type
Type Code
Type Descriptor
(numbers in
hexadecimal)
(numbers in
hexadecimal)
Extended-Precision
Floating-Point Number
0B
0004 xx0B
Single-Precision Complex
Floating-Point Number
0C
0004 xx0C
Double-Precision Complex
Floating-Point Number
0D
0004 xx0D
Extended-Precision Complex
Floating-Point Number
0E
0004 xx0E
15
16
17
Single-Precision Physical
Quantity
19
Double-Precision Physical
Quantity
1A
Extended-Precision Physical
Quantity
1B
Single-Precision Complex
Physical Quantity
1C
Double-Precision Complex
Physical Quantity
1D
Extended-Precision Complex
Physical Quantity
1E
A-9
Appendix A
Table A-2.
Data Type
Type Code
Type Descriptor
Boolean
20
0004 xx20
String
30
0004 xx30
Handle
31
Path
32
0004 xx32
Pict
33
0004 xx33
Array
40
Cluster
0x50
The minimum value in the size field of a type descriptor is 4 (as shown
in the first table). However, any type descriptor can have a name
appended (a Pascal string) in which case the size is larger by the length
of the name.
Notice that the array and cluster data types each have their own type
code. They also contain additional information about their
dimensionality (for arrays) or number of elements (for clusters), as well
as information about the data types of their elements.
In the following example of an enumerated type for the items am, fm,
fm stereo, each group represents a 16-bit word. The space enclosed
in quotes (" ") represents an ASCII space.
0016 0015 0003 02a m02 fm 09f m" "st er eo
A-10
Appendix A
0002 denotes the seconds base index. FFFF is the exponent of seconds.
0003 denotes the meters base index. 0001 is the exponent of meters.
Note:
Array
The type code for an array is 0x40. Immediately after the type code is a
word containing the number of dimensions of the array. Then, for each
dimension, an unsigned long integer contains the size, in elements, of
that dimension. Finally, after each of the dimension sizes, the type
descriptor for the element appears. The element type might be any type
except an array. The dimension size for any dimension might be
FFFFFFFF (1). This means that the array dimension size is variable.
Currently, all arrays are variable-sized. The actual dimension size is
stored with the data. The dimension size is always greater than or equal
to zero. The following is a type descriptor for a one-dimensional array
of double-precision floating-point numbers:
000E 0040 0001 FFFF FFFF 0004 000A
000E is the length of the entire type descriptor, including the element
type descriptor. The array is variable-sized, so the dimension size is
FFFFFFFF. Notice that the element type descriptor (0004 000A)
appears exactly as it does for a scalar of the same type.
The following is an example of a type descriptor for a two-dimensional
array of Booleans.
0012 0040 0002 FFFF FFFF FFFF FFFF 0004 0020
Cluster
The type code for a cluster is 0x50. Immediately after the type code is
a word containing the number of items in the cluster. After this word is
the type descriptor for each element in cluster order. For example,
consider a cluster of two integers: a signed-word integer and an
unsigned long integer:
000E 0050 0002 0004 0002 0004 0007
000E is the length of the type descriptor including the element type
descriptors.
A-11
Appendix A
floating-point number
0004 0003... long integer
Flattened Data
Two internal functions convert data from the format in memory to a
form more suitable for writing to or reading from a file.
Because strings and arrays are stored in handle blocks, clusters
containing these types are discontiguous. In general, data is stored in
tree form. For example, a cluster of a double-precision floating-point
number and a string is stored as an 8-byte floating-point number,
followed by a 4-byte handle to the string. The string data is not stored
adjacent in memory to the extended-precision floating-point number.
Therefore, if you want to write the cluster data to disk, you have to get
the data from two different places. Of course, with an arbitrarily
complex data type, the data might be stored in many different places.
When data is saved to a VI file or a datalog file, it flattens the data into
a single string before saving it. This way, even the data from an
arbitrarily complex cluster is made contiguous, instead of being stored
in several pieces. When G loads such a file from disk, it must perform
the reverse operationit must read a single string and unflatten it into
its internal G form.
The flattened data is normalized to a standard form so that the data can
be used unaltered by VIs running on any platform. It stores numeric data
in big endian form (most-significant byte format), and it stores
extended precision floating-point numbers as 16-byte quantities using
the Sun extended-precision format described earlier in this section.
Similar transformations might be necessary when reading data written
by other applications.
Note:
When writing data to a file for use by an application other than G, you
might need to transform your data after flattening it. Other Windows
A-12
Appendix A
Scalars
The flattened form of any numeric type, as well as the Boolean type,
contains only the data in big endian format. For example, a long integer
with value 19 is encoded as FFFF FFED. A double-precision
floating-point number with a value approximately equal to is 0X 40
09 21 FB 54 44 2D 18. A Boolean True is 8xxx, 9xxx, , Exxx,
or Fxxx.
The file form for extended-precision numbers is based on the SPARC
quadruple-precision form, which is a 16-bit biased exponent, followed
by a mantissa which is 112 bits long. The Macintosh and PC have an
explicit bit, the bit left of the binary point. In normalized numbers, this
bit is always a one. It is only a zero when the exponent is zero (very
small, denormalized numbers). On the SPARC, the bit left of the binary
point is an implicit bit (assumed always to be one) which does not
appear in the representation.
Arrays
The data for a flattened array is preceded by normalized long integers
that record the size, in elements, of each of the dimensions of the arrays.
A-13
Appendix A
Clusters
A flattened cluster is the concatenation (in cluster order) of the flattened
data of its elements. So, for example, a flattened cluster of a word
integer of value 4 (decimal) and a long integer of value 12 is 0004
0000 000C.
A flattened cluster of a string ABC and a word integer of value 4 is
0000 0003 4142 4300 04.
A flattened cluster of a word integer of value 7, a cluster of a word
integer of value 8, and a word integer of value 9 is 0007 0008 0009.
To unflatten this data, you just use the reverse process. The flattened
form of a piece of data does not encode the type of the data; you need
the type descriptor for that. The Unflatten From String function requires
you to wire a data type as an input, so that the function can decode the
string properly.
A-14
Appendix
B-1
Appendix B
B-2
Appendix B
B-3
Appendix B
B-4
Appendix B
B-5
Appendix B
B-6
Appendix B
Printing
When using automatic (programmatic) printing while
executing a VI, why is the information not printed until the VI
stops executing?
Programmatic printing by design does not print a VI or subVI until it
stops execution. For printing during execution, use a) FilePrint
Window to print the front panel manually, or b) a call to a subVI that
accepts the input data to its controls (the front panel might be identical
to that of the executing VI) and prints its results with programmatic
printing. For more details see the section Programmatic Printing in
Chapter 5, Printing VIs.
2.
3.
Assign the subVI a connector and pass the data from the graph on
the main VI to the graph on the subVI.
Every time your main VI calls the subVI, it automatically prints the
graph.
B-7
Appendix B
(Windows and UNIX) Use the System Exec VI to print a file through a
B-8
Appendix B
Enlarge the labels and front panel controls so that, when the text
expands because of a font mismatch, the text still fits in the control
or label boundary.
Find a font which is the same size on both the monitor and the
printer. Many printer drivers have font substitution algorithms to
assist this process.
Miscellaneous
What is info-LabVIEW and how do I subscribe?
Info-LabVIEW is a user-sponsored and supported network of
LabVIEW and BridgeVIEW users. Users can post information to a
specific e-mail address (see below); the posting is then broadcast to all
users subscribing to the list. Other users then might respond back to the
group or perhaps directly to the individual who wrote the post.
B-9
Appendix B
B-10
Appendix B
AESend Run VI
AESend Close VI
Loading two VIs that call two distinct subVIs with the same
name causes problems.
For example, main1.vi and main2.vi both call distinct subVIs which
are both named subVI.vi.
1.
2.
B-11
Appendix B
If a new item with priority 3 is placed on the queue, then the queue
would look like the following:
sss3322211111
B-12
Appendix B
There is no definite time limit on how long this might be, particularly if the
VI contains CINs, which may take a very long time to complete execution.
B-13
Appendix B
B-14
Appendix B
or
labview/usr/home/test.llb/test.vi
to launch the Test VI, depending on the correct path. You can use a
simple script to make a command that launches LabVIEW with a
particular VI.
B-15
Appendix B
B-16
Appendix
Customer Communication
For your convenience, this appendix contains forms to help you gather the information necessary
to help us solve your technical problems and a form you can use to comment on the product
documentation. When you contact us, we need the information on the Technical Support Form and
the configuration form, if your manual contains one, about your system configuration to answer
your questions as quickly as possible.
National Instruments has technical assistance through electronic, fax, and telephone systems to
quickly provide the information you need. Our electronic services include a bulletin board service,
an FTP site, a FaxBack system, and e-mail support. If you have a hardware or software problem,
first try the electronic support systems. If the information available on these systems does not
answer your questions, we offer fax and telephone support through our technical support centers,
which are staffed by applications engineers.
Electronic Services
Bulletin Board Support
National Instruments has BBS and FTP sites dedicated for 24-hour support with a collection of
files and documents to answer most common customer questions. From these sites, you can also
download the latest instrument drivers, updates, and example programs. For recorded instructions
on how to use the bulletin board and FTP services and for BBS automated information, call
(512) 795-6990. You can access these services at:
United States: (512) 794-5422 or (800) 327-3077
Up to 14,400 baud, 8 data bits, 1 stop bit, no parity
United Kingdom: 01635 551422
Up to 9,600 baud, 8 data bits, 1 stop bit, no parity
France: 01 48 65 15 59
Up to 9,600 baud, 8 data bits, 1 stop bit, no parity
FTP Support
To access our FTP site, log on to our Internet host, ftp.natinst.com, as anonymous and use
your Internet address, such as [email protected], as your password. The support files and
documents are located in the /support directories.
C-1
FaxBack Support
FaxBack is a 24-hour information retrieval system containing a library of documents on a wide
range of technical information. You can access FaxBack from a touch-tone telephone at
(512) 418-1111.
LabVIEW: [email protected]
Lookout: [email protected]
Telephone
Australia
Austria
Belgium
Canada (Ontario)
Canada (Quebec)
Denmark
Finland
France
Germany
Hong Kong
Israel
Italy
Japan
Korea
Mexico
Netherlands
Norway
Singapore
Spain
Sweden
Switzerland
Taiwan
U.K.
03 9879 5166
0662 45 79 90 0
02 757 00 20
905 785 0085
514 694 8521
45 76 26 00
90 527 2321
01 48 14 24 24
089 741 31 30
2645 3186
03 5734815
02 413091
03 5472 2970
02 596 7456
95 800 010 0793
0348 433466
32 84 84 00
2265886
91 640 0085
08 730 49 70
056 200 51 51
02 377 1200
01635 523545
Fax
03 9879 6277
0662 45 79 90 19
02 757 03 11
905 785 0086
514 694 4399
45 76 26 02
90 502 2930
01 48 14 24 14
089 714 60 35
2686 8505
03 5734816
02 41309215
03 5472 2977
02 596 7455
5 520 3282
0348 430673
32 84 86 00
2265887
91 640 0533
08 730 43 70
056 200 51 55
02 737 4644
01635 523154
Brand _____________________________________________
Other Products
Computer make and model ______________________________________________________
Microprocessor _______________________________________________________________
Clock frequency or speed _______________________________________________________
Type of video board installed ____________________________________________________
Operating system version _______________________________________________________
Operating system mode ________________________________________________________
Programming language _________________________________________________________
Programming language version __________________________________________________
Other boards in system _________________________________________________________
Base I/O address of other boards _________________________________________________
DMA channels of other boards ___________________________________________________
Interrupt level of other boards ___________________________________________________
Title:
Edition Date:
October 1996
Part Number:
321296A-01
Fax to:
Technical Publications
National Instruments Corporation
(512) 794-5678
Glossary
Prefix
Meaning
Value
m-
milli-
103
micro-
106
n-
nano-
109
Symbols
Infinity.
Pi.
A
absolute path
active window
ANSI
array
array shell
G-1
Glossary
ASCII
asynchronous execution
ATE
Attribute Node
auto-indexing
autoscaling
autosizing
B
block diagram
BNF
Boolean controls
and indicators
G-2
Glossary
breakpoint
Breakpoint tool
broken VI
Bundle node
C
case
Case Structure
cast
chart
CIN
cloning
cluster
cluster shell
G-3
Glossary
coercion
coercion dot
Color tool
compile
conditional terminal
connector
Part of the VI or function node that contains its input and output
terminals, through which data passes to and from the node.
connector pane
constant
continuous run
control
control flow
Controls palette
conversion
count terminal
G-4
Glossary
CPU
current VI
D
data acquisition
data dependency
data flow
data logging
datalog file
Description box
destination terminal
dialog box
dimension
G-5
Glossary
drag
DUT
E
empty array
Array that has zero elements, but has a defined data type. For
example, an array that has a numeric control in its data display
window but has no defined values for any element is an empty
numeric array.
EOF
execution highlighting
external routine
F
FFT
file refnum
An identifier that G associates with a file when you open it. You
use the file refnum to indicate that you want a function or VI to
perform an operation on the open file.
flattened data
Data of any type that has been converted to a string, usually, for
writing it to a file.
For Loop
Formula Node
frame
free label
Label on the front panel or block diagram that does not belong to
any other object.
G-6
Glossary
front panel
function
Functions palette
G
G
global variable
glyph
GPIB
graph control
H
handle
Help window
hex
G-7
Glossary
hierarchical palette
Hierarchy window
housing
Hz
I
icon
Icon Editor
icon pane
Region in the upper right corner of the front panel and block
diagram that displays the VI icon.
IEEE
indicator
Inf
inplace execution
instrument driver
I/O
iteration terminal
G-8
Glossary
L
label
Labeling tool
Tool used to create labels and enter text into text windows.
LED
Light-emitting diode.
legend
Object owned by a chart or graph that display the names and plot
styles of plots on that chart or graph.
M
marquee
matrix
Two-dimensional array.
MB
Megabytes of memory.
menu bar
mnemonic
modular programming
N
NaN
nodes
nondisplayable characters
not-a-path
A predefined value for the path control that means the path is
invalid.
not-a-refnum
G-9
Glossary
numeric controls
and indicators
O
object
Generic term for any item on the front panel or block diagram,
including controls, nodes, wires, and imported pictures.
one-dimensional
Operating tool
P
palette
pixmap
platform
plot
polymorphism
pop up
pop-up menus
Positioning tool
probe
G-10
Glossary
Probe tool
programmatic printing
pseudocode
pull-down menus
R
reentrant execution
representation
Subtype of the numeric data type, of which there are signed and
unsigned byte, word, and long integers, as well as
single-precision, double-precision, and extended-precision
floating-point numbers, both real and complex.
resizing handles
ring control
S
scalar
scale
scope chart
Scroll tool
sequence local
G-11
Glossary
Sequence Structure
shift register
sink terminal
slider
source terminal
string controls and indicators Front panel objects used to manipulate and display or input and
output text.
strip chart
structure
stub VI
subdiagram
subVI
sweep chart
T
table-driven execution
terminal
G-12
Glossary
Tip strip
Small yellow text banners that identify the terminal name and
make it easier to identify function and node terminals for wiring.
tool
toolbar
Bar containing command buttons that you can use to run and
debug VIs.
Tools palette
Palette containing tools you can use to edit and debug front panel
and block diagram objects.
top-level VI
two-dimensional
tunnel
type descriptor
U
universal constant
user-defined constant
UUT
V
VI
VI library
virtual instrument
G-13
Glossary
W
While Loop
wire
Wiring tool
Tool used to define data paths between source and sink terminals.
G-14
Index
I-15
Index
I-16
Index
B
background colors, 2-25
Backslash \ Codes Display option
available codes (table), 11-4
tab characters in strings (note), 11-2
working in backslash mode, 11-4 to 11-5
backslash character, backslash \ code
(table), 11-4
<Backspace> key
deleting objects, 2-13
deleting wires, 17-6
Bar Plots option, 15-21
base attributes. See attributes.
bends in wires, 17-6
big endian data, A-12
bitmap printing, 7-17
black and white vs. color icons, 3-3
blinking
background blinking color, 7-14
foreground blinking color, 7-14
setting blink speed of front panel objects, 7-10
Blinking Attribute, 20-8 to 20-9
Block Diagram option, Custom Print Settings
dialog box, 5-6
Block Diagram Preferences dialog box,
7-11 to 7-12
illustration, 7-11
Show dots at wire junctions, 7-11
Show subVI names when dropped, 7-11
Show tip-strips over terminals, 7-11
Show wiring guides, 7-11
I-17
Index
I-18
Index
I-19
Index
C
Call Chain ring, 4-21
Call Chains, reading, 4-21
Call Library Function, 23-3 to 23-7
Call Library Function dialog box, 23-4
calling conventions (Windows),
23-4 to 23-5
I-20
Index
I-21
Index
color box
illustration, 9-24
numeric controls and indicators, 9-24
color box constant, 16-6
Color Copy tool, 2-5
color icons vs. black and white, 3-3
color mapping options, intensity chart,
15-40 to 15-41
Color option
Font ring, 2-17
graph indicators, 15-22
Color palette
illustration, 2-24
More option, 2-25
Color Preferences dialog box, 7-13 to 7-14
Blink Background, 7-14
Blink Foreground, 7-14
Block Diagram, 7-13
Coercion Dots, 7-13
Front Panel, 7-13
illustration, 7-13
Menu Background, 7-14
Menu Text, 7-13
Provide extra colors, 7-14
Scrollbar, 7-13
Use default colors, 7-14
color ramp, 9-25 to 9-26
Color Table Attribute, 15-40 to 15-41
Color tool, 2-5
coloring objects, 2-24 to 2-26
copying and transferring colors, 2-26
customizing colors, 2-25 to 2-26
foreground and background colors, 2-25
limitations, 2-24
transparent objects, 2-24 to 2-25
columns
headers, 11-6
resizing, 11-6 to 11-7
<command> key
cutting, copying, and pasting icons
(note), 3-4
moving between array elements, 14-13
moving between cluster elements, 14-21
I-22
Index
I-23
Index
<Ctrl-click>
copying and transferring colors, 2-26
executing Show VI Hierarchy
action, 3-21
resizing working space, 2-24
untacking last tack point (note), 17-3
<Ctrl-Enter>, embedding newlines, 7-10
<Ctrl-f>, bringing up Find dialog box, 3-24
<Ctrl-h> (help key), 1-7
<Ctrl-m>, switching from run mode to edit
mode (note), 6-6
<Ctrl-Shift>, bringing up temporary Tools
palette, 2-4
<Ctrl-y>, calling History window, 14-6
cursors. See graph cursors.
custom controls
adding cosmetic parts to custom controls,
22-17 to 22-18
adding to Controls palette, 22-1, 22-5
applying changes from custom controls,
22-3 to 22-4
caveats, 22-18 to 22-19
Control Editor, 22-1 to 22-3
Control Editor Parts window,
22-7 to 22-9
controls as parts, 22-15 to 22-17
cosmetic parts, 22-9 to 22-14
independent pictures, 22-12 to 22-14
more than one picture,
22-11 to 22-12
creating, 22-1 to 22-4
current part, 22-8
independence from source file, 22-5
independent parts, 22-6 to 22-7
making icons, 22-5
opening, 22-5
pop-up menus for different parts, 22-9
purpose and use, 22-1
saving, 22-4
scale parts, 22-15
text parts, 22-14 to 22-15
using, 22-4
valid custom controls, 22-3 to 22-4
I-24
Index
D
Data Log File RefNum, 12-3 to 12-5
Data Logging menu, 4-5 to 4-6
Change Log File Binding option, 4-6
data logging operation, 4-5 to 4-6
illustration, 4-5
Purge Data option, 4-6
data logging on front panel, 4-5 to 4-7
changing log file binding, 4-6
Data Logging menu, 4-5 to 4-6
deleting marked records, 4-6
enabling/disabling automatic data
logging, 6-6
marking records for deletion, 4-6
retrieving data programmatically,
4-7 to 4-9
accessing databases, 4-7 to 4-9
halo terminals for accessing data,
4-7, 4-8
using file I/O functions, 4-9
viewing records, 4-6 to 4-7
waveform charts (note), 4-6
Data Operations menu
Autoscale X, 15-13
Autoscale Y, 15-13
control pop-up menu options, 4-2 to 4-3
Copy Data, 11-8
Cut Data, 11-8, 14-13
Description, 2-26
Empty Array, 14-13
End Selection, 14-14 to 14-16, 15-33
front panel control and indicator pop-up
menu, 8-3
Make Current Value Default, 14-21
object pop-up menu options, 4-3 to 4-4
Paste Data, 11-8
Reinitialize to Default Values, 14-21
Show Last Element, 14-13
I-25
Index
I-26
Index
I-27
Index
E
Edit Control & Function Palettes option,
7-24, 22-16
Edit Control option, 22-1 to 22-2
Edit Icon option, 3-2, 3-21
Edit menu
Clear, 2-13
Copy, 2-12
Cut, 2-12
Edit Control, 22-1 to 22-2
Edit Control & Function Palettes,
7-24, 22-16
Move Backward, 2-11
Move Forward, 2-10
Move to Back, 2-11
Move to Front, 2-10
Panel Order, 8-8 to 8-9
I-28
Index
Paste, 2-12
Remove Bad Wires, 4-10, 17-6,
17-11, 17-14
SubVI From Selection, 3-10
User Name, 7-19 to 7-20
Edit Palettes dialog box, 7-26 to 7-27
Edit VI Library option, 2-30
editing VIs
aligning objects, 2-11 to 2-12
coloring objects, 2-24 to 2-26
creating object descriptions, 2-26 to 2-27
creating VI descriptions, 2-26 to 2-27
deleting objects, 2-13
distributing objects, 2-12
dragging and dropping VIs, pictures, and
text, 2-8 to 2-9
duplicating objects, 2-12 to 2-13
labeling objects, 2-14 to 2-22
free labels, 2-14 to 2-16
text characteristics, 2-16 to 2-22
positioning objects, 2-9 to 2-11
resizing objects, 2-23 to 2-24
front panel and block diagram work
space, 2-24
labels, 2-23 to 2-24
selecting objects, 2-7 to 2-8
switching from run mode to edit mode
(note), 6-6
while running VIs, 4-2 to 4-4
control pop-up menu options,
4-2 to 4-3
object pop-up menu options,
4-3 to 4-4
efficient data structures. See performance
issues.
electronic support services, C-1 to C-2
e-mail support, C-2
Empty Array command, 14-13
empty arrays, 14-12
Enable Database Access option, 4-7, 4-8
Enable Indexing option, 18-8
Enable Log/Print at Completion option, 6-6
I-29
Index
F
fax and telephone support, C-2
FaxBack support, C-2
File Convert CVI FP File option, 23-8
file dialog boxes, native, 7-21 to 7-22
file I/O functions, for retrieving logged
data, 4-9
file management
arranging files in VI libraries,
25-1 to 25-2
backing up files, 25-2
File menu
Apply Changes, 22-3
Edit VI Library, 2-30
Page Setup, 5-2
Printer Setup, 5-2
Revert, 2-28, 3-11, 22-11
Save, 2-28, 22-20
Save a Copy As, 2-28
I-30
Index
I-31
Index
I-32
Index
G environment, customizing
controls and functions palettes,
7-25 to 7-29
adding VIs and
controls to user.lib and
instr.lib, 7-25
creating subpalettes, 7-27 to 7-29
installing and changing views, 7-26
moving subpalettes, 7-29
Palettes editor, 7-26 to 7-27
views, 7-29
Preferences Dialog Box options,
7-1 to 7-24
block diagram preferences,
7-11 to 7-12
color preferences, 7-13 to 7-14
debugging preferences, 7-12 to 7-13
font preferences, 7-14 to 7-15
front panel preferences, 7-9 to 7-11
history preferences, 7-17 to 7-20
miscellaneous preferences,
7-22 to 7-23
path preferences, 7-2 to 7-6
performance and disk preferences,
7-6 to 7-9
printing preferences, 7-16 to 7-17
time and date preferences, 7-21
storing preferences, 7-23 to 7-25
Get Info option, 3-21
Global Variable palette, 21-1
global variables
creating, 21-1 to 21-2
definition, 21-1
example, 21-2
Find pop-up menu, 3-29
including in Hierarchy window,
3-18, 3-19
memory considerations, 26-21
memory usage, 26-21
placing in VIs, 21-3
purpose and use, 21-1 to 21-3
selecting, 21-2 to 21-3
Globals option, Select Objects menu, 3-25
G
G environment, 2-1 to 2-6. See also G
environment, customizing.
dataflow programming, 1-5
help information, 1-7 to 1-9
attribute node help, 1-9
block diagram help, 1-7 to 1-9
creating your own help files,
1-9 to 1-10
front panel help, 1-7
online reference, 1-9
menus, 2-6
overview, 1-1
pop-up menus, 2-6
questions
charts and graphs, B-1 to B-4
error messages and crashes,
B-4 to B-5
miscellaneous questions, B-9 to B-16
platform issues and
compatibilities, B-6
printing, B-7 to B-9
switching to Basic G palette from
BridgeVIEW (note), 2-1
Tools palette, 2-4 to 2-5
I-33
Index
H
handles, flattened data, A-13
headers, printing
Print Header option, 5-4, 5-8
Print Section Headers option, 5-6
help information, 1-7 to 1-9
attribute node help, 1-9
block diagram help, 1-7 to 1-9
creating your own help files, 1-9 to 1-10
adding documentation, 6-4
front panel help, 1-7
locking, 1-7
online reference, 1-9
Help menu
Lock Help command, 1-7
Online Reference command, 1-9
Show Help command, 1-7
Simple Help command, 1-7
Help Path box, VI Setup dialog box, 6-4
Help Tag box, VI Setup dialog box, 6-4
Help window
Attribute Nodes, 20-6
wiring connection information, 17-5
<Help> key, 1-7
hex characters
backslash \ code (table), 11-4
displaying strings as hex characters, 11-5
Hex Display option, 11-5
hidden labels, displaying, 2-16
Hide All SubVIs option, Hierarchy Node
Pop-Up menu, 3-20
I-34
Index
hiding
digital displays, 2-13
labels, 2-13
menu bar, 6-6, B-15
Stop button, 4-4
toolbar, 6-6
hierarchy node mouse clicks sequences,
3-21 to 3-22
Hierarchy Node Pop-Up menu
Edit Icon option, 3-21
Get Info option, 3-21
Hide All SubVIs option, 3-20
Highlight Connections option, 3-20
Open Front Panel option, 3-21
Print Documentation option, 3-21
Show All Callers option, 3-21
Show All SubVIs option, 3-21
Show Immediate SubVIs option, 3-20
Show VI Hierarchy option, 3-20
VI Setup option, 3-21
hierarchy of VI, printing, 5-6
Hierarchy window, 3-15 to 3-23
features, 3-15
Find Hierarchy Node mechanism,
3-22 to 3-23
node mouse-click sequences, 3-21 to 3-22
node pop-up menu options, 3-20 to 3-21
opening, 3-15 to 3-17
subVI connections to calling VIs,
3-16 to 3-17
toolbar buttons, 3-19
View menu options, 3-18 to 3-19
viewing during suspended
execution, 4-30
Highlight Connections option, 3-20
highlighting execution, 4-21 to 4-23
auto probe during, 7-12
example, 4-22
execution glyphs, 4-23
Hilite Execution button, 4-21
showing data bubbles, 7-12
Hilite <Return> Boolean option, 6-5
Hilite Execution button, 4-21
I
Icon, Description, Panel and Diagram format
option, 5-3
Icon and Description option, 5-5
VI Connector and Icon, 5-5
VI Description, 5-5
Icon Editor
Cancel button, 3-4
illustration, 3-2
OK button, 3-4
tools available, 3-3 to 3-4
Undo button, 3-4
icons
creating for controls, 22-5
creating for subVIs, 3-2 to 3-4
black and white vs. color icons, 3-3
Cancel button, 3-4
cutting, copying, and pasting icons
(note), 3-4
dropper tool, 3-3
I-35
Index
Inf
propagation by floating-point
operations, 4-17
range errors (note), 4-18
info-Labview (user group), B-9 to B-10
input/output performance considerations,
26-6 to 26-7
Insert option, wire pop-up menu, 16-12
Insert Submenu dialog box, 7-27 to 7-29
Automatic Update From directory, 7-28
Create a new menu file, 7-28
illustration, 7-28
Link to a directory, 7-28
Link to a library, 7-28
Link to an existing menu file, 7-28
inserting block diagram objects, 16-12
instr.lib, adding VIs and controls, 7-25
integers, displaying in other radixes, 9-4
intensity charts, 15-36 to 15-41
illustrations, 15-37 to 15-38
options, 15-38 to 15-41
color mapping, 15-40 to 15-41
history of data, 15-40
pop-up menu, 15-39
intensity graph, 15-29 to 15-30
data type, 15-29
options, 15-29 to 15-30
Interpolate Colors option, 9-25
Interpolation option, 15-21 to 15-22
interrupts, servicing, B-13
iteration terminal, 18-3
J
junction (of wires), 17-6
Justify option, Font ring, 2-17
I-36
Index
L
Label command, 2-3, 2-13, 2-16
labeling objects, 2-14 to 2-22
free labels, 2-14 to 2-16
text characteristics, 2-16 to 2-22
Labeling tool, 2-5
labels
copying text, 2-15
default labels for structures and
functions, 2-15
differences when porting VIs between
platforms, 27-3
displaying
function labels, 16-9
hidden labels, 2-16
free labels, 2-14 to 2-16
front panel, 2-3
hiding, 2-13
numeric scales, 9-18 to 9-19
min and max labels, 9-18 to 9-19
overlapping, 2-15, 27-3
owned labels
controls or indicators, 2-15
definition, 2-14
leaving blank, 2-15
resizing, 2-23
showing, 2-3, 2-16
subVIs on block diagram (note), 2-16
transparent, 7-10
National Instruments Corporation
I-37
Index
M
Make Current Value Default option,
14-12, 14-21
Make This Case option, 18-21
managing applications. See applications,
managing.
manual. See documentation (National
Instruments).
Mapping Mode option, 15-15
Mapping option, 9-15
marker spacing
adding or deleting markers, 15-14
non-uniform distribution, 15-14
Marker Spacing option
graph indicators, 15-13 to 15-14
slide scale pop-up menu, 9-14
marquee, 2-7
Mechanical Action palette, 10-4 to 10-5
memory preferences. See Performance and
Disk Preferences dialog box.
I-38
Index
I-39
Index
N
NaN (not a number)
propagation by floating-point
operations, 4-17
range errors (note), 4-18
native file dialogs, using, 7-22
Network Connection RefNum, 12-4, 12-5
node pop-up menu. See Hierarchy Node
Pop-Up menu.
nodes. See also structures.
definition, 16-1
functions, 16-8 to 16-11
I-40
Index
I-41
Index
I-42
Index
I-43
Index
I-44
Index
I-45
Index
Q
questions about G
charts and graphs, B-1 to B-4
error messages and crashes, B-4 to B-5
miscellaneous questions, B-9 to B-16
platform issues and compatibilities, B-6
printing, B-7 to B-9
R
radix for integers, selecting, 9-4
Range Error indicator, 4-14
range options for digital controls and
indicators, 9-6 to 9-7
Data Range dialog box, 9-7
floating-point numbers (table), 9-6
numeric range checking, 9-7 to 9-9
Coerce option, 9-7
correcting invalid values, 9-8 to 9-9
Ignore option, 9-7
Suspend option, 9-8
range of extended floating-point numbers
(note), 9-6
Record marked for deletion button, 4-6
rectangle tool, Icon Editor, 3-3
Redo Layout button, 3-19
I-46
Index
I-47
Index
I-48
Index
sequence locals
adding, 18-17
assigning more than one value to, 18-22
Sequence Structures
adding subdiagrams, 18-19 to 18-20
deleting subdiagrams, 18-20 to 18-21
editing, 18-18
example in examples.llb.vi, 18-16
icon for, 18-2, 18-13
moving between subdiagrams,
18-18 to 18-19
overview, 18-13 to 18-14
purpose and use, 16-11, 18-16 to 18-18
reordering subdiagrams, 18-21
sequence locals, 18-17 to 18-18
subdiagram display window, 18-13
wiring problems, 18-22 to 18-26
assigning more than one value to a
sequence local, 18-22
failing to wire a tunnel in all cases of
a Case Structure, 18-22
overlapping tunnels, 18-23
removing structures without deleting
items in a structure, 18-26
wiring from multiple frames of
Sequence Structure, 18-24 to 18-25
wiring underneath rather than
through a structure, 18-25 to 18-26
Serial Port VIs, 5-1
setting up VIs. See SubVI Node Setup dialog
box; VI Setup dialog box.
shift registers, 18-10 to 18-13
adding or removing terminals,
18-11 to 18-12
definition, 18-4, 18-10
initializing, 18-10 to 18-11
left and right terminals, 18-10
<Shift> key
positioning objects, 2-9
sizing multiple rows or columns, 11-7
I-49
Index
<Shift>-clicking
executing Show All SubVIs action, 3-21
selecting
multiple nodes, 3-22
table rows and columns, 11-7 to 11-9
selecting and deselecting objects, 2-7
using with selection rectangle, 2-8
<Shift-Enter> key
advancing through text scale labels, 9-19
creating text scale labels, 9-18
finding previous matching node, 3-23
<Shift-Return> key
advancing through text scale labels, 9-19
creating text scale labels, 9-18
finding previous matching node, 3-23
Show Abort Button option, 4-4
Show All Callers option, 3-21
Show All SubVIs option, 3-21
Show All VIs option, 3-18
Show Case option, 18-18
Show Connector command, 1-6, 3-5
Show Diagram command, 1-3, 2-4
Show Digital Display option
ring controls, 13-8
slide controls and indicators, 9-14
Show Error List command, 4-10
Show Front Panel When Called option
SubVI Node Setup dialog box, 6-6
VI Setup dialog box, 6-2
Show Front Panel When Loaded option, 6-2
Show Help command, 1-7
Show History command, 25-6
Show Immediate SubVIs option, 3-20, 3-21
Show Last Element option, 14-13
Show option, listbox controls pop-up menu
adding symbols to listbox items, 13-4
suboptions, 13-4
Show Parts Window option, 22-7
Show Radix command, 9-4
Show Selection option, 11-9, 14-14, 14-16
Show submenu option, 8-3
Show Terminals option, 16-1, 16-9
Show Toolbar option, 6-6
I-50
Index
I-51
Index
examples located in
examples.llb, 18-1
icons for, 18-2
overview, 18-2 to 18-3
placing and sizing on block diagram,
18-5 to 18-6
tunnels, 16-12
types of, 16-11
wiring problems
assigning more than one
value to sequence local, 18-22
failure to wire tunnel in all cases of
Case Structure, 18-22
overlapping tunnels, 18-23 to 18-24
removing structures without deleting
contents, 18-26
wiring from multiple frames of
Sequence Structure, 18-24 to 18-25
Structures palette, 18-1
student edition, objects unavailable, 7-12
Style option
Font ring, 2-17
Scale pop-up menu, 9-15
subdiagram display window
Case and Sequence Structures, 18-13
diagram identifier, 18-13
subdiagrams
adding, 18-19 to 18-20
definition, 18-2
deleting, 18-20 to 18-21
moving between, 18-18 to 18-19
reordering, 18-21
subpalettes
creating, 7-27 to 7-29
moving, 7-29
SubVI From Selection option, 3-10
SubVI Node Setup dialog box, 6-6
illustration, 6-6
options, 6-6
SubVI Node Setup option, 4-29
subVIs
analogous to subroutines in C, 3-1
building. See building subVIs.
calling two distinct subVIs with same
name, B-11
connections to calling VIs, in Hierarchy
window, 3-16 to 3-17
icons representing, 1-6
inability to edit descriptions from calling
VI diagram (note), 2-27
labels on block diagram (note), 2-16
memory usage, 26-20
performance considerations, 26-9
printing list of subVIs, 5-6
replacing subVI with same name, B-11
reusing data memory, 26-20
showing subVI name when dropped on
block diagram, 7-11
Sun numeric keypad, supporting, 7-10
Surround Panel with Border option, 5-8
Suspend When Called option
Operate menu, 4-29
SubVI Node Setup dialog box, 6-6
VI Setup dialog box, 6-2
suspending execution, 4-29 to 4-30
during debugging, 4-29
options, 4-29
recognizing automatic suspension,
4-29 to 4-30
Return to caller button, 4-30
Run button, 4-30
Skip to beginning button, 4-30
using toolbar buttons during
suspension, 4-30
viewing Hierarchy windows during
suspension, 4-30
sweep chart update mode, 15-26 to 15-27
Switch Until Released action, 10-5
Switch When Pressed action, 10-5
Switch When Released action, 10-5, 22-13
symbols for listbox items, 13-4
Synchronize with Directory option, 7-28
system crashes, questions about, B-4 to B-5
I-52
Index
patterns
defining, 3-5
selecting and modifying, 3-6
required, recommended, and optional
connections, 3-8 to 3-9
white terminal indicating incomplete
connection (note), 3-8
terminals. See also tunnels.
conditional terminal, 18-4
control and indicator terminals,
16-2 to 16-3
symbols, 16-2 to 16-3
count terminal, 18-3
definition, 16-1
destination terminals, 16-1
displaying, 16-1
front panel terminals
avoiding cycles in subVIs, 3-13
created automatically, 2-3 to 2-4
indicator terminals, 16-1
iteration terminal, 18-3
node input terminals, 16-1
overview, 1-4 to 1-5
placing inside For and While loops,
18-6 to 18-7
selector, 18-14
shift register terminals, 18-10
sink terminals, 16-1
source terminals, 16-1
types of, 16-1
text
changing fonts, 2-16 to 2-22
dragging and dropping, 2-8 to 2-9
finding, 3-26 to 3-27
menu text color, 7-13
numeric scale text labels, 9-18 to 9-19
min and max labels, 9-18 to 9-19
ring controls
adding text, 13-8 to 13-9
changing text, 13-10
text display pop-up menu, 9-19
Text Labels option, 9-18
text parts, 22-14 to 22-15
T
tab character
backslash \ code (table), 11-4
entering into string (note), 11-2
<Tab> key
moving between array elements, 14-13
moving between cluster elements, 14-21
moving between tools in Tools
palette, 2-5
string controls and indicators (note), 11-2
toggling between Positioning and Scroll
tools, 3-22
tables, 11-6 to 11-9
copying, cutting, and pasting data, 11-8
entering and selecting data tables,
11-7 to 11-9
illustration, 11-6
manipulating with string functions, 11-9
resizing tables, rows, and columns,
11-6 to 11-7
row and column headings, 11-9
Selection Scrolling option, 11-8
showing selected area of data, 11-9
technical support, C-1 to C-2
temporary directories, setting, 7-3 to 7-4
terminal connections for subVIs, 3-5 to 3-10
assigning to controls and indicators,
3-6 to 3-8
changing spatial arrangement, 3-6
confirming terminal connections,
3-9 to 3-10
deleting terminal connections, 3-9 to 3-10
limiting number of, when creating subVI
from selections, 3-12
I-53
Index
U
Unbundle By Name function
accessing cluster elements, 22-22
disassembling cluster elements,
14-30 to 14-32
Unbundle function, 14-29 to 14-30
unbundling cluster elements, 14-19
I-54
Index
V
Valid Path option, 12-2
Vertical Centers alignment, 2-12
Vertical Hierarchy option, 3-18
VI descriptions, creating, 2-27
VI Hierarchy option, 5-6
VI history. See also History Preferences dialog
box.
adding entries, 6-4, 7-18
printing, 5-6
VI History option, 5-6
VI History window, 25-6 to 25-9
example, 25-6
printing history information, 25-9
recording comments (note), 25-6
related VI Setup and Preferences dialog
options, 25-9
resetting history information, 25-8
revision numbers, 25-7 to 25-8
VI libraries (.LLBs), 2-29 to 2-30
arranging files in VI libraries,
25-1 to 25-2
avoiding saving VIs in vi.lib directory
(note), 2-29
creating, 2-30
editing contents of libraries, 2-30
including in Hierarchy window,
3-18, 3-19
reasons for saving VIs as libraries, 2-29
saving VIs in existing VI libraries, 2-30
setting library directories, 7-3 to 7-4
Top Level setting, 2-30
VI search path, setting, 7-5 to 7-6
I-55
Index
I-56
Index
W
Warning button, accessing Error List
window, 4-10
waveform and XY graphs, 15-2 to 15-22
creating multiplot graph, 15-5 to 15-11
waveform graph data types,
15-5 to 15-9
XY graph data types, 15-9 to 15-11
creating single-plot graph, 15-3 to 15-4
waveform graph data types,
15-2 to 15-3
XY graph data types, 15-3 to 15-4
definition, 15-2
graph options, 15-11 to 15-22
illustration, 15-12
legend options, 15-19 to 15-22
scale options, 15-12 to 15-17
illustration, 15-2
waveform chart, 15-22 to 15-29
cursors not supported, 15-25
data types, 15-22 to 15-25
front panel data logging (note), 4-6
options, 15-25 to 15-29
chart pop-up menu, 15-25
scope chart update mode, 15-27
stacked versus overlaid plots,
15-28 to 15-29
strip chart update mode, 15-27
sweep chart update mode, 15-27
update modes, 15-26 to 15-28
While Loops
auto-indexing
number of iterations, 18-9
overview, 18-7 to 18-8
running out of memory (note), 18-9
avoiding cycles in subVIs, 3-12
I-57
Index
Y
Y Scale submenu, 15-13, 15-40
Z
Z Scale Info Attribute
Color Array, 15-40
High Color, 15-40
Low Color, 15-40
zooming options, graph indicators,
15-17 to 15-19
I-58