6504 Bridge Point ParkwayAustin, TX 78730-5039Tel: (512) 794-0100
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.
E
XCEPT AS SPECIFIED HEREIN
SPECIFICALLY DISCLAIMS ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
C
USTOMER’S RIGHT TO RECOVER DAMAGES CAUSED BY FAULT OR NEGLIGENCE ON THE PART OF NATIONAL
I
NSTRUMENTS SHALL BE LIMITED TO THE AMOUNT THERETOFORE PAID BY THE CUSTOMER
WILL NOT BE LIABLE FOR DAMAGES RESULTING FROM LOSS OF DATA
CONSEQUENTIAL DAMAGES
, N
ATIONAL INSTRUMENTS MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AND
. N
ATIONAL INSTRUMENTS
,
PROFITS, USE OF PRODUCTS, OR INCIDENTAL OR
,
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 owner’s
failure to follow the National Instruments installation, operation, or maintenance instructions; owner’s modification
of the product; owner’s 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
NI-DAQ®, NI-488.2™, and NI-488.2M™ are trademarks of National Instruments Corporation.
Product and company names listed are trademarks or trade names of their respective companies.
WARNING REGARDING MEDICAL AND CLINICAL USE
OF NATIONAL INSTRUMENTS PRODUCTS
National Instruments products are not designed with components and testing intended to ensure a level of reliability
suitable for use in treatment and diagnosis of humans. Applications of National Instruments products involving
medical or clinical treatment can create a potential for accidental injury caused by product failure, or by errors on
the part of the user or application designer. Any use or application of National Instruments products for or
involving medical or clinical treatment must be performed by properly trained and qualified medical personnel, and
all traditional medical safeguards, equipment, and procedures that are appropriate in the particular situation to
prevent serious injury or death should always continue to be used when National Instruments products are being
used. National Instruments products are NOT intended to be a substitute for any form of established process,
procedure, or equipment used to monitor or safeguard human health and safety in medical or clinical treatment.
The LabWindows/CVI Standard Libraries Reference Manual contains information about the
LabWindows/CVI standard libraries—the Graphics Library, the Analysis Library, the Formatting
and I/O Library, the GPIB Library, the GPIB-488.2 Library, the RS-232 Library, the Utility
Library, and the system libraries. The LabWindows/CVI Standard Libraries Reference Manual
is intended for use by LabWindows/CVI users who have already completed the Getting Startedwith LabWindows/CVI tutorial and are familiar with the LabWindows/CVI User Manual. To use
this manual effectively, you should be familiar with LabWindows/CVI and DOS fundamentals.
Organization of This Manual
The LabWindows/CVI Standard Libraries Reference Manual is organized as follows.
•Chapter 1, ANSI C Library, describes the ANSI C Standard Library as implemented in
LabWindows/CVI.
•Chapter 2, Formatting and I/O Library, describes the functions in the LabWindows/CVI
Formatting and I/O Library, and contains many examples of how to use them. The
Formatting and I/O Library contains functions that input and output data to files and
manipulate the format of data in a program.
•Chapter 3, Analysis Library, describes the functions in the LabWindows/CVI Analysis
Library. The Analysis Library Function Overview section contains general information about
the Analysis Library functions and panels. The Analysis Library Function Reference section
contains an alphabetical list of the function descriptions.
•Chapter 4, GPIB/GPIB-488.2 Library, describes the NI-488 and NI-488.2 functions in the
LabWindows/CVI GPIB Library, as well as the Device Manager functions in
LabWindows/CVI. The GPIB Library Function Overview section contains general
information about the GPIB Library functions and panels, the GPIB DLL, and guidelines
and restrictions you should know when using the GPIB Library. Detailed descriptions of the
NI-488 and NI-488.2 functions can be found in your NI-488.2 function reference manual.
The GPIB Function Reference section contains an alphabetical list of descriptions for the
Device Manager functions, the callback installation functions, and the functions for returning
the thread-specific status variables.
•Chapter 5, RS-232 Library, describes the functions in the LabWindows/CVI RS-232 Library.
The RS-232 Library Function Overview section contains general information about the RS-232
Library functions and panels. The RS-232 Library Function Reference section contains an
alphabetical list of function descriptions.
•Chapter 6, DDE Library, describes the functions in the LabWindows/CVI DDE (Dynamic
Data Exchange) Library. The DDE Library Function Overview section contains general
information about the DDE Library functions and panels. The DDE Library FunctionReference section contains an alphabetical list of function descriptions. This library is
available for LabWindows/CVI for Microsoft Windows only.
•Chapter 7, TCP Library, describes the functions in the LabWindows/CVI TCP (Transmission
Control Protocol) Library. The TCP Library Function Overview section contains general
information about the TCP Library functions and panels. The TCP Library FunctionReference section contains an alphabetical list of function descriptions.
•Chapter 8, Utility Library, describes the functions in the LabWindows/CVI Utility Library.
The Utility Library contains functions that do not fit into any of the other LabWindows/CVI
libraries. The Utility Library Function Panels section contains general information about the
Utility Library functions and panels. The Utility Library Function Reference section contains
an alphabetical list of function descriptions.
•Chapter 9, X Property Library, describes the functions in the Lab/Windows CVI X Property
Library. The X Property Library contains functions that read and write properties to and from
X Windows. The X Property Library Overview section contains general information about
the X Property Library functions and panels. The X Property Library Function Reference
section contains an alphabetical list of function descriptions.
•Chapter 10, Easy I/O for DAQ Library describes the functions in the Easy I/O for DAQ
Library. The Easy I/O for DAQ Library Function Overview section contains general
information about the functions, and guidelines and restrictions you should know when using
the Easy I/O for DAQ Library. The Easy I/O for DAQ Library Function Reference section
contains an alphabetical list of function descriptions.
•Appendix A, Customer Communication, contains forms you can use to request help from
National Instruments or to comment on our products and manuals.
•The Glossary contains an alphabetical list and description of terms used in this manual,
including abbreviations, acronyms, metric prefixes, mnemonics, and symbols.
•The Index contains an alphabetical list of key terms and topics in this manual, including the
page where you can find each one.
The following conventions are used in this manual:
About This Manual
bold
italicItalic text denotes emphasis, a cross reference, or an introduction to
bold italicBold italic text denotes a note, caution, or warning.
monospaceText in this font denotes text or characters that you should literally
italic monospace
< >Angle brackets enclose the name of a key. A hyphen between two
Bold text denotes a parameter, menu item, return value, function
panel item, or dialog box button or option.
a key concept.
enter from the keyboard. Sections of code, programming
examples, and syntax examples also appear in this font. This font
also is used for the proper names of disk drives, paths, directories,
programs, subprograms, subroutines, device names, variables,
filenames, and extensions, and for statements and comments taken
from program code.
Italic text in this font denotes that you must supply the appropriate
words or values in the place of these items.
or more key names enclosed in angle brackets denotes that you
should simultaneously press the named keys–for example,
<Ctrl-Alt-Delete>.
»The » symbol leads you through nested menu items and dialog
box options to a final action. The sequence
File » Page Setup » Options » Substitute Fonts
directs you to pull down the
item, select
option from the last dialog box.
pathsPaths in this manual are denoted using backslashes (\) to
separate drive names, directories, and files, as in
drivename\dir1name\dir2name\myfile
IEEE 488, IEEE 488 and IEEE 488.2 refer to the ANSI/IEEE Standard 488.1-1987, IEEE 488.2
and the ANSI/IEEE Standard 488.2-1992, respectively, which define the GPIB.
Abbreviations, acronyms, metric prefixes, mnemonics, symbols, and terms are listed in the
For a detailed discussion of the best way to use the LabWindows/CVI documentation set, see the
section Using the LabWindows/CVI Documentation Set in Chapter 1, Introduction toLabWindows/CVI of Getting Started with LabWindows/CVI.
Related Documentation
The following documents contain information that you may find helpful as you read this manual:
•ANSI/IEEE Standard 488.1-1987, IEEE Standard Digital Interface for Programmable
Instrumentation
•ANSI/IEEE Standard 488.2-1992, IEEE Standard Codes, Formats, Protocols, and Common
Commands
•Harbison, Samuel P. and Guy L. Steele, Jr., C: A Reference Manual, Englewood Cliffs, NJ:
Prentice-Hall, Inc., 1995.
•Gettys, James and Robert W. Scheifler. Xlib—C Language X Interface, MIT X ConsortiumStandard. Cambridge, Massachussetts: X Consortium, 1994. ISBN (none)
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
technical support forms for you to complete. These forms are in the appendix, Customer
Table 1-1. ANSI C Standard Library Classes (Continued)
General Utilities<stdlib.h>
String to Arithmetic Expression
Random Number Generation
Memory Management
Searching and Sorting
Integer Arithmetic
Multibyte Character Sets
Program Termination
Environment
String Handling<string.h>
Byte Operations
String Operations
String Searching
Collation Functions
Miscellaneous
Low-Level I/O Functions
Under UNIX you can use the low-level I/O functions (such as open, sopen, read, and
write) from the system library by including system header files in your program. Under
Windows you can use these functions by including cvi\include\ansi\lowlvlio.h in
your program. No function panels are provided for these functions.
Standard Language Additions
LabWindows/CVI does not support extended character sets that require more than 8 bits per
character. As a result, the wide character type wchar_t is identical to the single-byte char
type. LabWindows/CVI accepts wide character constants specified with the L prefix (as in
L‘ab’), but only the first character is significant. Furthermore, library functions that use the
wchar_t type operate only on 8-bit characters.
LabWindows/CVI supports variable argument functions using the ANSI C macros, with one
exception: none of the unspecified arguments can have a struct type. As a result, the macro
va_arg (ap, type) should never be used when type is a structure.
Note:
Under UNIX, LabWindows/CVI implements only the C locale as defined by the ANSI C
standard. The native locale, which is specified by the empty string, "", is also the C locale. The
following table shows the locale information values for the C locale.
Under Windows, LabWindows/CVI implements the default locale by using the appropriate items
from the Intl section of the WIN.INI file and appropriate Microsoft Windows functions.
Anything not mentioned here has the same behavior under the default locale as specified in the C
locale.
For the LC_NUMERIC locale:
•decimal_point maps to the value of sDecimal.
•thousands_sep maps to the value of sThousand.
For the LC_MONETARY locale:
•currency_symbol maps to the value of sCurrency.
•mon_decimal_point maps to the value of sDecimal.
•mon_thousands_sep maps to the value of sThousand.
•frac_digits maps to the value of iCurrDigits.
•int_frac_digits maps to the value of iCurrDigits.
•p_cs_precedes and n_cs_precedes are set to 1 if iCurrency equals 0 or 2,
otherwise they are set to 0.
•p_sep_by_space and n_sep_by_space are set to 0 if iCurrency equals 0 or 1,
otherwise they are set to 0.
•p_sign_posn and n_sign_posn are determined by the value of iNegCurr as follows:
Value of
Value of iNegCurr
p_sign_posn/n_sign_posn
0, 40
1, 5, 8, 91
3, 7, 102
63
24
For the LC_CTYPE locale:
•isalnum maps to the Windows function isCharAlphaNumeric.
•isalpha maps to the Windows function isCharAlpha.
•islower maps to the Windows function isCharLower.
•isupper maps to the Windows function isCharUpper.
•tolower maps to the Windows function AnsiLower.
•toupper maps to the Windows function AnsiUpper.
For the LC_TIME locale:
•strftime uses the following items from the WIN.INI file for the appropriate format
specifiers: sTime, iTime, s1159, s2359, iTLZero, sShortDate, and sLongDate.
•The names of the weekdays and the names of the months match the language version of
LabWindows/CVI. That is, a German version of LabWindows/CVI would use the German
names of months and days.
For the LC_COLLATE locale:
•strcoll maps to the Windows function lstrcmp.
Because LabWindows/CVI does not support extended character sets that require more than a
byte per character, a multibyte character in LabWindows/CVI is actually a single byte character.
Likewise, a multibyte sequence is a sequence of single byte characters. Because a multibyte
character is the same as a wide character, the conversion functions described in these sections do
little more than return their inputs as outputs.
Character Processing
LabWindows/CVI implements all the ANSI C character processing facilities as both macros and
functions. The macros are disabled when the LabWindows/CVI debugging level is set to
Standard or Extended, so that user protection is available for the arguments to the functions.
String Processing
Under UNIX, the strcoll function is equivalent to strcmp and its behavior is not affected by
the LC_COLLATE locale. Under Windows, strcoll is equivalent to the Windows function
lstrcmp. For both platforms, the function strxfrm performs a string copy using strncpy
and returns the length of its second argument.
The function rename fails if the target file already exists. Under Microsoft Windows, rename
fails if the source and target files are on different disk drives. Under UNIX, rename fails if the
source and target files are on different file systems.
The functions fgetpos and ftell set errno to EFILPOS on error.
errno Set by File I/O Functions
The errno global variable is set to indicate specific error conditions by the ANSI C file I/O
functions and the low-level I/O functions. The possible values of errno are declared in
cvi\include\ansi\errno.h. There is a base set of values that is common to all
platforms. There are additional values that are specific to particular platforms.
Under Windows 3.1, errno gives very limited information. If the operating system returns an
error, errno is set to EIO.
Under Windows 95 and NT, you can call the Windows SDK GetLastError function to
obtain system specific information when errno is set to one of the following values:
EACCES
EBADF
EIO
ENOENT
ENOSPC
Mathematical Functions
The macro HUGE_VAL defined in the header math.h as well as the macros FLT_EPSILON,
FLT_MAX, FLT_MIN, DBL_EPSILON, DBL_MAX, DBL_MIN, LDBL_EPSILON, LDBL_MAX,
and DBL_MIN defined in the header float.h all refer to variables. Consequently, these
macros cannot be used in places where constant expressions are required, such as in global
initializations.
Time and Date Functions
Function time returns the number of seconds since January 1, 1990.
Functions mktime and localtime require time zone information to produce correct results.
LabWindows/CVI obtains time zone information from the environment variable named TZ, if it
exists. The value of this variable should have the format AAA[S]HH[:MM]BBB, where optional
items are in square brackets.
The AAA and BBB fields specify the names of the standard and daylight savings time zones,
respectively (such as EST for Eastern Standard Time and EDT for Eastern Daylight Time). The
optional sign field S indicates whether the local time zone is to the west (+) or to the east (-) of
UTC (Greenwich Mean Time). The hour field (HH) and the optional minutes field (:MM) specify
the number of hours and minutes from UTC. As an example, the string EST05EDT specifies the
time zone information for the eastern part of the United States.
The functions gmtime, localtime, and mktime make corrections for daylight savings time
(DST). LabWindows/CVI uses a set of rules for determining when daylight savings time begins
and ends. A string in the messages file cvimsgs.txt in the LabWindows/CVI bin directory
specifies these rules. The following is the default value of this string.
":(1986)040102+0:110102-0:(1967)040102-0:110102-0"
This states that for the years from 1986 to the present, DST begins at 2:00 a.m. on the first
Sunday in April, and ends at 2:00 a.m. on the last Sunday in October. For the years from 1967 to
1985, DST begins at 2:00 a.m. on the last Sunday in March, and ends at 2:00 a.m. on the last
Sunday in October. You can change the way LabWindows/CVI determines DST by changing
this string in the cvimsgs.txt file. The countmsg.exe program must be executed after
changing the text file. You should execute the following line.
countmsg cvimsgs.txt
Control Functions
The assert macro defined by LabWindows/CVI does not print diagnostics to the standard
error stream when the debugging level is anything other than None. Instead, when the value of
its argument evaluates to zero, LabWindows/CVI will display a dialog box with a message
containing the file name, line number, and expression that caused the assert to fail.
Under UNIX, system passes the specified command to the Bourne shell (sh) as input, as if the
current process was performing a wait(2V) system call and was waiting until the shell
terminated. Callbacks are not called while the command is executing.
Under Windows, the executable can be either an MS DOS or Microsoft Windows executable,
including *.exe, *.com, *.bat, and *.pif files. The function does not return until the
command terminates, and user keyboard and mouse events are ignored until the command exits.
Callbacks for asynchronous events, such as idle events, Windows messages, and VXI interrupts,
PostDeferredCall calls, and DAQ events are called while the command is executing. If
you need to execute a command built into command.com such as copy, dir, and others, you
can call system with the command command.com /C DosCommand args, where
DosCommand is the shell command you would like executed. Refer to your DOS
documentation for further help with command.com. DOS executables (.exe, .com, and
.bat files) use the settings in _default.pif (in your Windows directory) when they are
running. You can change their priority, display options, and more by editing _default.pif
or by creating another .pif file. Refer to your Microsoft Windows documentation for help on
creating and editing .pif files.
If the function is passed a null pointer, LabWindows/CVI returns a non zero value if a command
processor is available. Under UNIX, if the argument is not a null pointer, the program returns a
zero. Under Microsoft Windows, if the argument is not a null pointer, the program returns zero
if the program was successfully started, otherwise it returns one of the following error codes.
-1 System was out of memory, executable file was corrupt, or relocations were invalid.
-3 File was not found.
-4 Path was not found.
-6 Attempt was made to dynamically link to a task, or there was a sharing or network
protection error.
-7 Library required separate data segments for each task.
-9 There was insufficient memory to start the application.
-11 Windows version was incorrect.
-12 Executable file was invalid. Either it was not a Windows application or there was an error
in the .EXE image.
-13 Application was designed for a different operating system.
-14 Application was designed for MS-DOS 4.0.
-15 Type of executable file was unknown.
-16 Attempt made to load a real-mode application (developed for an earlier Windows version.)
-17 Attempt was made to load a second instance of an executable file containing multiple data
segments that were not marked read-only.
-20 Attempt was made to load a compressed executable file. The file must be decompressed
before it can be loaded.
-21 Dynamic-link library (DLL) file was invalid. One of the DLLs required to run this
application was corrupt.
-22 Application requires Microsoft Windows 32-bit extensions.
-23 Could not find toolhelp.dll or toolhelp.dll is corrupted.
-24 Could not allocate a GetProcUserDefinedHandle.
The exit function does not actually flush and close the open streams. LabWindows/CVI leaves
files open so that they may be used from within the Interactive Window after execution of the
project terminates. The Close Libraries menu option under the Run menu performs this library
cleanup. This library cleanup is also performed when you restart execution of the project by
selecting Run Project from the Run menu. The argument passed to function exit is not used
by the LabWindows/CVI environment. Under UNIX, standalone executables created by
LabWindows/CVI return the value of the argument passed to the exit function.
The UNIX version of LabWindows/CVI works with all the signals supported by UNIX in
addition to the ANSI C signals.
ANSI C Library Function Reference
For ANSI C function descriptions, consult a reference work such as C: A Reference Manual
which is listed in the Related Documentation section of About This Manual. Alternatively, you
can use LabWindows/CVI function panel help. The following function description is provided
because it is an extension of the ANSI C function set.
fdopen
FILE *fp =
Note:
This function is available only in the Windows version of LabWindows/CVI.
Purpose
You can use this function to obtain a pointer to a buffered I/O stream from a file handle returned
by one of the following functions.
open(low-level I/O)
sopen(low-level I/O)
You can use the return value just as if you had obtained it from fopen.
(Although this function is not in the ANSI standard, it is included in this library because it
returns a pointer to a buffered I/O stream.)
Parameters
Input
fdopen
fileHandle
mode
fileHandle
(int
integerFile handle returned by open or sopen.
stringSpecifies the read/write, binary/text, and append modes.
Parameter Discussion
mode is the same as the mode parameter to fopen.
You should use a mode value that is consistent with the mode in which you originally opened the
file. If you use write capabilities that were not enabled when the file handle was originally
opened, the call to fdopen succeeds, but any attempt to write fails. For instance, if you
originally opened the file for reading only, you can pass "rw" to fdopen, but any call tofwrite fails.