Пример #1
0
static UInt16 WordsListFormFindClosestProposal(AppContext* appContext, const ListType* list, const char* word)
{
    UInt16 itemCount=appContext->wordsInListCount;
    const char* const * items=appContext->wordsList;
    Assert(items);
    Assert(itemCount);
    UInt16 proposal=0;
    if (itemCount)
    {
        Int32 position=0;
        Boolean found=SysBinarySearch(items, itemCount, sizeof(const char*), ProposalSearchFunction, word, 0, &position, true);
        Assert(position>=0);
        Assert(position<=itemCount);
        if (position==itemCount)
            position--;
/*
        if (position>0)
        {
            const char* match=LstGetSelectionText(list, position);
            if (StrCompare(match, word)>0)
                position--;
        }
*/        
        proposal=position;
    }
    return proposal;
}
Пример #2
0
/***********************************************************************
 *
 * FUNCTION:    PrvSearchTimeZoneNames
 *
 * DESCRIPTION: Search for the first name that starts with <chr>. If
 *		we find a match, return the index, otherwise return noListSelection.
 *
 * PARAMETERS:
 *		tzArrayP			 ->	Pointer to array of TimeZoneEntryType records.
 *		numTimeZones	 ->	Number of records in tzArrayP array.
 *		firstChar		 ->	Character to match to beginning of name.
 *
 * RETURNED:
 *		Index of matching entry (0...numTimeZones-1) or noListSelection if
 *		no match is found.
 *
 * HISTORY:
 *		08/01/00	kwk	Created by Ken Krugler.
 *
 ***********************************************************************/
static Int16 PrvSearchTimeZoneNames(TimeZoneEntryType* tzArrayP, UInt16 numTimeZones, WChar firstChar)
{
	Int32 position;
	Char buffer[maxCharBytes+1];
	buffer[TxtSetNextChar(buffer, 0, firstChar)] = '\0';
	
	if (SysBinarySearch(	tzArrayP,
								numTimeZones,
								sizeof(TimeZoneEntryType),
								PrvCompareNameToTimeZoneEntry,
								buffer,
								StrLen(buffer),
								&position,
								true))
	{
		return(position);
	}
	else
	{	
		return(noListSelection);
	}
} // PrvSearchTimeZoneNames