TAlternateTextMatch provides a way for you to create a set of text strings that you can attach to a particular segment of the text template. The TParameterFormatter::Scan function uses this list as a set of alternate matches. When the scanning operation reaches the segment of the template with the attached TAlternateTextMatch, it calls the TAlternateTextMatch::Match function to iterate through the list of alternate strings.
You can also provide case-insensitive alternate matching by specifying a text-ordering object when you construct the TAlternateTextMatch.

TAlternateTextMatch derives from the abstract class TTextMatch. To provide a different mechanism for alternate text matching, you can derive your own class from TTextMatch. You must override the TTextMatch::Match function, providing your own matching algorithm. This function returns a Boolean indicating whether there is a match and the number of characters matched.
 
To use TAlternateTextMatch: 
 
 Example: Using TAlternateTextMatch
This example demonstrates how to provide the alternate match she for the pronoun he.
  TParameterFormatter myFormatter;
  TPositionalNumberFormatter myNumberFormatter;
  TFormattableParameterList parameters;
  TScanResult result;
  TAlternateTextMatch alternateMatch;
  TFormattableNumber num;
  
  // Create the text template.
  TStandardText textTemplate( "He has XX books.");
  myFormatter.SetTemplate(textTemplate);
  
  // Establish the parameters and attach formatters.
  myFormatter.SetParameterType(0,TStandardText("TFormattableNumber"));
  myFormatter.SetParameterFormat(TTextRange(TTextOffset(7),TTextOffset(9)),
                                  0, myNumberFormatter);
  
  // Add the alternate text match.
  alternateMatch.AddAlternateText(TStandardText("She"));
  myFormatter.SetTextMatch(TTextRange(TTextOffset(0),TTextOffset(2)),
                               alternateMatch);
  
  // Perform the scanning operation.
  TStandardText scanText("She has 499 books.");
  myFormatter.Scan(scanText,TTextRange::GetMaximumRange();
                      parameters, result);
  
  // Verify the scanned-in value.
  parameters.GetParameter(0,num);
[Contents]
 
[Previous]
 
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.