2.2.3.2.5 CategoricalMap::LookUp

Description

Look up a category in this CategoricalMap and return its index.

Syntax

int LookUp( LPCSTR lpcszCategory )

Parameters

lpcszCategory
[input]Input category to look up

Return

Returns the index (1 based offset) of the category in this CategoricalMap if the category is found and returns -1 if it is not found.

Examples

EX1

void CategoricalMap_LookUp_ex1()
{
    Worksheet wks;
    wks.Create();
    if (wks)
    { 
        Dataset ds(wks, 0);
        ds.SetSize(8);
        vector<string> vs = {"aaa","bbb","ddd","ccc","qqq","777","aaa","ddd"};
        ds.PutStringArray(vs);
        string strWksColname = wks.Columns(0).GetName();
        strWksColname = wks.GetPage().GetName() + "_" + strWksColname;    
 
        StringArray vMyCatMap;
        CategoricalData cdMyCatData(strWksColname);
        vMyCatMap = (StringArray) cdMyCatData.Map;
        int index = cdMyCatData.Map.LookUp("ddd"); //index = 3, if look up "eee", index = -1
        string strVal = cdMyCatData.Map.ReverseLookUp(5);
    }
}

Remark

Look up a category (text value) in this CategoricalMap and return its index(1 based offset). If the CategoricalMap has an associated CategoricalData data set then all text data values in the CategoricalData data set equal to the specified category are mapped to the category's index value. For EX1, the text value "ddd" is mapped to the index 3.

See Also

CategoricalMap::ReverseLookUp

Header to Include

origin.h