DTWAIN_ArrayFind
The DTWAIN_ArrayFind function searches for an element in a DTWAIN_ARRAY.
LONG DTWAIN_ArrayFind (
Parameters Array DTWAIN_ARRAY to search.
pValue Address of the value to find.
Return Values If the function succeeds, the zero-based position of the element is returned. Otherwise -1 is returned if the element cannot be found, or another error has been encountered.
Comments The DTWAIN_ArrayFind function searches the DTWAIN_ARRAY Array, and returns the position of the element pointed to by pValue.
The data type of the value located at the address pValue must match the data type that is stored in Array. DTWAIN cannot determine the data type located at address pValue, therefore it is the responsibility of the programmer to provide the correct type.
For more specialized searches see the following:
Example: /* Find an element in a DTWAIN_ARRAY */ void Func( ) { DTWAIN_ARRAY Array; LONG i; LONG Position; LONG SearchVal;
/* Create a DTWAIN_ARRAY with 4 elements */ Array = DTWAIN_ArrayCreate(DTWAIN_ARRAYLONG, 4);
/* Store the values 0, 2, 4, and 6 in the DTWAIN_ARRAY */ for ( i = 0; i < 4; i++ ) { Val = i * 2; DTWAIN_ArraySetAt( Array, i, &Val ) }
/* Search for 2 */ SearchVal = 2; Position = DTWAIN_ArrayFind( Array, &SearchVal );
/* Position should be a 1, since the '2' was stored at Array[1] */
/* Search for 6 */ SearchVal = 6; Position = DTWAIN_ArrayFind( Array, &SearchVal );
/* Position should be a 3, since the '6' was stored at Array[3] */
/* Destroy the array */ DTWAIN_ArrayDestroy( Array ); }
TWAIN State Transitions None.
Prerequisite Function Call(s)
See Also |