Functions > di_copy_buffer

Syntax 

The di_copy_buffer function copies the input buffer into a user-specified array.

Syntax 

int di_copy_buffer (buf_index, dest (0), number);

unsigned buf_index;

/* specifies the offset from the first element in the buffer */

int _huge *dest (0);

/* specifies destination array name */

unsigned number;

/* specifies how many array elements to copy to dest (0)*/

Parameters

buf_index

buf_index specifies the offset from the first element in the buffer. If an offset of zero is specified, data is copied to the user-specified array starting with the very first element in the buffer. Specifying an offset of 10 will start the copy process with the tenth value from the top of the buffer (etc.).

_huge *dest (0)

Specifies the destination array name. The _huge pointer allows C programmers to specify a destination array larger than 64k bytes.

number

Specifies how many array elements to copy to copy to dest (0).

Return Value

DI_NO_ERR No error

Dependencies

di_buffer_alloc

Remarks

This function also supports buffer wrapping (i.e., if buf_index and number exceed the buffer size in words, the copy process continues from the start of the buffer). The di_buffer_status function can be used to compute buf_index, which must be between 0 and (buffer size - 1). Although number may be as large as the buffer size, active scanning may concurrently modify values starting at the index returned by di_buffer_status.

Sample Code

Declare Sub di_copy_buf Lib "200SDK.DLL" (ByVal buf_index%, dest%(), ByVal number%)

Dim in_buff%

'offset in the input buffer Dim

analog_in%(1000)

'array used to store analog in

Dim number%

'number of samples to copy

Sub Form_Load ()

' This copies the first 500 values of the input buffer to the array "analog_in" starting with element 0

buf_index = 0

number = 500

di_copy_buffer buf_index,analog_in(0),number

End Sub

 

Copyright © DATAQ Instruments, Inc.