cfunc.key C Function/C Functions

cfunc.key

Command cfunc.key C Function/C Functions
Applicable release versions: AP 6.1
Category C Functions (120)
Description equivalent to the Pick/BASIC statement: key(string1, expression, string2, string3)

An additional parameter, value, is available from C which returns the current value of the key if it is multi-valued.

This function returns -1 if an error occurs. The error code is contained in _CP_errno. If the key operator is invalid, _CP_errno will contain PE_ILL_KEY. If the root pointer is invalid, _CP_errno will contain PE_NOTROOT.
Syntax int _CP_key(CPSTR* string1, int expression, CPSTR** string2, CPSTR** string3, int* value)
Options
Example
The following gets the first item-id which contains "a" as attribute 
1.

CPSTR * n = _CP_mkstr("myfile");
CPSTR * a = _CP_mkstr("a1");
CPSTR * op = _CP_mkstr("n");
CPSTR * k = _CP_mkstr("a");
CPSTR * i = _CP_str_null;
int r,dummy;

_CP_root(n,a,&r);
_CP_key(op,r,&k,&i,&dummy);
Purpose
Related cfunc.introduction