Compaq AA-RH99A-TE Remote Starter User Manual


 
3.2.3 Getting a Representation of an Array Element
The array_element function returns a representation of one element of an
array. The function returns non-NULL if it succeeds or NULL if an error
occurs. When the value of error is non-NULL, the
error argument is set to
point to the error message. This function has the following syntax:
DataStruct array_element(
DataStruct sym,
int i,
char** error);
Argument
Input/Output
Description
sym
Input Names the array
i
Input Specifies the index of the element
error
Output Returns a pointer to an error message, if
the return value is NULL
You usually use the array_element function with the read_field_vals
function. You use the array_element function to get a representation of
an array element that is a structure or pointer to a structure. You then
pass this representation to the read_field_vals function to get the
values of fields inside the structure. For an example of how this is done, see
Example 3–4 in Section 3.3.
The first argument of the array_element function is usually the result
returned from the read_sym function.
______________________ Note _______________________
The read_sym, array_element, and read_field_vals
functions are often used together to retrieve the values of an
array of structures pointed to by a global pointer. (For more
information about using these functions, see the description of
the read_sym function in Section 3.2.27.)
For example:
if((ele = array_element(sz_softc, cntrl, &error)) == NULL){
fprintf(stderr, "Couldnt get %dth element of sz_softc:\n, cntrl");
fprintf(stderr, "%s\n", error);
}
3.2.4 Retrieving an Array Element Value
The array_element_val function returns the value of an array element. It
returns the integer value if the data type of the array element is an integer
3–4 Writing Extensions to the kdbx Debugger