National Instruments PC-OPDIO-16 Manuale Utente

Pagina di 92
Chapter 4
The Fundamentals of Building Applications with NI-DAQ
© National Instruments Corporation
4-13
PC-OPDIO-16 User Manual
     
Huge Buffer Access   
Unlike C and C++, Turbo Pascal does not support huge pointers.  Consequently, you must
perform your own pointer arithmetic when accessing memory buffers greater than 64 KB in size.
Essentially, whenever you increment a pointer to a buffer of memory, you should check the low
word of the pointer to see if it rolls over from $FFFF back to $0000.  In this case, you need to
increment the high word of the pointer by a value given as 
Ofs(AHIncr)
.  This increments the
Windows selector by the correct amount and references the next 64 KB segment.  By using
record variants like 
PMemory
 used in 
DAQOP_TP.PAS
, you can easily access both the pointer
and the high and low words of the pointer value.  For more details, please see your Turbo Pascal
manuals.
    
String Passing
    
Normally, standard Pascal strings consist of an array of up to 255 characters, with the first byte
reserved for the length of the existing string.  However, Windows and NI-DAQ functions expect
a null-terminated string, such as those used in the C language.  Fortunately, Turbo Pascal for
Windows extends the string syntax to support the null-terminated string.  To use this option,
check to ensure that the extended syntax compiler option 
{$X+}
 is enabled (which is the
default), and then declare the string as an array of characters, as in the following example:
type
Tfilename = array[0..80] of Char;
begin
err := DAQ_to_Disk(.., Tfilename, ...);
In addition, Turbo Pascal has a predefined pointer to a null-terminated string called 
PChar
.  To
pass a null-terminated string to a procedure or function, pass either a 
PChar
 pointer variable to
the string, or pass the name itself without an index.
    
Parameter Passing
    
By default, Pascal passes parameters by value.  Include the 
var
 keyword if you need to pass by
reference.
Note: Functions such as 
DAQ_Monitor
 or 
Align_DMA_Buffer
 return variables
(
newestPtIndex and AlignIndex
) that index certain buffers.  These values
assume that the index of your first index is zero.  If your Pascal array starts at one, you
must add one to these variables if you use them.