Finds the first element to match a given string.

Syntax

SRP_FastArray_Match(Handle, StringToMatch, FieldPos, ValuePos, SubValuePos, MatchAnywhereFlag)

Parameters

ParameterDescription
HandleHandle to an existing SRP Fast Array (REQUIRED)
StringToMatchThe string containing the text you are trying to find.
FieldPosThe field position, if found, of the match.
ValuePosThe value position, if found, of the match.
SubValuePosThe sub-value position, if found, of the match.
MatchAnywhereFlagIf true, the match can occur anywhere in an element. Otherwise, only exact matches count.

Remarks

The SRP_FastArray_Match method locates an element within the list that matches the given string. The match is not case sensitive, but if the MatchAnywhereFlag is false (which is the default), then a match succeeds only when the string matches the entire element. If the MatchAnywhereFlag is true, then the first element contain the given string anywhere within itself is a match. For example, "Branded" is considered a match for "AND" because "and" appears within the element. When a match is found, the FieldPos, ValuePos, and SubValuePos parameters are set to the position of the match. If no match is found, all three parameters will be set to 0.

IMPORTANT: The SRP_FastArray_Match method will begin searching at the position specified in the FieldPos, ValuePos, and SubValuePos parameters. Set these to 1, or 0, to search from the beginning of the array. However, if you need to start the search elsewhere, then set the position in advance. For example, setting FieldPos to 3 tells the Match service to start looking for matches in field 3.

Examples

// Create a fast array
Handle = SRP_FastArray_Create("Apple":@FM:"Banana":@FM:"Carrot")

// Find banana
FieldPos = 0
ValuePos = 0
SubValuePos = 0
SRP_FastArray_Match(Handle, "banana", FieldPos, ValuePos, SubValuePos, 0)

// Result: FieldPos = 2, ValuePos = 1, SubValuePos = 1
 
// Find Doughnut
FieldPos = 0
ValuePos = 0
SubValuePos = 0
SRP_FastArray_Match(Handle, "doughnut", FieldPos, ValuePos, SubValuePos, 0)

// Result: FieldPos = 0, ValuePos = 0, SubValuePos = 0
 
// Find App anywhere
FieldPos = 0
ValuePos = 0
SubValuePos = 0
SRP_FastArray_Match(Handle, "app", FieldPos, ValuePos, SubValuePos, 1)

// Result: FieldPos = 1, ValuePos = 1, SubValuePos = 1

// All done
Variable = SRP_FastArray_Release(Handle)
  • No labels