cdds_key - keyword search or token count in definition value.

SYNOPSIS

#include "cdds.h"

int cdds_key(keyword);

const char *keyword

DESCRIPTION

This function is superceded by cdds_scank. The new function allows the scan definition to be selected in the same call. It also allows the value to be processed from the current position. cdds_key provides backward compatibility with an earlier version of DDS.

cdds_key is used to parse the value of the scan definition. This definition must have been previously selected using a cdds_scan...function, It is processed from left-to-right, starting at the beginning of the value (not current position). If a scan definition is not selected, cdds_key returns EOF.

The value of the scan definition is divided into tokens. Tokens are delimited by white space, and double quotes (optional). If a token is quoted, it may contain special characters. Any single character may be escaped by prefixing it with "\". Escapes are required to preserved special characters ('\', '=', '"'). White space within a quoted token does not need to be escaped. Escape characters "\" are removed during retrieval.

cdds_key can be used to count tokens. A count is requested by specifying a null keyword, i.e. NULL, zero length string, or a string that only contains white space. The function returns the number of tokens in the value. Zero is returned if none exist. The current position in the value is set to the beginning.

cdds_key can be used to search for a token in the scan value. A search is requested by specifying a non-null keyword. The keyword argument is parsed into tokens, similar to the value. The search stops at the first value token that matches any keyword token. If a match is found, its count is returned and the current position in the value is advanced to the token. If a match is not found, the function returns EOF and the current position is set to the beginning.

The function returns EOF, if a syntax error is detected in the tokens.

NOTE: This routine is deprecated; use cdds_scank instead.

EXAMPLE

          
            int j, count, n_red, max;
            const char *alias;
            float pick[100];

            /* select the "palette" definition */
            j = cdds_scanf("palette", "");

            /* count the number of colors */
            count = cdds_key(NULL);

            /* find a "reddish" token */
            n_red = cdds_key("scarlet crimson cherry");

            /* retrieve the reddish "alias" */
            j = cdds_scant(NULL, &alias);

            /* count and retrieve "depth_picks" */
            if(! cdds_scanf("depth_picks", "") {
            max = cdds_key(NULL);
            for(n = 0; n < max; n++)
            cdds_scanf(NULL, "%f", pick + n);
            }
          

SEE ALSO

      cdds_dict  Select DDS dictionary and mode
      cdds_scanv Retrieve value from scan dictionary
    

AUTHOR

R. L. Selzler, EPTG (Oct 1995)