National Instruments PC-OPDIO-16 Manuale Utente
The Fundamentals of Building Applications with NI-DAQChapter 4
PC-OPDIO-16 User Manual
4-6
© National Instruments Corporation
If you are using Borland C++ version 4.0, you need to edit the definition of
halloc
in the
include file
MALLOC.H
in the include directory. To do so, go to line 65 in
MALLOC.H
and
remove the underscore from in front of
farmalloc
. The line should then read as follows:
#define halloc(num, size) (void huge *)farmalloc((unsigned
long)(num)* (size))
long)(num)* (size))
This change correctly maps the
halloc
function, which several NI-DAQ for DOS example
programs use.
Example Programs
You can find a set of example programs and the necessary header files in the
NIDAQDOS\C_EX
directory. Not all of the examples will work with Borland C because some of them use plotting
routines written with Microsoft C. However, you can comment out the plotting operations and
use those example programs.
routines written with Microsoft C. However, you can comment out the plotting operations and
use those example programs.
Creating a DOS Application Using Borland Turbo Pascal
To create a Turbo Pascal application that calls NI-DAQ functions, perform the following steps:
1. Create your source code. Follow the instructions in this chapter when making NI-DAQ
function calls.
Note: You must call the
USE
function in your application before calling any other
NI-DAQ functions. This function causes portions of the NI-DAQ library that are
required to use your DAQ product to be included in your application. If you do not
call the appropriate
required to use your DAQ product to be included in your application. If you do not
call the appropriate
USE
function, your other NI-DAQ functions will return error -
421 (functionNotLinkedErr).
2. Add the
NIDAQ
unit to the
USES
clause in your source code.
3. When compiling your program, be sure that the Turbo Pascal compiler can locate the
NI-DAQ units.
•
If you are using the Integrated Development Environment (IDE), the directory containing
the NI-DAQ units should be specified as one of the Unit directories under the
Options | Directories menu. It is recommended that you choose Auto Save for the
Environment in the Options | Environment | Preferences menu to make the change
permanent.
the NI-DAQ units should be specified as one of the Unit directories under the
Options | Directories menu. It is recommended that you choose Auto Save for the
Environment in the Options | Environment | Preferences menu to make the change
permanent.
•
If you are using the command-line version of the compiler, specify the directory using the
/Uxxx
switch.
•
You may notice the compiler directive
{$N+}
in some of the NI-DAQ Turbo Pascal
example programs. This option directs the compiler to generate inline 80x87 code for
handling floating point numbers. This code is required by NI-DAQ routines that use
variables of type Double.
handling floating point numbers. This code is required by NI-DAQ routines that use
variables of type Double.