# cbMemReadPretrig()

Reads pre-trigger data collected with the cbAPretrig() function from a memory board, and re-arranges the data in the correct order (pre-trigger data first, then post-trigger data). This function can only be used to retrieve data that was collected with the cbAPretrig() function with EXTMEMORY set in the options argument. After each cbAPretrig() call, all data must be unloaded from the memory board with this function. If any more data is sent to the memory board then the pre-trigger data will be lost

## Function Prototype

C/C++

int cbMemReadPretrig(int BoardNum, unsigned short DataBuffer[], long FirstPoint, long Count)

Visual Basic

Function cbMemReadPretrig(ByVal BoardNum&, DataBuffer%, ByVal FirstPoint&, ByVal Count&) As Long

## Arguments

BoardNum

The number associated with the board when it was installed with InstaCal or created with cbCreateDaqDevice(). BoardNum may be 0 to 99.

DataBuffer

The pointer to the data array.

FirstPoint

Index of first point to read or FROMHERE. Use FirstPoint to specify the first point to read. For example, to read data sample numbers 200 through 250, set FirstPoint = 200 and Count = 50.

Count

Number of data samples (words) to read.

## Returns

- Error code or 0 if no errors
- DataBuffer – data read from the memory board.

## Notes

- When reading a large amount of data from the board in small chunks, set FirstPoint to FROMHERE to read each successive chunk. Using FROMHERE speeds up the operation of cbMemReadPretrig() when working with large amounts of data.
- For example, to read 300,000 points in 100,000 chunks the calls would look like this:

cbMemReadPretrig(0, DataBuffer, 0, 100000)

cbMemReadPretrig(0, DataBuffer, FROMHERE, 1000000)

cbMemReadPretrig(0, DataBuffer, FROMHERE, 1000000)

- DT Connect Conflicts: The cbMemReadPretrig() function can not be called while a DT Connect transfer is in progress. For example, if you start collecting A/D data to the memory board in the background (by calling cbAInScan() with the DTCONNECT + BACKGROUND options), you can not call cbMemReadPretrig() until the cbAInScan() has completed. If you do you will get a DTACTIVE error.