_CP_select is equivalent to the select expression1 to list BASIC statement.
int _CP_select(int expression1, int* list, int expression2)
If expression2 is nonzero, then the secondary list is assumed. The default behavior of _CP_select is to create an internal select list which contains the item-IDs of the file pointed to by expression1. expression1 must have been previously created by a _CP_open call.
This function returns -1 if an error occurs. The error code is contained in _CP_errno.
/* Prints the item names in "myfile". */ CPSTR * n = _CP_mkstr("myfile"); CPSTR * id = _CP_str_null; int sl = -1; int f = -1; _CP_open(&f, _CP_str_null, n); _CP_select(f, &sl, 0); while (_CP_readnext(&id,&sl,(int*)0,0)>=0) _CP_print(id);
The example below demonstrates how an external select list overrides the file variable passed as expression1. Here, "myfile" is passed to the select, but the readnext returns items from the master dictionary.
CPSTR * n = _CP_mkstr("myfile"); CPSTR * s = _CP_mkstr("select md sampling 3"); CPSTR * id = _CP_str_null; int sl = -1; int f = -1; _CP_execute(_CP_EXECUTE, s, (CPSTR**) 0, (CPSTR**) 0); _CP_open(&f, _CP_str_null, n); _CP_select(f, &sl, 0); while (_CP_readnext(&id, &sl, (int*) 0, 0) >= 0) _CP_print(id);