[ Previous ] [ Contents ] [ Index ] [ Next ]

Ns_SetFind

Overview

Locate the index of a field within an Ns_Set

Syntax

    int Ns_SetFind(
    	Ns_Set		*set,
    	char		*key
    );

Description

The Ns_SetFind function returns the index of the first field whose key name matches the given key. The index is in C array order, i.e., 0 is the index of the first field. If no fields are found, Ns_SetFind returns -1. If more than one field in the set has the same key name, Ns_SetFind returns just the first field index.

The Ns_SetIFind function is this function's case-insensitive counterpart.

Example

    Ns_Set *aSet;
    int index;
    
    aSet = Ns_SetCreate("");
    Ns_SetPut(aSet, "Foo", "foovalue");
    Ns_SetPut(aSet, "Bar", "barvalue");
    index = Ns_SetFind(aSet, "Foo"); /* case sensitive search*/
    if (index == -1) {
    	Ns_Log(Warning, "set key Foo not found");
    } else {
    	Ns_Log(Notice, "Value for Foo is %s", 
    			Ns_SetGet(aSet, "Foo"));
    }
    Ns_SetFree(aSet);

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1996 America Online, Inc.