Finds the index of the first element from the starting index that matches the given string.
Syntax
Index = SRP_List_Match(Handle, StringToMatch, StartIndex, MatchAnywhereFlag)
Returns
The index of the first element that matches the target value.
Parameters
Parameter | Description |
---|---|
Handle | Handle to an existing SRP List (REQUIRED) |
StringToMatch | The string to find in the SRP List (REQUIRED) |
StartIndex | The index to start the search (REQUIRED) |
MatchAnywhereFlag | If true, a match occurs if the string appears anywhere in the element. Otherwise, the whole element must match (REQUIRED) |
Remarks
The SRP_List_Match method searches for the first element that matches the given target and returns its index. The search is not case sensitive, unlike SRP_List_Locate. A match occurs if the whole element has the same text unless the MatchAnywhereFlag is set to 1, in which case the string can appear anywhere in an element. For example, if MatchAnywhereFlag is 1 and you are searching for "AND", there will be a successful match against "Branded".
The SearchIndex parameter tells the Match routine where to start the search. Set it to 1 or 0 to start at the beginning of the list. If, for example, you set the StartIndex to 5, then the search will begin at the fifth element and proceed down the list.
IMPORTANT: You should always release the handle to an SRP List when you no longer need it by calling SRP_List_Release.
Examples
// Create the list Handle = SRP_List_Create("Apple Pie,Banana Cream Pie,Chocolate Cake,Pie", ",") // This will return 4, since the search is looking for an element whose entire element matches "pie" Index = SRP_List_Match(Handle, "pie", 1, 0) // This will return 1, since the search is looking for an element containing "pie" anywhere Index = SRP_List_Match(Handle, "pie", 1, 1) // This will return 2, since the search starts at index 2 Index = SRP_List_Match(Handle, "pie", 2, 1) // Play nice with memory SRP_List_Release(Handle)