int IndexOfNodeInList_bn ( const node_bn*  node,   const nodelist_bn*  nodes,   int  start_index )

Returns the position (index) of node in the list nodes, or -1 if it was not found.

It starts searching at index start_index; pass 0 to search the whole list.

It is okay if node is NULL.

Version:

Versions 2.11 and later have this function.

See also:

NthNode_bn  (inverse function) Returns the index, given the node
NodeNamed_bn  Search for node by name
LengthNodeList_bn  Returns the maximum node index

Example:

// Like IndexOfNodeInList_bn, but generates an error if there is not exactly
//   one instance of node in list nodes.
//
int IndexOfNodeInList (const node_bn* node, const nodelist_bn* nodes){
    int i = IndexOfNodeInList_bn (node, nodes, 0);
    if (i == -1)
        NewError (env, 901, ERROR_ERR,
                  "IndexOfNodeInList: There is no node '%s' in the list",
                  node ? GetNodeName_bn (node) : "null");
    else {
        int second = IndexOfNodeInList_bn (node, nodes, i + 1);
        if (second != -1)
            NewError (env, 902, ERROR_ERR,
                      "IndexOfNodeInList: There is more than one instance of node '%s' in the
                       list",
                      node ? GetNodeName_bn (node) : "null");
    }
    return i;
}
Example 2:
See NodeNamed_bn example 'FindNodeNamed' to search a node list for a node with a given name.