nnl_util - Name-to-Number Lookup Utilities

The NNL_UTIL package provides several functions for looking up entries in name/number tables, returning (i) the number corresponding to a name or (ii) the name corresponding to a number.

A name/number table is simply an array of number/name entries whose last entry has a NULL name (NNLMap, defined in "nnl_util.h", is a structure containing a long number and a character string):

    #include  "nnl_util.h"		-- Name-to-Number Lookup utilities.

    static  const  NNLTable  exampleLUT = {
        {  1, "On" },
        { -1, "Off" },
        {  2, "Red" },
        { -2, "Green" },
        {  3, "Show" },
        { -3, "Hide" },
        { 45, NULL }
    } ;

(The number in the last NULL entry can be any number, e.g., a default value or an error indicator.)

Public Procedures

nnlCount)) - returns the number of entries in a name/number table.
nnlNameOf)) - looks up a name by number in a name/number table.
nnlNumberOf)) - looks up a number by name in a name/number table.

Source Files


Alex Measday  /  E-mail